From b87527f8b05ba7615597667b16761ef4bb137f64 Mon Sep 17 00:00:00 2001 From: John Mertz Date: Thu, 20 Jul 2023 22:07:23 -0400 Subject: [PATCH] Enhance idle options Allow for calling idle with --ignore_mode to run an option beyond the current sequence limit. Allow 'dim' as it's own option. Add 'lock' option to waybar script (and add it to source control in the first place). Simplify sequence logic by setting a numerical mode. Improve help. --- sway/idle.sh | 207 +++++++++++++++++++++++++----------------- waybar/waybar-idle.sh | 40 ++++++++ 2 files changed, 166 insertions(+), 81 deletions(-) create mode 100755 waybar/waybar-idle.sh diff --git a/sway/idle.sh b/sway/idle.sh index 5d01a74..642b714 100755 --- a/sway/idle.sh +++ b/sway/idle.sh @@ -1,91 +1,136 @@ #!/bin/bash +FADE_TIMEOUT=60 # one minute +DIM_TIMEOUT=120 # two minutes +LOCK_TIMEOUT=300 # five minutes +SLEEP_TIMEOUT=600 # ten minutes +HIBERNATE_TIMEOUT=3600 # one hour + BLFILE="$HOME/.spool/idle.dim" OPFILE="$HOME/.spool/active_outputs" -NOHIBERNATE="$HOME/.spool/hibernate_inhibitor" +IDLEMODE=$(cat $HOME/.spool/idle_mode) +if [[ -n $2 ]]; then + if [[ $2 == '--ignore_mode' ]]; then + $IDLEMODE='hibernate' + else + echo "Unknown mode $IDLEMODE" + exit + fi +fi +if [[ -z $IDLEMODE ]]; then + IDLEMODE="lock" +fi +if [[ $IDLEMODE == 'none' ]]; then + IDLEMODE=0 +elif [[ $IDLEMODE == 'fade' ]]; then + IDLEMODE=1 +elif [[ $IDLEMODE == 'dim' ]]; then + IDLEMODE=2 +elif [[ $IDLEMODE == 'lock' ]]; then + IDLEMODE=3 +elif [[ $IDLEMODE == 'sleep' ]]; then + IDLEMODE=4 +elif [[ $IDLEMODE == 'hibernate' ]]; then + IDLEMODE=5 +else + echo "Invalid idle_mode '$IDLEMODE'" +fi -FADE_TIMEOUT=60 # one minute -DIM_TIMEOUT=120 # two minutes -LOCK_TIMEOUT=300 # five minutes -DPMS_TIMEOUT=600 # ten minutes -SUSPEND_TIMEOUT=3600 # one hour +function usage() { + echo "usage: $0