Skip to content

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
@semeion

This comment has been minimized.

Copy link

@semeion semeion commented May 17, 2019

nice rule, very usefull

@semeion

This comment has been minimized.

Copy link

@semeion semeion commented May 18, 2019

what about add an option to set console blank time too? maybe using setterm... it could be nice! But i have no idea how to loop in tty to add something like "setterm -blank $DPMS -powerdown #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.