Skip to content

Instantly share code, notes, and snippets.

@Apsu
Created August 23, 2012 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apsu/3433074 to your computer and use it in GitHub Desktop.
Save Apsu/3433074 to your computer and use it in GitHub Desktop.
drm udev rule
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="display"
#!/bin/zsh
for i in /sys/class/drm/card0-*/status; do
d="${${${i#*-}%/*}/(-?-|-)}"
if [[ "$d" == "LVDS1" ]]; then
t="--output LVDS1 --auto --primary$t"
elif [[ "$(<$i)" == "connected" ]]; then
t="$t --output $d --auto --left-of LVDS1"
else
t="$t --output $d --off"
fi
done
doit() {
DISPLAY=:0 XAUTHORITY=/home/apsu/.Xauthority xrandr $*
}
doit $(echo $t)
@Apsu
Copy link
Author

Apsu commented Aug 23, 2012

The 10-display.rules file goes in /etc/udev/rules.d
The display file goes in /lib/udev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment