From 20102a4006229b2d0177e85391a863d83527dd1e Mon Sep 17 00:00:00 2001 From: John Mertz Date: Sun, 18 Aug 2024 13:06:26 -0600 Subject: [PATCH] Save power mode before sleep, set to power-saver, then restore --- sway/idle.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sway/idle.sh b/sway/idle.sh index d3b035b..410121a 100755 --- a/sway/idle.sh +++ b/sway/idle.sh @@ -7,6 +7,7 @@ SLEEP_TIMEOUT=600 # ten minutes HIBERNATE_TIMEOUT=3600 # one hour BLFILE="$HOME/.local/state/idle.dim" +POWERMODE="$HOME/.local/state/power_profile" OPFILE="$HOME/.local/state/active_outputs" STATEFILE="$HOME/.local/state/idle.state" IDLEMODE=$(cat $HOME/.local/state/idle_mode) @@ -163,6 +164,8 @@ elif [[ $1 == "unlock" ]]; then fi elif [[ $1 == "sleep" ]]; then if [[ $IDLEMODE -gt 3 ]]; then + powerprofilesctl get > $POWERMODE + powerprofilesctl set power-saver echo 'sleep' > $STATEFILE for i in $(cat $OPFILE); do swaymsg "output $i dpms off"; done fi @@ -175,6 +178,7 @@ elif [[ $1 == "unsleep" ]]; then if [[ -e $STATEFILE ]]; then rm $STATEFILE fi + powerprofilesctl set $(cat $POWERMODE) elif [[ $1 == "hibernate" ]]; then if [[ $IDLEMODE -gt 4 ]]; then echo 'hibernate' > $STATEFILE