#!/bin/sh

#Finish vpn and networking stuff after ini script is finished, then make sure printf in case goes to stderror which is shown in bar

launch() {
	app=$(printf "Notes
Files
Editor
Terminal
Multiplexer
LBRY
Chat
Music
Browser
Email
Processes" | 
		dmenu -i -p "Launcher")

case $app in 
	Notes) st -e vim "+cd ~/Notes/text" "+CtrlP";;
	Files) st -e nnn;;
	Editor) st -e vim;;
	Terminal) st;;
	Multiplexer) st -e tmux $*;;
	LBRY) lbry;;
	Chat) element-desktop;;
	Music) st -e ncmpcpp;;
	Browser) brave-browser;;
	Email) brave-browser mail.protonmail.com/login;;
	Processes) st -e htop;;
esac
}

action() {
	action=$(printf "Play Music
Pause Music
Toggle Music
Select VPN
Disable VPN
Enable VPN
VPN Status
Rebind Keys
Disable Bar
Enable Bar" |
		dmenu -i -p "Actions")

case $action in
	'Play Music') mpc play ;;
	'Pause Music') mpc pause ;;
	'Toggle Music') mpc toggle ;;
	'Rebind Keys') setup-xbindkeys;;
	'Disable Bar') tmux set -g status off;;
	'Enable Bar') tmux set -g status on;;
esac
}

screenshot() {
	method=$(printf "clipboard
file
both" |
	dmenu -i -p "Screenshot")

	if test $method = "file"; then
		scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
			-s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png 
	fi
}
	if test $method = "clipboard"; then
		scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
			-s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
			-e "xclip $f; rm $f"
	fi

	if test $method = "both"; then
		scrot --note "-f 'LiterationSans Nerd Font Book/11' -x 10 -y 20 -c 255,0,0,255 -t 'Hi'"\
			-s ~/Pictures/screenshots/screenshot-%Y-%m-%d_$wx$h.png\
			-e "xclip $f;"
	fi
case $1 in
	launch) launch;;
	action) action;;
	*) printf "Invalid argument";;
esac