feat: replace pynput by evdev by rkmax · Pull Request #103 · streamdeck-linux-gui/streamdeck-linux-gui · GitHub
Skip to content

feat: replace pynput by evdev#103

Merged
coolapso merged 6 commits into
streamdeck-linux-gui:mainfrom
rkmax:feat-feature-keys
Dec 28, 2023
Merged

feat: replace pynput by evdev#103
coolapso merged 6 commits into
streamdeck-linux-gui:mainfrom
rkmax:feat-feature-keys

Conversation

@rkmax

@rkmax rkmax commented Oct 18, 2023

Copy link
Copy Markdown
Collaborator

Description of the changes

The pynput library is not well-supported by Wayland; therefore, it has been replaced with evdev, which appears to be a more robust option.

The keys field has been substituted by a text editor featuring real-time autocomplete functionality, as opposed to a fixed list.

In the event that an invalid key name is entered, a warning will be displayed in the system tray.

Demo

2023-10-18_07-29-24.mp4

@codecov

codecov Bot commented Oct 18, 2023

Copy link
Copy Markdown

@rkmax rkmax self-assigned this Oct 18, 2023
@coolapso

Copy link
Copy Markdown
Member

check the conflicts when you can please, most likely cause by merging the previous PR.

@rkmax rkmax force-pushed the feat-feature-keys branch from 207d3c4 to 7205728 Compare October 18, 2023 18:02
@rkmax rkmax requested a review from coolapso October 18, 2023 18:09
@Data-007

Copy link
Copy Markdown

@rkmax Something on Arch requiring tkinter or python-tk unsure. Think x11
See image below. More on discord.
image

@coolapso

Copy link
Copy Markdown
Member

This is a really HUGE change, not sure how to go about it, but I somewhat agree with as wayland starts to become the de-facto protocol.

I believe this might be a problem with installing the dependency. But well, gotta start somewhere.

For now, running with poetry from your branch:

