scripts/waybar/waybar-idle.sh

46 lines
932 B
Bash
Raw Normal View History

#!/bin/bash
FILE="$HOME/.spool/idle_mode"
if [[ -z $1 ]] || [[ "$1" == 'rotate' ]] || [[ "$1" == 'bar' ]]; then
if [[ -e $FILE ]]; then
MODE=$(cat $FILE)
else
MODE="fade"
fi
else
MODE="$1"
fi
if [[ $MODE == "none" ]]; then
NEXT="fade"
ICON="☕"
elif [[ $MODE == "fade" ]]; then
ICON="🌌"
NEXT="dim"
elif [[ $MODE == "dim" ]]; then
ICON="⬛"
NEXT="lock"
elif [[ $MODE == "lock" ]]; then
ICON="🔒"
NEXT="sleep"
elif [[ $MODE == "sleep" ]]; then
ICON="💤"
NEXT="hibernate"
elif [[ $MODE == "hibernate" ]]; then
ICON="↯ "
NEXT="none"
else
echo "Invalid mode: $MODE"
exit
fi
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
else
echo -n $MODE >$FILE
$0 bar
fi