Estou tentando automatizar uma calibração de tablets Huion sem muito sucesso.
Eu tenho esta saída de xinput --list
em um terminal normal:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ USB USB Keyboard id=13 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=14 [slave pointer (2)]
⎜ ↳ HUION PenTablet id=18 [slave pointer (2)]
⎜ ↳ HUION PenTablet id=19 [slave pointer (2)]
⎜ ↳ HUION PenTablet id=20 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Video Bus id=8 [slave keyboard (3)]
↳ Power Button id=9 [slave keyboard (3)]
↳ Sleep Button id=10 [slave keyboard (3)]
↳ Laptop_Integrated_Webcam_2HDM id=11 [slave keyboard (3)]
↳ USB USB Keyboard id=12 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=15 [slave keyboard (3)]
↳ Dell WMI hotkeys id=17 [slave keyboard (3)]
O log do udev exibe apenas isto para o mesmo comando:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ USB USB Keyboard id=13 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=14 [slave pointer (2)]
⎜ ↳ HUION PenTablet id=18 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Video Bus id=8 [slave keyboard (3)]
↳ Power Button id=9 [slave keyboard (3)]
↳ Sleep Button id=10 [slave keyboard (3)]
↳Laptop_Integrated_Webcam_2HDM id=11 [slave keyboard (3)]
↳ USB USB Keyboard id=12 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=15 [slave keyboard (3)]
↳ Dell WMI hotkeys id=17 [slave keyboard (3)]
Observe que as linhas de id=19
e id=20
estão faltando.
Eu tenho:
/etc/udev/rules.d/huion.rules
:
ATTRS{idVendor}=="256c", ATTRS{idProduct}=="006e", SYMLINK+="davesusb", ENV{DISPLAY}=":0.0", ENV{XAUTHORITY}="/home/romulo/.Xauthority", RUN+="/usr/local/Huion"
/usr/local/Huion
:
#!/bin/bash
/home/romulo/.local/Huion &
~/.local/Huion
:
#!/bin/bash
sleep 3
DISPLAY=":0.0"
HOME=/home/romulo/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
if (xrandr | grep "HDMI1 connected" > /dev/null)
then
LENGTH=$(/usr/bin/xrandr | grep 'HDMI1 connected primary' | uniq | awk '{x=$4; split(x,a,"+"); split(a[1],b,"x"); print b[1]}')
WIDTH=$(/usr/bin/xrandr | grep 'HDMI1 connected primary' | uniq | awk '{x=$4; split(x,a,"+"); split(a[1],b,"x"); print b[2]}')
DEVICE=$(/usr/bin/xinput --list | grep HUION | uniq | awk 'NR==2 {x=$5; split(x,a,"="); print a[2]}')
echo $(/usr/bin/xinput --list)
CORRECTION=$((40000*$WIDTH/$LENGTH))
echo "$CORRECTION"
if (glxinfo | grep "Intel" > /dev/null)
then
xsetwacom set $DEVICE MapToOutput HDMI1
echo "device $DEVICE restricted to HDMI-1"
xinput set-prop $DEVICE "Evdev Axis Calibration" 0 40000 0 $CORRECTION
echo "correction of proportion : 40000x$CORRECTION"
else
echo "error :("
fi
else
echo "error :("
fi
O script faz xinput --list | grep HUION | uniq | awk 'NR==2 …'
em uma tentativa de capturar o id
do segundo dispositivo HUION (por exemplo, 19
)
e assim falha porque essa informação não está presente.
Como posso superar esse problema?
atualização 1
Raiz até sudo su
me dá o mesmo xinput --list
como usuário normal, mas qualquer tentativa de calibrar não teve efeito. Preciso mudar para o meu usuário na invocação do script de shell do udev? Não é muito elegante ... :(