Created
May 17, 2019 18:47
-
-
Save semeion/bdbef91008ed3d5a22c9e284c2d568cb to your computer and use it in GitHub Desktop.
udev script for handling power management
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SUBSYSTEM=="power_supply", ACTION=="change", RUN+="/etc/scripts/battery.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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