Instantly share code, notes, and snippets.

Embed
What would you like to do?
udev script for handling power management
SUBSYSTEM=="power_supply", ACTION=="change", RUN+="/etc/scripts/battery.sh"
#!/bin/bash
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
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment