'mode' command didn't actually work until now.
Also rotate mode if no argument is provided. This makes the rotate behaviour of waybar-idle.sh unnecessary.
This commit is contained in:
parent
60344ec940
commit
b32759643a
20
sway/idle.sh
20
sway/idle.sh
|
@ -10,9 +10,12 @@ BLFILE="$HOME/.local/state/idle.dim"
|
|||
OPFILE="$HOME/.local/state/active_outputs"
|
||||
STATEFILE="$HOME/.local/state/idle.state"
|
||||
IDLEMODE=$(cat $HOME/.local/state/idle_mode)
|
||||
|
||||
if [[ -n $2 ]]; then
|
||||
if [[ $2 == '--ignore_mode' ]]; then
|
||||
IDLEMODE='hibernate'
|
||||
elif [[ $1 == "mode" ]]; then
|
||||
IDLEMODE=$2
|
||||
else
|
||||
echo "Unknown mode $IDLEMODE"
|
||||
exit
|
||||
|
@ -76,6 +79,23 @@ function usage() {
|
|||
if [[ -z $1 ]]; then
|
||||
echo "Missing argument"
|
||||
usage
|
||||
elif [[ $1 == "mode" ]]; then
|
||||
if [[ -n $2 ]]; then
|
||||
echo -n $2 > $HOME/.local/state/idle_mode
|
||||
elif [[ $IDLEMODE == 0 ]]; then
|
||||
echo -n 'fade' > $HOME/.local/state/idle_mode
|
||||
elif [[ $IDLEMODE == 1 ]]; then
|
||||
echo -n 'dim' > $HOME/.local/state/idle_mode
|
||||
elif [[ $IDLEMODE == 2 ]]; then
|
||||
echo -n 'lock' > $HOME/.local/state/idle_mode
|
||||
elif [[ $IDLEMODE == 3 ]]; then
|
||||
echo -n 'sleep' > $HOME/.local/state/idle_mode
|
||||
elif [[ $IDLEMODE == 4 ]]; then
|
||||
echo -n 'hibernate' > $HOME/.local/state/idle_mode
|
||||
elif [[ $IDLEMODE == 5 ]]; then
|
||||
echo -n 'none' > $HOME/.local/state/idle_mode
|
||||
fi
|
||||
cat $HOME/.local/state/idle_mode
|
||||
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]] || [[ $1 == "help" ]]; then
|
||||
usage
|
||||
elif [[ $1 == "start" ]]; then
|
||||
|
|
|
@ -1,45 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
FILE="$HOME/.local/state/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"
|
||||
ICON="? "
|
||||
echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Error: Invalid mode ('$MODE')","class":"'$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
|
||||
|
|
Loading…
Reference in New Issue