Allow specifying a specific mode as an argument
This commit is contained in:
parent
4edd9a297d
commit
7af9d67b29
|
@ -1,40 +1,45 @@
|
||||||
#!/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
|
||||||
MODE=$(cat $FILE)
|
if [[ -e $FILE ]]; then
|
||||||
|
MODE=$(cat $FILE)
|
||||||
|
else
|
||||||
|
MODE="fade"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
MODE="fade"
|
MODE="$1"
|
||||||
echo -n $MODE >$FILE
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $MODE == "none" ]]; then
|
if [[ $MODE == "none" ]]; then
|
||||||
NEXT="fade"
|
NEXT="fade"
|
||||||
ICON="☕"
|
ICON="☕"
|
||||||
elif [[ $MODE == "fade" ]]; then
|
elif [[ $MODE == "fade" ]]; then
|
||||||
ICON="🌌"
|
ICON="🌌"
|
||||||
NEXT="dim"
|
NEXT="dim"
|
||||||
elif [[ $MODE == "dim" ]]; then
|
elif [[ $MODE == "dim" ]]; then
|
||||||
ICON="⬛"
|
ICON="⬛"
|
||||||
NEXT="lock"
|
NEXT="lock"
|
||||||
elif [[ $MODE == "lock" ]]; then
|
elif [[ $MODE == "lock" ]]; then
|
||||||
ICON="🔒"
|
ICON="🔒"
|
||||||
NEXT="sleep"
|
NEXT="sleep"
|
||||||
elif [[ $MODE == "sleep" ]]; then
|
elif [[ $MODE == "sleep" ]]; then
|
||||||
ICON="💤"
|
ICON="💤"
|
||||||
NEXT="hibernate"
|
NEXT="hibernate"
|
||||||
elif [[ $MODE == "hibernate" ]]; then
|
elif [[ $MODE == "hibernate" ]]; then
|
||||||
ICON="↯ "
|
ICON="↯ "
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue