Skip to content
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

Add Wayland support and rework key finding #175

Closed
wants to merge 62 commits into from
Closed

Add Wayland support and rework key finding #175

wants to merge 62 commits into from

Conversation

ldrahnik
Copy link
Member

@ldrahnik ldrahnik commented Apr 2, 2024

No description provided.

@ldrahnik ldrahnik linked an issue Apr 2, 2024 that may be closed by this pull request
@ldrahnik ldrahnik requested a review from kamack38 April 2, 2024 14:52
@kamack38
Copy link
Member

kamack38 commented Apr 3, 2024

This doesn't work for me. I'm using Hyprland (you cannot use it in VM without a GPU pass through). Here's an error log:

2024-04-03 20:45:11,935 INFO     Detecting keyboard from string: "N: Name="AT Translated Set 2 keyboard""
2024-04-03 20:45:11,935 INFO     Set keyboard 5 from H: Handlers=sysrq kbd leds event5
2024-04-03 20:45:11,979 INFO     Detecting touchpad from string: "N: Name="ASUE1403:00 04F3:319A Touchpad""
2024-04-03 20:45:11,980 INFO     Set touchpad device id 0 from S: Sysfs=/devices/platform/AMDI0010:00/i2c-0/i2c-ASUE1403:00/0018:04F3:319A.000C/input/input38
2024-04-03 20:45:11,980 INFO     Set touchpad id 20 from H: Handlers=event20 mouse3
2024-04-03 20:45:11,980 INFO     Touchpad min-max: x 0-4036, y 0-2299
2024-04-03 20:45:11,980 INFO     Numpad min-max: x 200-3836, y 200-2219
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
2024-04-03 20:45:14,552 INFO     Touched top_right_icon area (numlock) in time: 1712169914.5525608
2024-04-03 20:45:15,555 INFO     The numpad numlock was pressed longer than the activation time and will be activated: 1.002497673034668
2024-04-03 20:45:15,555 INFO     Activation time: 1.0
2024-04-03 20:45:15,583 INFO     System numlock activated
2024-04-03 20:45:15,583 INFO     Numpad activated
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-03 20:45:15,599 INFO     Setting up for config file key: "enabled" with value: "True"
2024-04-03 20:45:15,599 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-03 20:45:15,816 INFO     Un-touched top_right_icon area (representing numlock key) in time: 1712169915.816633

(process:190957): dconf-WARNING **: 20:45:18.452: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=26e9782468234fa38200de7a43ad1434 --binary-syntax --close-stderr”: Child process exited with code 1
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-03 20:45:18,455 INFO     Setting up for config file key: "enabled" with value: "False"
2024-04-03 20:45:18,455 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-03 20:45:18,555 INFO     Numpad deactivated
2024-04-03 20:45:19,908 INFO     Touched top_right_icon area (numlock) in time: 1712169919.9087756
2024-04-03 20:45:20,912 INFO     The numpad numlock was pressed longer than the activation time and will be activated: 1.0034966468811035
2024-04-03 20:45:20,912 INFO     Activation time: 1.0
2024-04-03 20:45:20,956 INFO     System numlock activated
2024-04-03 20:45:20,956 INFO     Numpad activated

(process:190999): dconf-WARNING **: 20:45:20.970: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=26e9782468234fa38200de7a43ad1434 --binary-syntax --close-stderr”: Child process exited with code 1
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-03 20:45:20,973 INFO     Setting up for config file key: "enabled" with value: "True"
2024-04-03 20:45:20,974 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-03 20:45:21,252 INFO     Setting up for config file key: "enabled" with value: "False"
2024-04-03 20:45:21,252 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-03 20:45:21,352 INFO     Numpad deactivated
2024-04-03 20:45:21,738 INFO     Touched top_right_icon area (numlock) in time: 1712169921.738391
2024-04-03 20:45:22,742 INFO     The numpad numlock was pressed longer than the activation time and will be activated: 1.0039167404174805
2024-04-03 20:45:22,742 INFO     Activation time: 1.0
2024-04-03 20:45:22,783 INFO     System numlock activated
2024-04-03 20:45:22,783 INFO     Numpad activated

(process:191036): dconf-WARNING **: 20:45:22.795: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=26e9782468234fa38200de7a43ad1434 --binary-syntax --close-stderr”: Child process exited with code 1
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-03 20:45:22,798 INFO     Setting up for config file key: "enabled" with value: "True"
2024-04-03 20:45:22,799 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-03 20:45:23,038 INFO     Un-touched top_right_icon area (representing numlock key) in time: 1712169923.0385675
2024-04-03 20:45:23,857 INFO     Pressed numpad key
2024-04-03 20:45:23,857 INFO     KEY_KP9:73
2024-04-03 20:45:23,857 INFO     Unpressed numpad key
2024-04-03 20:45:23,857 INFO     KEY_KP9:73
2024-04-03 20:45:24,029 INFO     Pressed numpad key
2024-04-03 20:45:24,029 INFO     KEY_KP9:73
2024-04-03 20:45:24,029 INFO     Unpressed numpad key
2024-04-03 20:45:24,029 INFO     KEY_KP9:73
2024-04-03 20:45:24,187 INFO     Pressed numpad key
2024-04-03 20:45:24,187 INFO     KEY_KP9:73
2024-04-03 20:45:24,187 INFO     Unpressed numpad key
2024-04-03 20:45:24,187 INFO     KEY_KP9:73
2024-04-03 20:45:24,339 INFO     Pressed numpad key
2024-04-03 20:45:24,339 INFO     KEY_KP9:73
2024-04-03 20:45:24,339 INFO     Unpressed numpad key
2024-04-03 20:45:24,339 INFO     KEY_KP9:73
2024-04-03 20:45:24,483 INFO     Pressed numpad key
2024-04-03 20:45:24,483 INFO     KEY_KP9:73
2024-04-03 20:45:24,483 INFO     Unpressed numpad key
2024-04-03 20:45:24,483 INFO     KEY_KP9:73
2024-04-03 20:45:24,614 INFO     Pressed numpad key
2024-04-03 20:45:24,614 INFO     KEY_KP9:73
2024-04-03 20:45:24,614 INFO     Unpressed numpad key
2024-04-03 20:45:24,614 INFO     KEY_KP9:73
2024-04-03 20:45:24,758 INFO     Pressed numpad key
2024-04-03 20:45:24,758 INFO     KEY_KP9:73
2024-04-03 20:45:24,759 INFO     Unpressed numpad key
2024-04-03 20:45:24,759 INFO     KEY_KP9:73
2024-04-03 20:45:25,963 INFO     Pressed numpad key
2024-04-03 20:45:25,963 INFO     KEY_KP9:73
2024-04-03 20:45:25,963 INFO     Unpressed numpad key
2024-04-03 20:45:25,963 INFO     KEY_KP9:73
2024-04-03 20:45:26,128 INFO     Pressed numpad key
2024-04-03 20:45:26,128 INFO     KEY_KP9:73
2024-04-03 20:45:26,128 INFO     Unpressed numpad key
2024-04-03 20:45:26,128 INFO     KEY_KP9:73
2024-04-03 20:45:26,279 INFO     Pressed numpad key
2024-04-03 20:45:26,279 INFO     KEY_KP9:73
2024-04-03 20:45:26,279 INFO     Unpressed numpad key
2024-04-03 20:45:26,279 INFO     KEY_KP9:73
2024-04-03 20:45:26,431 INFO     Pressed numpad key
2024-04-03 20:45:26,431 INFO     KEY_KP9:73
2024-04-03 20:45:26,431 INFO     Unpressed numpad key
2024-04-03 20:45:26,431 INFO     KEY_KP9:73
2024-04-03 20:45:26,596 INFO     Pressed numpad key
2024-04-03 20:45:26,596 INFO     KEY_KP9:73
2024-04-03 20:45:26,597 INFO     Unpressed numpad key
2024-04-03 20:45:26,597 INFO     KEY_KP9:73
2024-04-03 20:45:26,747 INFO     Pressed numpad key
2024-04-03 20:45:26,747 INFO     KEY_KP9:73
2024-04-03 20:45:26,747 INFO     Unpressed numpad key
2024-04-03 20:45:26,747 INFO     KEY_KP9:73
2024-04-03 20:45:26,892 INFO     Pressed numpad key
2024-04-03 20:45:26,892 INFO     KEY_KP9:73
2024-04-03 20:45:26,892 INFO     Unpressed numpad key
2024-04-03 20:45:26,892 INFO     KEY_KP9:73
2024-04-03 20:45:27,050 INFO     Pressed numpad key
2024-04-03 20:45:27,050 INFO     KEY_KP9:73
2024-04-03 20:45:27,050 INFO     Unpressed numpad key
2024-04-03 20:45:27,050 INFO     KEY_KP9:73
2024-04-03 20:45:27,208 INFO     Pressed numpad key
2024-04-03 20:45:27,208 INFO     KEY_KP9:73
2024-04-03 20:45:27,208 INFO     Unpressed numpad key
2024-04-03 20:45:27,208 INFO     KEY_KP9:73
2024-04-03 20:45:27,373 INFO     Pressed numpad key
2024-04-03 20:45:27,373 INFO     KEY_KP9:73
2024-04-03 20:45:27,373 INFO     Unpressed numpad key
2024-04-03 20:45:27,374 INFO     KEY_KP9:73
2024-04-03 20:45:27,539 INFO     Pressed numpad key
2024-04-03 20:45:27,539 INFO     KEY_KP9:73
2024-04-03 20:45:27,539 INFO     Unpressed numpad key
2024-04-03 20:45:27,539 INFO     KEY_KP9:73
2024-04-03 20:45:27,690 INFO     Pressed numpad key
2024-04-03 20:45:27,690 INFO     KEY_KP9:73
2024-04-03 20:45:27,690 INFO     Unpressed numpad key
2024-04-03 20:45:27,690 INFO     KEY_KP9:73
2024-04-03 20:45:27,855 INFO     Pressed numpad key
2024-04-03 20:45:27,855 INFO     KEY_KP9:73
2024-04-03 20:45:27,855 INFO     Unpressed numpad key
2024-04-03 20:45:27,855 INFO     KEY_KP9:73
2024-04-03 20:45:28,027 INFO     Pressed numpad key
2024-04-03 20:45:28,027 INFO     KEY_KP9:73
2024-04-03 20:45:28,027 INFO     Unpressed numpad key
2024-04-03 20:45:28,027 INFO     KEY_KP9:73
2024-04-03 20:45:28,199 INFO     Pressed numpad key
2024-04-03 20:45:28,199 INFO     KEY_KP9:73
2024-04-03 20:45:28,199 INFO     Unpressed numpad key
2024-04-03 20:45:28,199 INFO     KEY_KP9:73
2024-04-03 20:45:28,351 INFO     Pressed numpad key
2024-04-03 20:45:28,351 INFO     KEY_KP9:73
2024-04-03 20:45:28,351 INFO     Unpressed numpad key
2024-04-03 20:45:28,351 INFO     KEY_KP9:73
2024-04-03 20:45:28,536 INFO     Pressed numpad key
2024-04-03 20:45:28,537 INFO     KEY_KP9:73
2024-04-03 20:45:28,537 INFO     Unpressed numpad key
2024-04-03 20:45:28,537 INFO     KEY_KP9:73
2024-04-03 20:45:30,615 INFO     Touched top_right_icon area (numlock) in time: 1712169930.6156218
2024-04-03 20:45:31,620 INFO     The numpad numlock was pressed longer than the activation time and will be activated: 1.0045819282531738
2024-04-03 20:45:31,620 INFO     Activation time: 1.0
2024-04-03 20:45:31,653 INFO     System numlock deactivated
2024-04-03 20:45:31,653 INFO     Numpad deactivated

(process:191235): dconf-WARNING **: 20:45:31.667: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=26e9782468234fa38200de7a43ad1434 --binary-syntax --close-stderr”: Child process exited with code 1
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-03 20:45:31,670 INFO     Setting up for config file key: "enabled" with value: "False"
2024-04-03 20:45:31,670 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-03 20:45:31,888 INFO     Un-touched top_right_icon area (representing numlock key) in time: 1712169931.888838

There seem to be two issues:

  1. Using a special key on my mouse (bound to Ctrl+t) seem to disable the numpad
  2. Buttons on numpad doesn't work correctly pressing 9 one time inputs it, but any other click inputs 9 and then instantly deletes it

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 3, 2024

@kamack38 What about changing keyboard layout using super + space or another shortcut? Does it works? You can test it like I did French BEPO keyboard layout + EN keyboard layout and test whether works character % in both cases.

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 3, 2024

error: XDG_RUNTIME_DIR is invalid or not set in the environment.

@kamack38 This environment variable Is not set why, do you know?

This environment variable is in fact set which is why this error is strange.

@kamack38
Copy link
Member

kamack38 commented Apr 3, 2024

@kamack38 What about changing keyboard layout using super + space or another shortcut? Does it works? You can test it like I did French BEPO keyboard layout + EN keyboard layout and test whether works character % in both cases.

Super+space doesn't change the keyboard layout on Wayland which is why we shouldn't rely on shortcuts to do such things. It would be better if we find a way to do this programmatically

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 3, 2024

@kamack38

Super+space doesn't change the keyboard layout on Wayland which is why we shouldn't rely on shortcuts to do such things.

You write that like it is a known thing. Can you send me a link to doc or something why? Because when I change the layout in settings (I do not know what is different between changing the layout in the settings and in the top menu, it sounds to me like the distro top menu is (I tested only Ubuntu 22.04) not wayland ready more than it is not sent on purpose) then I receive event active keyboard has been changed to EN or to FR BEPO.

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 3, 2024

@kamack38

@kamack38 This environment variable Is not set why, do you know?

This environment variable is in fact set which is why this error is strange.

I know why, propagation of this variable from system environment to the systemctl service environment is was missing.

EDIT: commited

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 4, 2024

@kamack38 Could you please test that again with fix

@kamack38
Copy link
Member

kamack38 commented Apr 4, 2024

Issues I'm currently facing:

  1. Pressing any key on a device (keyboard, mouse) disables the numpad
  2. Numpad keys work well inside terminal, but clicking keys quickly (around 1-2s time difference between presses) doesn't work in Firefox (the new key is inputted and then instantly deleted).
  3. I still get an error error: XDG_RUNTIME_DIR is invalid or not set in the environment.. I'm not using the service file, but I'm running it from the comandline instead. (XDG_RUNTIME_DIR=/run/user/1000)
  4. I have rebounded Meta/Super + Space, so the layout switching using this key won't work for me.

@kamack38
Copy link
Member

kamack38 commented Apr 4, 2024

Anyway, could you please test if the sudo dumpkeys command reflects the current layout on your system (when you switch between layouts), if so this would allow getting the key that inputs for example "6".

EDIT:
I think the best solution is to find keysym in the current layout table and derive the keycode or scancode from it on start, and then send the correct key using evdev.

@kamack38
Copy link
Member

kamack38 commented Apr 4, 2024

The sudo dumpkeys doesn't reflect the current desktop layout

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 4, 2024

@kamack38

EDIT:
I think the best solution is to find keysym in the current layout table and derive the keycode or scancode from it on start, and then send the correct key using evdev.

Agree, thank you for mentioning that, now should be committed that keymap is created at driver start and keys are enabled and the same happens every time when is delivered new keymap.

Numpad keys work well inside terminal, but clicking keys quickly (around 1-2s time difference between presses) doesn't work in Firefox (the new key is inputted and then instantly deleted).

What was already committed - more above - should I hope fix this.

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 4, 2024

@kamack38

Pressing any key on a device (keyboard, mouse) disables the numpad

Is disabled because of an error inside the code? Can you please post here an error?

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 4, 2024

@kamack38

I still get an error error: XDG_RUNTIME_DIR is invalid or not set in the environment.

Do you get this error only using service or even when you directly run python code?

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 4, 2024

@kamack38 Please try to bind to something else and press and look whether was handler called. To do that start driver code using VSCode and put breakpoint here wl_keyboard_keymap_handler. Or just check keys are printed well using another layout changed in settings - primary keyboard layout should trigger handler or using that shortcut.

@kamack38
Copy link
Member

kamack38 commented Apr 5, 2024

@kamack38

I still get an error error: XDG_RUNTIME_DIR is invalid or not set in the environment.

Do you get this error only using service or even when you directly run python code?

When I run the code directly.

@kamack38
Copy link
Member

kamack38 commented Apr 5, 2024

@kamack38

Pressing any key on a device (keyboard, mouse) disables the numpad

Is disabled because of an error inside the code? Can you please post here an error?

2024-04-05 17:03:43,094 INFO     Setting up for config file key: "enabled" with value: "True"
2024-04-05 17:03:43,095 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-05 17:03:43,357 INFO     Un-touched top_left_icon area in time: 1712329423.3570955

(process:80374): dconf-WARNING **: 17:03:45.987: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=26e9782468234fa38200de7a43ad1434 --binary-syntax --close-stderr”: Child process exited with code 1
Authorization required, but no authorization protocol specified

Unable to connect to X server
2024-04-05 17:03:45,990 INFO     Setting up for config file key: "enabled" with value: "False"
2024-04-05 17:03:45,991 INFO     check_config_values_changes: detected internal change of config file -> do nothing -> would be deadlock
<Event dir=False mask=0x8 maskname=IN_CLOSE_WRITE name=numberpad_dev path=/home/kamack38/Documents/GitHUB/asus-numberpad-driver pathname=/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad_dev wd=1 >
2024-04-05 17:03:46,091 INFO     Numpad deactivated

@kamack38
Copy link
Member

kamack38 commented Apr 5, 2024

On the first run I also get this:

Exception in thread Thread-5 (load_keycodes_for_ascii_chars_for_wayland):
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad.py", line 148, in load_keycodes_for_ascii_chars_for_wayland
    wayland_display.connect()
  File "/usr/lib/python3.11/site-packages/pywayland/client/display.py", line 131, in connect
    raise ValueError("Unable to connect to display")
ValueError: Unable to connect to display

@kamack38
Copy link
Member

kamack38 commented Apr 5, 2024

