scripts/waybar/waybar-idle.sh

41 lines
766 B
Bash
Executable File

#!/bin/bash
FILE="$HOME/.spool/idle_mode"
if [ -e $FILE ]; then
MODE=$(cat $FILE)
else
MODE="fade"
echo -n $MODE >$FILE
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"
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 "Invalid argumuent $1"
fi