@@ -21,44 +21,76 @@ usage() {
2121 echo " Usage: ${0##*/ } [cmd]"
2222 echo ' -s [shell] Change shell to [shell]'
2323 echo ' -h This help'
24- exit 1
24+ exit " $1 "
2525}
2626
2727opts=' s:h'
2828
2929while getopts " ${opts} " arg; do
3030 case " ${arg} " in
31- s) LAUNCHER_CMD=" $OPTARG " ;;
32- h|? ) usage 0 ;;
33- * ) echo " invalid argument '${arg} '" ; usage 1 ;;
31+ s) LAUNCHER_CMD=" $OPTARG " ;;
32+ h | ? ) usage 0 ;;
33+ * )
34+ echo " invalid argument '${arg} '"
35+ usage 1
36+ ;;
3437 esac
3538done
3639
37- shift $(( $OPTIND - 1 ))
40+ # OPTIND is a global variable
41+ shift $(( OPTIND - 1 ))
3842
3943file=" $( mktemp) "
40- echo " $1 " > " $file "
44+ echo " $1 " > " $file "
4145cmd=" ${LAUNCHER_CMD} \" $file \" "
42- echo $cmd
46+ echo " $cmd "
4347
44- # declare -a terminals=(x-terminal-emulator mate-terminal gnome-terminal terminator xfce4-terminal urxvt rxvt termit Eterm aterm uxterm xterm roxterm termite lxterminal terminology st qterminal lilyterm tilix terminix konsole kitty guake tilda alacritty)
4548terminal=" "
46- declare -A terminals=( [" alacritty" ]=" alacritty -e $cmd || LIBGL_ALWAYS_SOFTWARE=1 alacritty -e $cmd " [" rio" ]=" rio -e $cmd " [" ghostty" ]=" ghostty -e $cmd " [" kitty" ]=" kitty $cmd " [" konsole" ]=" konsole -e $cmd " [" gnome-console" ]=" kgx --wait -e $cmd " [" gnome-terminal" ]=" gnome-terminal --wait -- $cmd " [" xfce4-terminal" ]=" xfce4-terminal --disable-server --command '$cmd '" [" lxterminal" ]=" lxterminal -e $cmd " [" xterm" ]=" xterm -e $cmd " [" st" ]=" st $cmd " [" foot" ]=" foot $cmd " )
47- declare -a term_order=( " alacritty" " rio" " ghostty" " kitty" " konsole" " gnome-console" " gnome-terminal" " xfce4-terminal" " lxterminal" " xterm" " st" " foot" )
49+ declare -A terminals=(
50+ [" alacritty" ]=" alacritty -e $cmd || LIBGL_ALWAYS_SOFTWARE=1 alacritty -e $cmd "
51+ [" foot" ]=" foot $cmd "
52+ [" ghostty" ]=" ghostty -e $cmd "
53+ [" gnome-console" ]=" kgx --wait -e $cmd "
54+ [" gnome-terminal" ]=" gnome-terminal --wait -- $cmd "
55+ [" kitty" ]=" kitty $cmd "
56+ [" konsole" ]=" konsole -e $cmd "
57+ [" lxterminal" ]=" lxterminal -e $cmd "
58+ [" rio" ]=" rio -e $cmd "
59+ [" st" ]=" st $cmd "
60+ [" xfce4-terminal" ]=" xfce4-terminal --disable-server --command '$cmd '"
61+ [" xterm" ]=" xterm -e $cmd "
62+ )
63+ declare -a term_order=(
64+ " alacritty"
65+ " rio"
66+ " ghostty"
67+ " kitty"
68+ " konsole"
69+ " gnome-console"
70+ " gnome-terminal"
71+ " xfce4-terminal"
72+ " lxterminal"
73+ " xterm"
74+ " st"
75+ " foot"
76+ )
4877
49- if [ -z " $terminal " ] || ! command -v " $terminal " & > /dev/null; then
50- for entry in ${term_order[@]} ; do
51- if command -v " $entry " > /dev/null 2>&1 ; then
52- terminal=" $entry "
53- break ;
54- fi
55- done
78+ if [ -z " $terminal " ] || ! command -v " $terminal " & > /dev/null; then
79+ for entry in " ${term_order[@]} " ; do
80+ if command -v " $entry " > /dev/null 2>&1 ; then
81+ terminal=" $entry "
82+ break
83+ fi
84+ done
5685fi
5786
5887if [ -z " $terminal " ]; then
5988 notify-send -t 1500 --app-name=CachyOS " No terminal installed" " Could not find a terminal emulator. Please install one."
6089 exit 1
6190fi
6291
63- eval " ${terminals[${terminal}]} " || { rm " $file " ; exit 2; }
92+ eval " ${terminals[${terminal}]} " || {
93+ rm " $file "
94+ exit 2
95+ }
6496rm " $file "
0 commit comments