I was told that using libxkbcommon one can get a keysym corresponding to the keycode, but I'm using the python library and I can't get it to work (changing layouts doesn't change the keysym produced).

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 5, 2024

@kamack38 Can you post here link to .iso of your distro? I will try run that inside virtual box too, only what Is missing inside virtual box I guess and I have had no time yet discovery if Is possible Is how share I2C devices with virtual box instances. I have never tried Hyprland. But that error Is weird, it has to be something stupid because it Is required environment variable for Wayland and you have that variable even set up like you said.

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 24, 2024

Problem with activation NumberPad without loaded keymap yet thought wayland I solved by predefining Num_Lock (might help with previous issue if it was this case):

    # is predefined for the situation when is used wayland and in config is written enabled=true so Num_Lock will be send before is loaded from current keymap
    'Num_Lock': 'Num_Lock',

README.md Show resolved Hide resolved
install_layout_select.sh Outdated Show resolved Hide resolved
@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 25, 2024

@kamack38

The last missing implementation which I register for completion:

TODO:

- implementation of dynamic finding keycodes of modifiers for wayland using the workaround mentioned here (Implemented)

Do I miss something?

@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 27, 2024

@kamack38 I have implemented dynamic findings for modifiers obtained thought Wayland with the workaround mentioned here and now I do not know about any problems so I request again branch to review. I found and fixed a few essential bugs so I think it is on the right way to be merged soon. Thank you!

@ldrahnik ldrahnik marked this pull request as ready for review April 27, 2024 10:56
@ldrahnik ldrahnik requested a review from kamack38 April 29, 2024 07:27
@kamack38
Copy link
Member

For gnome when was used shortcut for changing layouts was not called something like setxkbmap (libxkbcommon) so new keymap was not delivered but was changed org.gnome.desktop.input-sources.current (deprecated), respectively for the new distros under gnome org.gnome.desktop.input-sources.mru-sources (most recently used source) which can be in both cases found here org.gnome.desktop.input-sources.sources. So I implemented calling setxkbmap', layout, '-display', display_var when are changed these dconf values. For both wayland even x11. So if I will simplify this dconf settings is prioritized under gnome over using setxkbmap but setxkbmap (libxkbcommon) for example is used when is changed layout order in settings.

I have a little trouble understanding you here. Does this mean that changing the keyboard layout inside Gnome does not actually change the layout reported by libxkbcommon? If so, I would count it as a Gnome bug.

@kamack38
Copy link
Member

@ldrahnik Have You tested the newest version, because I'm getting the following error using pyinotify 0.9.6:

Traceback (most recent call last):
  File "/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad.py", line 16, in <module>
    from pyinotify import WatchManager, IN_CLOSE_WRITE, IN_IGNORED, IN_MOVED_TO, AsyncNotifier
ImportError: cannot import name 'AsyncNotifier' from 'pyinotify' (/usr/lib/python3.12/site-packages/pyinotify.py). Did you mean: 'AsyncioNotifier'?

@kamack38 kamack38 changed the title WIP Add Wayland support and rework key finding Apr 29, 2024
@ldrahnik
Copy link
Member Author

ldrahnik commented Apr 30, 2024

@ldrahnik Have you tested the newest version, I'm getting the following error using pyinotify 0.9.6:

Traceback (most recent call last):
  File "/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad.py", line 16, in <module>
    from pyinotify import WatchManager, IN_CLOSE_WRITE, IN_IGNORED, IN_MOVED_TO, AsyncNotifier
ImportError: cannot import name 'AsyncNotifier' from 'pyinotify' (/usr/lib/python3.12/site-packages/pyinotify.py). Did > you mean: 'AsyncioNotifier'?

Which version of Python do you use? (3.12 I see in file path but more concretely?). Probably related because I am fine with installation / use on each station (e.g. with Python version 3.10.12)

@ldrahnik
Copy link
Member Author

ldrahnik commented May 1, 2024

For gnome when was used shortcut for changing layouts was not called something like setxkbmap (libxkbcommon) so new keymap was not delivered but was changed org.gnome.desktop.input-sources.current (deprecated), respectively for the new distros under gnome org.gnome.desktop.input-sources.mru-sources (most recently used source) which can be in both cases found here org.gnome.desktop.input-sources.sources. So I implemented calling setxkbmap', layout, '-display', display_var when are changed these dconf values. For both wayland even x11. So if I will simplify this dconf settings is prioritized under gnome over using setxkbmap but setxkbmap (libxkbcommon) for example is used when is changed layout order in settings.

I have a little trouble understanding you here. Does this mean that changing the keyboard layout inside Gnome does not actually change the layout reported by libxkbcommon? If so, I would count it as a Gnome bug.

I think the same but I did not search for opened issues. Anyway, I had two options, force to users of NumberPad to overbind shortcut for changing keyboard e.g. Super+Space with own script to use setxkbmap which would fix that and than would be sent new keymap thought wayland or implement the same directly to the code of NumberPad what I did.

@ldrahnik
Copy link
Member Author

ldrahnik commented May 2, 2024

@ldrahnik Have you tested the newest version, I'm getting the following error using pyinotify 0.9.6:

Traceback (most recent call last):
  File "/home/kamack38/Documents/GitHUB/asus-numberpad-driver/numberpad.py", line 16, in <module>
    from pyinotify import WatchManager, IN_CLOSE_WRITE, IN_IGNORED, IN_MOVED_TO, AsyncNotifier
ImportError: cannot import name 'AsyncNotifier' from 'pyinotify' (/usr/lib/python3.12/site-packages/pyinotify.py). Did > you mean: 'AsyncioNotifier'?

Please create separated issue in case it affects the master branch.

@ldrahnik
Copy link
Member Author

ldrahnik commented May 2, 2024

@kamack38 Merged. Thank you for reviewing. You had a lot of useful points.

@ldrahnik ldrahnik closed this May 2, 2024
@ldrahnik ldrahnik deleted the wayland branch May 2, 2024 22:33
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.

[Bug, Feature request] Wayland support
2 participants