Arch package to run setxkbmap (or any other script) when you plug in your USB keyboard.
The code is adapted from:
Clone the repo and run
makepkg -i
Place a (executable) script under ~/.config/autoxkbmap
for example with the following content
#!/usr/bin/env bash
setxkbmap -layout us -variant altgr-intl -option
The script gets executed (if access is granted) every time a keyboard device is plugged in and found by udev.
The logic is as follows
- udev detects the keyboard
- udev asks systemd to start the service (
autoxkbmap.service
) which runs the script/usr/bin/autoxkbmap
- the service runs the script
/usr/bin/autoxkbmap
- the script iterates over the active X11 sessions
- for each X11 session the script
~/.config/autoxkbmap
is run as the user owning the session
Fell free to fork and create pull requests.