pynput-keylistener #2

Open
mleone607 wants to merge 10 commits from mleone607/FW_LED_System_Monitor:pynput-keylistener into main
Collaborator

Key listener is now implemented with pynput. I resolved the issue with X-server not working when run as service under root with a few changes to run.sh and install_as_service

I believe pynput is the best option. I think it's supported on Windows. Let me know if there are any issues running it there.

Other options I considered all had show-stopping drawbacks. See this SO post for a discussion of them. Many of the commenters were looking to NOT hook the keyboard globally (i.e. they wanted to detect key presses on the command line that was running the app). We have the opposite need, and that became a discriminator for some of the options.

Here are the main ones I tried:

  • evdev: No Windows support. Causes keyboard reboot with rapid typing in Linux
  • sshkeyboard: Does not support multiple keypresses (will consider one released when the other is pressed) and does not read ctrl, alt, etc
  • keyboard: Requires root access just to call the library, regardless of permissions on keyboard device. Does not hook keyboard globally.

This branch is rebased on the temp_fan_plugin branch that the other PR was made from, so I closed it.

Key listener is now implemented with pynput. I resolved the issue with X-server not working when run as service under root with a few changes to run.sh and install_as_service I believe pynput is the best option. I think it's supported on Windows. Let me know if there are any issues running it there. Other options I considered all had show-stopping drawbacks. See [this SO post](https://stackoverflow.com/questions/24072790/how-to-detect-key-presses) for a discussion of them. Many of the commenters were looking to NOT hook the keyboard globally (i.e. they wanted to detect key presses on the command line that was running the app). We have the opposite need, and that became a discriminator for some of the options. Here are the main ones I tried: - evdev: No Windows support. Causes keyboard reboot with rapid typing in Linux - sshkeyboard: Does not support multiple keypresses (will consider one released when the other is pressed) and does not read ctrl, alt, etc - keyboard: Requires root access just to call the library, regardless of permissions on keyboard device. Does not hook keyboard globally. This branch is rebased on the temp_fan_plugin branch that the other PR was made from, so I closed it.
mleone607 added 10 commits 2025-07-12 22:44:12 -05:00
Author
Collaborator

A couple things I discovered when investigating making the X-Server connection work as root turned out not to be needed. But I wanted to mention them in case you find them necessary.

  1. Add this line to sudoers to ensure X settings persist: Defaults env_keep="DISPLAY XAUTHORITY"
  2. Add this line under the [Service] section in the service descriptor: Environment=/path/to/.Xauthority
A couple things I discovered when investigating making the X-Server connection work as root turned out not to be needed. But I wanted to mention them in case you find them necessary. 1. Add this line to sudoers to ensure X settings persist: Defaults env_keep="DISPLAY XAUTHORITY" 2. Add this line under the [Service] section in the service descriptor: Environment=/path/to/.Xauthority
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u pynput-keylistener:mleone607-pynput-keylistener
git checkout mleone607-pynput-keylistener

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git checkout main
git merge --no-ff mleone607-pynput-keylistener
git checkout mleone607-pynput-keylistener
git rebase main
git checkout main
git merge --ff-only mleone607-pynput-keylistener
git checkout mleone607-pynput-keylistener
git rebase main
git checkout main
git merge --no-ff mleone607-pynput-keylistener
git checkout main
git merge --squash mleone607-pynput-keylistener
git checkout main
git merge --ff-only mleone607-pynput-keylistener
git checkout main
git merge mleone607-pynput-keylistener
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: jeremy/FW_LED_System_Monitor#2
No description provided.