I have some udev rules written to run when I connect certain usb devices. For example, I change pointer velocity for certain mice, and change xmodmaps for particular keyboards.

The scripts work well when connecting the devices when the computer is on, and also work while connecting them while the computer is suspended. However, these udev rules appear not to fire if the device is plugged in before I boot up or log in. Is there a way to make them run on startup?

I'm using (K)ubuntu 13.04. Here are some examples of my udev rules and scripts.


ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0e6a", ATTR{idProduct}=="030c", RUN+="/usr/local/bin/TECK_connect"
ACTION=="remove", SUBSYSTEM=="usb", RUN+="/usr/local/bin/TECK_disconnect"


#!/usr/bin/env bash

export DISPLAY=:0.0
cp -f /home/sparhawk/HDD/Computer/Xmodmaps/Xmodmap_for_TECK /home/sparhawk/.Xmodmap
sudo -u sparhawk setxkbmap -layout us -variant altgr-intl
sudo -u sparhawk xmodmap /home/sparhawk/.Xmodmap
sudo -u sparhawk pkill xcape
sudo -u sparhawk xcape -e 'Alt_L=Return' && sudo -u sparhawk notify-send "xmodmap" "TECK connected." -i /usr/share/icons/oxygen/48x48/devices/input-keyboard.png --hint=int:transient:1


ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="0016" RUN+="/bin/sh -c 'echo $env{DEVPATH} | grep -q usb./[^/]*/[^/]*/[^/]*$ && echo enabled > /sys$env{DEVPATH}/../power/wakeup; razer_slowdown'"


#!/usr/bin/env bash
# slow down the tracking speed of a razer mouse.
# to check, $ xinput --list-props "Razer Razer DeathAdder"| grep 'Constant Deceleration'
# which was originally 1

scriptproper () {
        sleep 0.5 # perhaps not necessary, but putting it in background is.
        export DISPLAY=:0.0
        sudo -u sparhawk xinput --set-prop "Razer Razer DeathAdder" "Device Accel Constant Deceleration" 3

scriptproper &

1 Answer 1


No, since the operations you describe all require a running X server. You should consider creating an autostart item for them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.