-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Replace pyUSB with pyhidapi #73
Comments
I tested a bit more on running on user level, since there is not only the usb we need to access. There is also the uinput device we need to create in order to send keyboard signals. Because of that I added the following to the rules file: This will allow for logged in user to access uinput. I needed to run following commands to reload the udev rules after adding them to /etc/udev/rules.d/60-g910-gkeys.rules to make it work: After this I could run Just wanted to document this knowledge somewhere. No updates on implementing pyhidapi yet. |
I am unsure what logged-in user means here (vs currently active). For example, we can have two users (let say How will uinput work in this case ? I mean, I am Alice@lorien:~$ pstree -cal
-lightdm
|-Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
| `-{Xorg}
|-Xorg -core :1 -seat seat0 -auth /var/run/lightdm/root/:1 -nolisten tcp vt8 -novtswitch
| `-{Xorg}
|-lightdm --session-child 14 21
| |-xfce4-session
| | |- [ Alice session programs ]
| | |- ...
| |-{lightdm}
| `-{lightdm}
|-lightdm --session-child 16 30
| |-xfce4-session
| | |- [ Bob session programs ]
| | |- ...
| |-{lightdm}
| `-{lightdm}
|-{lightdm}
`-{lightdm} The thing is that we should not mess with permissions, and have the correct keyboard input sent to the correct X server. I made the test: With my configuration, I wonder what See This link to understand what is a |
Maybe the topic is a not clear enough what the issue is really about. I also made some progress on testing what's the gkey mode all about. With the current rules applied to udev you can start the program with user privileges without permission problems (even detaching an re-attaching the kernel driver). I think this is a big step into the right direction. This is my current rules file:
I testing on some other keyboards, too. So they are also included here. I won't merge any of this into master if I not got a full working concept, so don't worry things getting messed up. I read the libusb documentation as well as the one from uinput and python-uinput. That's the recommended way of accessing it. Since we run on root privileges right now we didn't need to take action to access it. There are mainly two ways to access: The other option is to gain access with the file permissions on the stream.You can set All I am doing now is under the assumption the driver can be installed on a user level and is handled by systemd in that way, so we can fix the problems triggering commands not beeing logged in or not even on a tty. That's the reason why It's in the title. My idea right now is to allow a install on user level, because there is maybe someone not allowed for sudo wanting to use the driver and can't right now. Best would be to detect root privileges on install and just install user level service then. I have to read some more on this, but I think systemd will handle start/stop of the service if we install it with the right target. |
This is exactly the point I raised. I am unsure on how it will be handled when 2 users are logged-in on same Note: During a switch, there is no login (the user is already there, the active window is still the one which was active during last Bob' switch-out to Alice). My question was simply : What will be the owner and access right of your device after we switch from Alice to Bob ? And what will happen to Alice and Bob systemd user services (there are two of them, right ?) during a user switch ? I believe the system is designed to make proper switch (for example X is grabbing/releasing devices, if I understand, but I am not sure of that). In other words, I wonder if our "driver" will also have to do something (when we switch in/to or out/from a user), if the two services will be notified of some event, or if everything will be auto-magically handled. |
If there is no option in the service unit then there will be probably a systemwide signal we can listen to on a user switch. Just assuming... I will read into on demand. I feel like the discussion is more related to "Install User-Level-Service" and maybe #63, then to the implementation of pyhidapi, which wasn't intended. Thats why I'll remove the "Install User-Level-Service" part from the headline now. |
It is in indeed. The current I think that, if some device get user ownership and permission, this discussion is very important (in particular when two users want to run the same service). But if you separate the root ownership from the |
I tried adding a .rules file for the supported devices to run the program on user level and could get information from keyboard. But as soon as you want to detach the kernel module you get a permission denied. Without detaching it is not possible to read or write to the USB.
The only way to allow this would be to replace pyusb with pyhidapi.
This would be the next big upgrade to the driver and would fix #53, since it is related to detaching the kernel driver via pyusb.
I will update this post if I am gonna work on it.
The text was updated successfully, but these errors were encountered: