Udev: cmd executado ao conectar o dispositivo, mas não faz nada

1

Eu criei regras que devem executar um comando quando eu conecto meu mouse USB para desativar o touchpad e o ponto de apoio:

machine ~ # cat /etc/udev/rules.d/61-touchpad.rules 
# 61-touchpad.rules
# disable PS/2 touchpad on DISPLAY :0 if a mouse is added to the system
ACTION=="add", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'"

# enable PS/2 touchpad on DISPLAY :0 if a mouse is removed from the system
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --enable 'AlpsPS/2 ALPS GlidePoint'"

# disable Point Stick on DISPLAY :0 if a mouse is added to the system
ACTION=="add", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --disable 'DualPoint Stick'"

# enable Point Stick on DISPLAY :0 if a mouse is removed from the system
ACTION=="remove", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", ENV{ID_BUS}=="usb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/user/.Xauthority", RUN+="/usr/bin/xinput --enable 'DualPoint Stick'"

machine ~ #

Quando executo o comando como root a partir de um shell, configurando DISPLAY e XAUTHORITY antes, o touch pad e o ponto de apoio são ativados / desativados de acordo quando eu removo / reconecto o mouse USB.

Quando eu uso udevadm test --action=add /sys/class/input/mouse0 para testar as regras, o udev grava muitas informações, entre elas escreve que ele executa os comandos com o ambiente apropriado:

LINK 'input/by-path/pci-0000:00:14.0-usb-0:6:1.0-mouse' /lib/udev/rules.d/60-persistent-input.rules:32
RUN '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'' /etc/udev/rules.d/61-touchpad.rules:20
RUN '/usr/bin/xinput --disable 'DualPoint Stick'' /etc/udev/rules.d/61-touchpad.rules:26
device 0x7f0315c20320 filled with db file data
...
ACTION=add
DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Optical_Mouse-mouse /dev/input/by-path/pci-0000:00:14.0-usb-0:6:1.0-mouse
DEVNAME=/dev/input/mouse0
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-6/3-6:1.0/0003:046D:C077.002A/input/input63/mouse0
DISPLAY=:0.0
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Optical_Mouse
...
MAJOR=13
MINOR=32
SUBSYSTEM=input
UDEV_LOG=7
USEC_INITIALIZED=8190049649
XAUTHORITY=/home/user/.Xauthority
run: '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint''
run: '/usr/bin/xinput --disable 'DualPoint Stick''
...

Quando executo udevd --debug e removo / reconecto o mouse USB, recebo muitas informações sobre o que está acontecendo:

starting '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint''
starting '/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint''
'/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'' [27714] exit with return code 0
'/usr/bin/xinput --disable 'AlpsPS/2 ALPS GlidePoint'' [27715] exit with return code 0
starting '/usr/bin/xinput --disable 'DualPoint Stick''
starting '/usr/bin/xinput --disable 'DualPoint Stick''
'/usr/bin/xinput --disable 'DualPoint Stick'' [27719] exit with return code 0

Tudo parece legal ... o único problema é que o touchpad e o ponto de apoio não estão desativados quando eu conecto o mouse USB.

Eu senti falta de algo?

    
por Joysn 12.03.2016 / 02:03

0 respostas

Tags