# vim:fileencoding=utf-8:foldmethod=marker:foldmarker={{{,}}}
#!/bin/bash

# {{{ Functions

function Run_App_Once {
	if ! pgrep -f $1 ;
	then
		$@&
	fi
}

function Run_Sudo_Command {
	tempName=`/bin/bash -c "echo $@ | sed 's/\///g'"`
	
	#echo "pre test"
	#echo $tempName
	#echo `test -f /tmp/$tempName`
	if ! test -f /tmp/$tempName;
	then
		/bin/bash -c "touch /tmp/$tempName"
		#echo "test failed"
		#echo $tempName
		kitty --hold /bin/zsh -c "sudo $@"
	fi
}

# End functions }}}


# {{{ Autostart apps arrays

#startOnce_arr=("volctl" "nm-applet")
#startOnce_arr=("nm-applet" "alacritty -e /home/sekhali/autostart_scripts/main.sh")
startOnce_arr=("nm-applet")
#startSudo_arr=("/home/sekhali/autostart_scripts/main.sh")
# End autostart apps array }}}


# {{{ Run apps once

for startOnce in ${startOnce_arr[@]} ; do
	#notify-send $RunOnce
	Run_App_Once $startOnce
	#notify-send $?
done

# End run apps once}}}


# {{{ Start with sudo

#for startSudo in ${startSudo_arr[@]} ; do
#	Run_Sudo_Command $startSudo
#done

# End start with sudo}}}
