Skip to content

Instantly share code, notes, and snippets.

@taylor
Forked from anonymous/gist:4057537
Created November 15, 2012 01:37
Show Gist options
  • Save taylor/4076083 to your computer and use it in GitHub Desktop.
Save taylor/4076083 to your computer and use it in GitHub Desktop.
Watch udev events and configure shit that should be automatically configured in the first place.
#!/bin/sh
config_input() {
setxkbmap -option ctrl:nocaps
dev="TPPS/2 IBM TrackPoint"
xinput --set-prop "$dev" "Evdev Wheel Emulation" 1
xinput --set-prop "$dev" "Evdev Wheel Emulation Button" 2
xinput --set-int-prop "$dev" "Evdev Wheel Emulation Axes" 8 6 7 4 5
}
config_display() {
xrandr --output LVDS1 --auto --output HDMI1 --auto --output VGA1 --auto
xset -dpms s off
}
config_input
config_display
unbuffer udevadm monitor \
| unbuffer -p sed -e '/^UDEV.*(\(machinecheck.*\|hidraw\|drm\))$/!d' \
-e 's/^.*(\(\w*\))$/\1/' \
| while read -r line
do
udevadm settle
case "$line" in
"machinecheck"*)
config_input
config_display
;;
"hidraw"*)
config_input
;;
"drm"*)
config_display
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment