Allow specifying a specific mode as an argument

This commit is contained in:
John Mertz 2023-08-13 22:27:34 -06:00
parent 4edd9a297d
commit 7af9d67b29
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
1 changed files with 27 additions and 22 deletions

View File

@ -1,11 +1,14 @@
#!/bin/bash #!/bin/bash
FILE="$HOME/.spool/idle_mode" FILE="$HOME/.spool/idle_mode"
if [ -e $FILE ]; then if [[ -z $1 ]] || [[ "$1" == 'rotate' ]] || [[ "$1" == 'bar' ]]; then
if [[ -e $FILE ]]; then
MODE=$(cat $FILE) MODE=$(cat $FILE)
else else
MODE="fade" MODE="fade"
echo -n $MODE >$FILE fi
else
MODE="$1"
fi fi
if [[ $MODE == "none" ]]; then if [[ $MODE == "none" ]]; then
@ -28,13 +31,15 @@ elif [[ $MODE == "hibernate" ]]; then
NEXT="none" NEXT="none"
else else
echo "Invalid mode: $MODE" echo "Invalid mode: $MODE"
exit
fi fi
if [ -z $1 ] || [ "$1" == "bar" ]; then if [[ -z $1 ]] || [[ "$1" == "bar" ]]; then
echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Change sleep mode ('$MODE')","class":"'$MODE'"}' echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Change sleep mode ('$MODE')","class":"'$MODE'"}'
elif [ "$1" == "rotate" ]; then elif [ "$1" == "rotate" ]; then
echo -n $NEXT >$FILE echo -n $NEXT >$FILE
$0 bar $0 bar
else else
echo "Invalid argumuent $1" echo -n $MODE >$FILE
$0 bar
fi fi