**$poetry run streamdeck
Traceback (most recent call last):
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/xauth.py", line 43, in __init__
    raw = open(filename, 'rb').read()
          ^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/f0rs3ti/.Xauthority'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/f0rs3ti/temp/streamdeck-ui/streamdeck_ui/gui.py", line 46, in <module>
    from streamdeck_ui.modules.keyboard import KeyPressAutoComplete, keyboard_press_keys, keyboard_write
  File "/home/f0rs3ti/temp/streamdeck-ui/streamdeck_ui/modules/keyboard.py", line 3, in <module>
    import pyautogui
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/pyautogui/__init__.py", line 246, in <module>
    import mouseinfo
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/mouseinfo/__init__.py", line 223, in <module>
    _display = Display(os.environ['DISPLAY'])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/display.py", line 80, in __init__
    self.display = _BaseDisplay(display)
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/display.py", line 62, in __init__
    display.Display.__init__(*(self, ) + args, **keys)
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/protocol/display.py", line 60, in __init__
    auth_name, auth_data = connect.get_auth(self.socket,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/support/connect.py", line 91, in get_auth
    return mod.get_auth(sock, dname, host, dno)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/support/unix_connect.py", line 103, in new_get_auth
    au = xauth.Xauthority()
         ^^^^^^^^^^^^^^^^^^
  File "/home/f0rs3ti/.cache/pypoetry/virtualenvs/streamdeck-linux-gui-j3PZ8RXd-py3.11/lib/python3.11/site-packages/Xlib/xauth.py", line 45, in __init__
    raise error.XauthError('~/.Xauthority: %s' % err)
Xlib.error.XauthError: ~/.Xauthority: [Errno 2] No such file or directory: '/home/f0rs3ti/.Xauthority'
**

I don't have Xauthority at all because I don't use X at all and have no need to have any settings there. Dependency on this file should be removed.

@rkmax rkmax changed the title feat: replace pynput by pyautogui feat: replace pynput by evdev Oct 19, 2023
@rkmax rkmax force-pushed the feat-feature-keys branch from 291062e to 01c415e Compare October 19, 2023 04:39
@Data-007

Copy link
Copy Markdown

Been running up the latest push #103
Wayland no All media keys
X11 Yes All media keys

More Discord->#testing-and-pull-testing

@rkmax rkmax force-pushed the feat-feature-keys branch 2 times, most recently from efe1c7b to 6167755 Compare December 18, 2023 15:55
@rkmax rkmax changed the base branch from develop to main December 18, 2023 15:56
- add support for old mappings
- add autocomplete fields for keys
@rkmax rkmax force-pushed the feat-feature-keys branch from 6167755 to ccb6c39 Compare December 18, 2023 15:59
@rkmax

rkmax commented Dec 18, 2023

Copy link
Copy Markdown
Collaborator Author

@4s3ti I just retaking this. I cleanup the history. I give up for now regarding the wayland support. I did different experiments even writenn modules in C but when test on different version sometimes fails

let me know if you can merge this one

@coolapso

Copy link
Copy Markdown
Member

I am okay with merging this, but I am not so sure what is the best way to handle this ... this feels more backwards incompatible change 🤔 maybe should be marked as "BREAKING CHANGE" and made a major release?

@ajbucci

ajbucci commented Dec 18, 2023

Copy link
Copy Markdown
Member

I am okay with merging this, but I am not so sure what is the best way to handle this ... this feels more backwards incompatible change 🤔 maybe should be marked as "BREAKING CHANGE" and made a major release?

Does this break anything? At a glance, it looks like there is code to handle the old pynput keypress value mappings, so I don't think there are any breaking changes with respect to the config json.

I think a bigger concern is: can this approach be modified to work with wayland in the future, or is it a dead-end? If it can't be made to work, then it probably doesn't make sense to merge/implement. It looks like a way to handle emulated input events may be on the horizon in libei: https://gitlab.freedesktop.org/libinput/snegg

If pynput moves to implement a libei wrapper then it may make more sense to wait and continue using pynput. moses-palmer/pynput#331

Nevermind, I found a way to get it to work @rkmax

This issue explains what is going on: https://gitlab.gnome.org/GNOME/mutter/-/issues/1869

Here is the basic fix: ajbucci@0b9cdd9

I'm sure there is a better way to define _SUPPORTED_ECODES in my implementation

Here is a more complete implementation: 93d206c

@rkmax

rkmax commented Dec 18, 2023

Copy link
Copy Markdown
Collaborator Author

thanks @ajbucci for pointing a solution for wayland. I really appreciate.

@4s3ti regarding if is a breaking change. I dont think so... no functionality were touched more than the dependencies

but leave the PR open since I'll fixes mentioned by @ajbucci to see if that works correctly on ubuntu 22/23 as well like if I need to add addtiional checks/steps in the installations instructions

@coolapso

Copy link
Copy Markdown
Member

alright .. looks good to me then ... let me know when its okay to be merged then ... or .. rather ,, I think you now have the permissions for it as well @rkmax

@ajbucci

ajbucci commented Dec 18, 2023

Copy link
Copy Markdown
Member

@rkmax No problem!

I cleaned up the implementation here, which should be a better starting point: 93d206c

@rkmax

rkmax commented Dec 21, 2023

Copy link
Copy Markdown
Collaborator Author

I just include the logic to exclude the bad ecodes and include the permissions docs and scripts for installations

@coolapso

Copy link
Copy Markdown
Member

lgtm @rkmax is this ready for being merged?

@rkmax

rkmax commented Dec 27, 2023

Copy link
Copy Markdown
Collaborator Author

@coolapso coolapso merged commit 6424eae into streamdeck-linux-gui:main Dec 28, 2023
galastiaos pushed a commit to galastiaos/powerstreamdeck-linux-gui that referenced this pull request Nov 25, 2025
* replace pynput by evdev
* add support for old mappings
* add autocomplete fields for keys
* ignore vuln until upgrade
* remove bad ecodes
* Add uaccess tag for uinput kernel module in udev rules
* Add uinput rule to udev configuration
* Fix formatting in _initialize_uinput function
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.

4 participants