#!/bin/bash
# composite level selector
# arpinux 2020 <https://arpinux.org>

# options - see 'man compton'
LIGHT="--shadow \
	--no-dock-shadow \
	--inactive-opacity .8 \
	--inactive-opacity-override \
	--detect-transient \
	--detect-client-leader" 
FULL="--shadow \
	--no-dock-shadow \
	--fading \
	--active-opacity 1 \
	--inactive-opacity .6 \
	--inactive-opacity-override \
	--menu-opacity .9 \
	--frame-opacity .9 \
	--no-fading-destroyed-argb \
	--detect-transient \
	--detect-client-leader"

# with args > just exec
if [ "$1" == "-s" ]; then
    pkill -9 compton
    exit 0
elif [ "$1" == "-l" ]; then
    pkill -9 compton
    sleep 1s
    compton $LIGHT &
    exit 0
elif [ "$1" == "-f" ]; then
    pkill -9 compton
    sleep 1s
    compton $FULL &
    exit 0
else
    # no args or wrong args > show dmenu
    choice=`echo -e "light\nfull\nstop\ncancel" | \
		rofi -dmenu \
		-p "composite level selector >> "`

	case "$choice" in
		light)	pkill -9 compton
			sleep 1s
			compton $LIGHT & ;;
		full)	pkill -9 compton
			sleep 1s
			compton $FULL & ;;
		stop)	pkill -9 compton & ;;
		cancel)	exit ;;
	esac
fi