scripts/waybar/toggle.sh

34 lines
956 B
Bash
Executable File

#!/bin/bash
ARG=$1
if [[ $ARG == '' ]]; then
ARG="toggle"
fi
if [[ $ARG == 'toggle' ]]; then
if [[ -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
rm '/home/jpm/.local/state/.waybar_hidden';
else
touch '/home/jpm/.local/state/.waybar_hidden';
fi
elif [[ $ARG == 'hide' ]]; then
if [[ ! -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
touch '/home/jpm/.local/state/.waybar_hidden';
else
echo 'Already hidden. You may need to use the "invert" option if action is reversed';
exit;
fi
elif [[ $ARG == 'show' ]]; then
if [[ -e '/home/jpm/.local/state/.waybar_hidden' ]]; then
rm '/home/jpm/.local/state/.waybar_hidden';
else
echo 'Already shown. You may need to use the "invert" option if action is reversed';
exit;
fi
elif [[ $ARG != 'invert' ]]; then
echo "Invalid argument";
fi
BARS=$(pgrep waybar | cut -d ' ' -f 1)
kill -s SIGUSR1 $BARS