2023-07-21 02:07:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-03-08 19:11:04 +00:00
|
|
|
FILE="$HOME/.local/state/idle_mode"
|
2023-08-14 04:27:34 +00:00
|
|
|
if [[ -z $1 ]] || [[ "$1" == 'rotate' ]] || [[ "$1" == 'bar' ]]; then
|
|
|
|
if [[ -e $FILE ]]; then
|
|
|
|
MODE=$(cat $FILE)
|
|
|
|
else
|
|
|
|
MODE="fade"
|
|
|
|
fi
|
2023-07-21 02:07:23 +00:00
|
|
|
else
|
2023-08-14 04:27:34 +00:00
|
|
|
MODE="$1"
|
2023-07-21 02:07:23 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $MODE == "none" ]]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
NEXT="fade"
|
|
|
|
ICON="☕"
|
2023-07-21 02:07:23 +00:00
|
|
|
elif [[ $MODE == "fade" ]]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
ICON="🌌"
|
|
|
|
NEXT="dim"
|
2023-07-21 02:07:23 +00:00
|
|
|
elif [[ $MODE == "dim" ]]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
ICON="⬛"
|
|
|
|
NEXT="lock"
|
2023-07-21 02:07:23 +00:00
|
|
|
elif [[ $MODE == "lock" ]]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
ICON="🔒"
|
|
|
|
NEXT="sleep"
|
2023-07-21 02:07:23 +00:00
|
|
|
elif [[ $MODE == "sleep" ]]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
ICON="💤"
|
|
|
|
NEXT="hibernate"
|
2023-07-21 02:07:23 +00:00
|
|
|
elif [[ $MODE == "hibernate" ]]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
ICON="↯ "
|
|
|
|
NEXT="none"
|
2023-07-21 02:07:23 +00:00
|
|
|
else
|
2023-08-14 04:27:34 +00:00
|
|
|
echo "Invalid mode: $MODE"
|
|
|
|
exit
|
2023-07-21 02:07:23 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-14 04:27:34 +00:00
|
|
|
if [[ -z $1 ]] || [[ "$1" == "bar" ]]; then
|
|
|
|
echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Change sleep mode ('$MODE')","class":"'$MODE'"}'
|
2023-07-21 02:07:23 +00:00
|
|
|
elif [ "$1" == "rotate" ]; then
|
2023-08-14 04:27:34 +00:00
|
|
|
echo -n $NEXT >$FILE
|
|
|
|
$0 bar
|
2023-07-21 02:07:23 +00:00
|
|
|
else
|
2023-08-14 04:27:34 +00:00
|
|
|
echo -n $MODE >$FILE
|
|
|
|
$0 bar
|
2023-07-21 02:07:23 +00:00
|
|
|
fi
|