diff --git a/waybar/waybar-idle.sh b/waybar/waybar-idle.sh index f7383a5..98932cc 100755 --- a/waybar/waybar-idle.sh +++ b/waybar/waybar-idle.sh @@ -1,40 +1,45 @@ #!/bin/bash FILE="$HOME/.spool/idle_mode" -if [ -e $FILE ]; then - MODE=$(cat $FILE) +if [[ -z $1 ]] || [[ "$1" == 'rotate' ]] || [[ "$1" == 'bar' ]]; then + if [[ -e $FILE ]]; then + MODE=$(cat $FILE) + else + MODE="fade" + fi else - MODE="fade" - echo -n $MODE >$FILE + MODE="$1" fi if [[ $MODE == "none" ]]; then - NEXT="fade" - ICON="☕" + NEXT="fade" + ICON="☕" elif [[ $MODE == "fade" ]]; then - ICON="🌌" - NEXT="dim" + ICON="🌌" + NEXT="dim" elif [[ $MODE == "dim" ]]; then - ICON="⬛" - NEXT="lock" + ICON="⬛" + NEXT="lock" elif [[ $MODE == "lock" ]]; then - ICON="🔒" - NEXT="sleep" + ICON="🔒" + NEXT="sleep" elif [[ $MODE == "sleep" ]]; then - ICON="💤" - NEXT="hibernate" + ICON="💤" + NEXT="hibernate" elif [[ $MODE == "hibernate" ]]; then - ICON="↯ " - NEXT="none" + ICON="↯ " + NEXT="none" else - echo "Invalid mode: $MODE" + echo "Invalid mode: $MODE" + exit fi -if [ -z $1 ] || [ "$1" == "bar" ]; then - echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Change sleep mode ('$MODE')","class":"'$MODE'"}' +if [[ -z $1 ]] || [[ "$1" == "bar" ]]; then + echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Change sleep mode ('$MODE')","class":"'$MODE'"}' elif [ "$1" == "rotate" ]; then - echo -n $NEXT >$FILE - $0 bar + echo -n $NEXT >$FILE + $0 bar else - echo "Invalid argumuent $1" + echo -n $MODE >$FILE + $0 bar fi