Skip to content

Use udev symlinks instead of event file paths#46

Open
Lxtharia wants to merge 2 commits intodaisyUniverse:masterfrom
Lxtharia:udev_symlink
Open

Use udev symlinks instead of event file paths#46
Lxtharia wants to merge 2 commits intodaisyUniverse:masterfrom
Lxtharia:udev_symlink

Conversation

@Lxtharia
Copy link
Copy Markdown

@Lxtharia Lxtharia commented Apr 7, 2025

These changes should help with the problem, that the /dev/input/eventXX file for a device might be different after a reboot (see https://wiki.archlinux.org/title/Udev)

This issue was mentioned in #34 and @triplefox proposed steps on how to tackle this problem:
#34 (comment)

Even though there might even be a way to do this without udev, I've stuck with it, as it's needed for the systemd service anyway.

The main idea is to prompt a user for a explicit device name (instead of using event23 for example)
and then let udev create a symlink like /dev/numpad -> /dev/input/eventXX automatically on boot.
To do this, udev needs some way of identifying a device.
I've decided to use the ATTRS(phys) attribute.
The steps are now as follows:

  1. User creates new device keebie -n and gets prompted for a name (f.e. numpad1)
  2. The current event file is recognized as usual by pressing a key on the device (f.e. /dev/input/event23)
  3. The ATTRS(phys) is read from that device (via evdev)
  4. This attribute is used in the udev rule that will symlink the device to /dev/numpad1
    • A symlink is created for the current session so the user doesn't need to reboot

A configuration file looks now like this:

{
   "initial_layer": "default.json",
   "devFile": "/dev/numpad",
   "udev_match_keys": [
      "ATTRS(phys)==\"usb-0000:0a:00.3-2/input0\""
   ],
   "udev_rule": "85-keebie-numpad.rules"
}

I have not tested it much, but I will do so in the next few days. Still wanted to open the PR now for feedback.

Lxtharia added 2 commits April 7, 2025 22:41
User will now be prompted for a device name.
Udev rule will create a symlink with that name that links to the correct
device (identified by ATTR(phys)) on reboot
make install now installs the systemd service
the systemd service will be installed as user service
the udev rule starts the keebie user service
@Lxtharia
Copy link
Copy Markdown
Author

Lxtharia commented May 1, 2025

Using the phys attribute somehow broke for me once, so this might not be the ultimate unique identifier.
Maybe using the vendorId + productId is a better option for the udev rule?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant