Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
udev script for handling power management
SUBSYSTEM=="power_supply", ACTION=="change", RUN+="/etc/scripts/"
AC=$(cat /sys/class/power_supply/AC/online)
# 2 hour DPMS timeout on AC, 10 minute timeout on battery
[ $AC -eq 1 ] && DPMS=7200 || DPMS=600
for D in /tmp/.X11-unix/X*; do
[ -S "$D" ] && sudo -u $(stat -c %U $D) DISPLAY=:${D##*X} /usr/bin/xset dpms $DPMS $DPMS $DPMS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.