You are not logged in.
Pages: 1
Hello.
I write udev rule for keyboard connecting.
sudo cat /etc/udev/rules.d/99-keyboard.rules
ACTION=="add", SUBSYSTEM=="usb", DRIVERS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c328", RUN+="setxkbmap us,ru -option 'grp:alt_shift_toggle'"On debug i see that command failed with exit code 1.
journalctl -f | grep setxkbmap
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3: /etc/udev/rules.d/99-keyboard.rules:1 RUN 'setxkbmap us,ru -option 'grp:alt_shift_toggle''
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3: Running command "setxkbmap us,ru -option 'grp:alt_shift_toggle'"
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3: Starting 'setxkbmap us,ru -option 'grp:alt_shift_toggle''
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3: Process 'setxkbmap us,ru -option 'grp:alt_shift_toggle'' failed with exit code 1.
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3: Command "setxkbmap us,ru -option 'grp:alt_shift_toggle'" returned 1 (error), ignoring.
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3:1.0: /etc/udev/rules.d/99-keyboard.rules:1 RUN 'setxkbmap us,ru -option 'grp:alt_shift_toggle''
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3:1.0: Running command "setxkbmap us,ru -option 'grp:alt_shift_toggle'"
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3:1.0: Starting 'setxkbmap us,ru -option 'grp:alt_shift_toggle''
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3:1.0: Process 'setxkbmap us,ru -option 'grp:alt_shift_toggle'' failed with exit code 1.
дек 02 21:27:11 redmi (udev-worker)[67397]: 3-1.4.3.3:1.0: Command "setxkbmap us,ru -option 'grp:alt_shift_toggle'" returned 1 (error), ignoring.
дек 02 21:27:11 redmi (udev-worker)[67423]: 3-1.4.3.3:1.1: /etc/udev/rules.d/99-keyboard.rules:1 RUN 'setxkbmap us,ru -option 'grp:alt_shift_toggle''
дек 02 21:27:11 redmi (udev-worker)[67423]: 3-1.4.3.3:1.1: Running command "setxkbmap us,ru -option 'grp:alt_shift_toggle'"
дек 02 21:27:11 redmi (udev-worker)[67423]: 3-1.4.3.3:1.1: Starting 'setxkbmap us,ru -option 'grp:alt_shift_toggle''
дек 02 21:27:11 redmi (udev-worker)[67423]: 3-1.4.3.3:1.1: Process 'setxkbmap us,ru -option 'grp:alt_shift_toggle'' failed with exit code 1.
дек 02 21:27:11 redmi (udev-worker)[67423]: 3-1.4.3.3:1.1: Command "setxkbmap us,ru -option 'grp:alt_shift_toggle'" returned 1 (error), ignoring.The command are working correct in terminal, but doesn't work in udev. Why? I tried different variants of this command and no success.
Last edited by zakrush (2024-12-04 15:06:53)
Offline
The command needs to be run under your user and with the DISPLAY & XAUTHORITY variables correctly set.
See https://wiki.archlinux.org/title/Udev#T … _udev_rule for an example that might work for you with some tweaking.
Jin, Jîyan, Azadî
Offline
Or just don't.
Configure the keyboard properly, https://wiki.archlinux.org/title/Xorg/K … tion_files
You can match product and vendor, https://man.archlinux.org/man/xorg.conf.5#MatchProduct
Get the information from xinput.
Offline
Yes, seth's suggestion is definitely better ![]()
Jin, Jîyan, Azadî
Offline
The command needs to be run under your user and with the DISPLAY & XAUTHORITY variables correctly set.
See https://wiki.archlinux.org/title/Udev#T … _udev_rule for an example that might work for you with some tweaking.
So, I tried it.
#!/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/dm/.Xauthority
xauth add $DISPLAY . `xauth list $DISPLAY | awk '{print $3}'`
setxkbmap us,ru -option 'grp:alt_shift_toggle'And setup it as systemd
But I can't win privilege problems.
Configure the keyboard properly, https://wiki.archlinux.org/title/Xorg/K … tion_files
You can match product and vendor, https://man.archlinux.org/man/xorg.conf.5#MatchProduct
Get the information from xinput.
Ok. Thanks. I will try it.
Offline
Or just don't.
Configure the keyboard properly, https://wiki.archlinux.org/title/Xorg/K … tion_files
You can match product and vendor, https://man.archlinux.org/man/xorg.conf.5#MatchProduct
Get the information from xinput.
Thanks a lot. It's really help me.
Offline
Pages: 1