sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.8k stars 156 forks source link

xmodmap on wayland #114

Open hsantanna opened 3 years ago

hsantanna commented 3 years ago

~/.Xmodmap haves no effect on Wayland, but it will interfere on key-mapper-gtk while changing the mapping on Wayland.

key-mapper-gtk will grab the key as set with ~/.Xmodmap even if running on Wayland.

  1. key-mapper-control --version: key-mapper 1.0.0 84549b26244ea14bf551a37ff9e4088f99305f6b https://github.com/sezanzeb/key-mapper python-evdev 1.4.0
  2. Arch Linux
  3. echo $XDG_SESSION_TYPE: wayland
  4. KDE Plasma (Wayland session) 5.21.5
  5. sudo ls -l /proc/1/exe: lrwxrwxrwx 1 root root 0 mai 26 16:58 /proc/1/exe -> /usr/lib/systemd/systemd
sezanzeb commented 3 years ago

the keys are taken from xmodmap -pke, which works with gnome on wayland. i.e. if I change the keyboard layout using gnomes menu, I get a different output for the command as expected.

if you change your keyboard layout in plasma, does the command also return the changed layout? for example, change it from qwertz to qwerty and see if the z changes, like:

# xmodmap -pke | grep z
# qwertz
keycode  29 = z Z y Y leftarrow yen
keycode  52 = y Y z Z guillemotright U203A

# xmodmap -pke | grep z
# qwerty
keycode  29 = y Y z Z leftarrow yen y Y
keycode  52 = z Z y Y guillemotright U203A z Z

if yes, then there is "only" an issue with the ~/.Xmodmap file, if not, then keymapper doesn't work on plasma as expected at all which would be the worst case.

If it doesn't work at all, a way must be found to acquire the session-side keyboard layout mappings for a plasma wayland session

sezanzeb commented 3 years ago

It seems that switching language via gnomes settings only makes the xmodmap -pke output different as long as I didn't change it manually via xmodmap filename for me. I couldn't reproduce the behavior I mentioned in my previous comment anymore afterwards, basically breaking key-mapper in the same way you are reporting.

since in wayland the desktop environment has to take care about keyboard layouts as far as I remember, the normal xkb and xmodmap stuff won't work anymore. So that file doesn't serve any purpose and only makes the xmodmap -pke output not match the actual environments layout anymore.

If xmodmap -pke doesn't reflect the actual layout at all in KDE, then I guess we will have to request a feature/tool like that from KDE to keep this working.

hsantanna commented 3 years ago

Yes, changing layout on KDE Plasma System Settings will affect xmodmap -pke, but that is because the settings will be changed on multiple layers, Wayland and X11.

I don't understand how it is done on Wayland side, but to X11 if I do:

setxkbmap xkb_layout xkb_variant

It will only affect X11 aplications, but not Wayland applications.

E.g. Konsole will still be on the same layout set by Plasma System Settings, but xterm will change to use keys as set by setxkbmap.

key-mapper seems to work all good on Wayland doing its mapping, but I think key-mapper-gtk should not be affected by xmodmap if it runs as a Wayland application, because in that case X keyboard maps should be set only for the compatibility layer with Xwayland apps.

As a workaround I disabled all my ~/.Xmodmap mapping and recreated them as key-mapper mappings, despite that I don't know how or if I can make NumLock affect key-mapper mappings.

sezanzeb commented 3 years ago

but I think key-mapper-gtk should not be affected by xmodmap if it runs as a Wayland application

I agree. As long as there is no alternative way to get the actual system mapping as stored in kde plasma (maybe via configuration files?) it will stay like that though

LunNova commented 2 years ago

Would this behaviour be an improvement?

XDG_SESSION_TYPE: X11
 - Use Xmodmap
XDG_SESSION_TYPE: wayland XDG_CURRENT_DESKTOP: KDE or GNOME
 - Use Xmodmap
XDG_SESSION_TYPE: wayland XDG_CURRENT_DESKTOP: any other value
 - Ignore Xmodmap

As far as I know any wayland setup other than gnome or KDE won't be using Xmodmap to store these.

sezanzeb commented 2 years ago

What about cinnamon which is based on gnome?

sezanzeb commented 1 year ago

in plasma, changing the keyboard layout in wayland correctly affects the xmodmap -pke output