Eu nunca fiz isso, mas tentarei ajudar baseando-se em outro site da SE.
Basicamente seguindo esta esta resposta você deve ser bom para modificar arquivos udev e prover scripts:
/etc/udev/rules.d/00-usb-keyboard.rules
ATTRS{idVendor}=="09da", ATTRS{idProduct}=="0260", OWNER="YOURUSERNAME"
ACTION=="add", RUN+="/home/YOURUSERNAME/.bin/usb-keyboard-in_udev"
ACTION=="remove", RUN+="/home/YOURUSERNAME/.bin/usb-keyboard-out_udev"
/home/YOURUSERNAME/.bin/usb-keyboard-in_udev
#!/bin/bash
/home/YOURUSERNAME/.bin/usb-keyboard-in &
#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/YOURUSERNAME/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
YOUR_COMMAND_HERE
/home/YOURUSERNAME/.bin/usb-keyboard-out_udev
#!/bin/bash
/home/YOURUSERNAME/.bin/usb-keyboard-out &
/home/YOURUSERNAME/.bin/usb-keyboard-out
#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/YOURUSERNAME/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
YOUR_COMMAND_HERE
Todos esses scripts devem ter permissão executável ( chmod +x
).
De acordo com a resposta:
USB keyboard vendor and product ids should be changed as per the output of the command lsusb (For example, my lsusb output have this for my USB Keyboard: Bus 001 Device 006: ID 09da:0260 A4 Tech Co., Ltd)
Espero que isso funcione para você.