Files
dotfiles/picom/.scripts/picom.sh
Sravan Balaji 6a050b96f3 Fix Wayland Startup Issues
- Make all notify-send commands non-blocking
  (i.e., run in background)
- Remove delay array from wayland startup
- Call startup script with `dwl -s`
2024-09-29 16:14:53 -04:00

77 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
help_menu() {
echo "Script to interact with picom. Use only one argument at a time."
echo " - Toggle On/Off: picom.sh OR picom.sh --toggle OR picom.sh -t"
echo " - Turn On: picom.sh --on"
echo " - Turn Off: picom.sh --off"
echo " - Help: picom.sh --help OR picom.sh -h"
}
is_running() {
if pgrep -x picom >/dev/null; then
echo 1
else
echo 0
fi
}
rofi_menu() {
declare -a options=(
"⏼ Toggle - toggle"
"󱄄 Turn On - on"
"󰶐 Turn Off - off"
"󰌍 Back - back"
"󰗼 Quit - quit"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -dmenu -i)
option=$(printf '%s\n' "${choice}" | awk '{print $NF}')
if [[ "$option" == "quit" ]]; then
pkill rofi
elif [[ "$option" != "back" ]]; then
main "--$option" && main "--rofi"
fi
}
main() {
if [ $# -eq 0 ]; then
# No arguments
help_menu
else
case $1 in
--help | -h)
help_menu
;;
--toggle)
if [ $(is_running) -eq '1' ]; then
main --off
else
main --on
fi
;;
--on)
if [ $(is_running) -eq '1' ]; then
pkill picom
fi
picom --config $HOME/.config/picom/picom.conf -b
notify-send "Turning Picom ON" &
;;
--off)
if [ $(is_running) -eq '1' ]; then
pkill picom
fi
notify-send "Turning Picom OFF" &
;;
--rofi)
rofi_menu
;;
esac
fi
}
main $@