mirror of
https://github.com/Snigdha-OS/snigdhaos-pkgbuilds.git
synced 2026-03-01 17:53:54 +01:00
62 lines
1.6 KiB
Bash
62 lines
1.6 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
LAUNCH_TERMINAL_SHELL=bash
|
|
|
|
usage(){
|
|
echo "Usage: ${0##*/} [cmd]"
|
|
echo " -s [shell] changes the shell to [shell]"
|
|
echo ' -h This help'
|
|
exit 1
|
|
}
|
|
|
|
opts='s:h'
|
|
|
|
while getopts "${opts}" arg; do
|
|
case "${arg}" in
|
|
s) LAUNCH_TERMINAL_SHELL="$OPTARGS" ;;
|
|
h | ?) usage 0 ;;
|
|
*)
|
|
echo "Invalid arguments '${arg}'"
|
|
usage 1 ;;
|
|
esac
|
|
done
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
initfile="$(mktemp)"
|
|
codefile="$initfile"
|
|
echo "#!/usr/bin/env bash" >"$initfile"
|
|
if [ "$LAUNCH_TERMINAL_SHELL" != "bash" ]; then
|
|
codefile="$(mktemp)"
|
|
echo "$LAUNCH_TERMINAL_SHELL $codefile" >>"$initfile"
|
|
fi
|
|
echo "$1" >>"$codefile"
|
|
chmod +x "$initfile"
|
|
cmd="\"$initfile\""
|
|
|
|
terminal=""
|
|
declare -A terminals=(["alacritty"]="alacritty -e $cmd || LIBGL_ALWAYS_SOFTWARE=1 alacritty -e $cmd" ["konsole"]="konsole -e $cmd" ["kgx"]="kgx -e $cmd" ["gnome-terminal"]="gnome-terminal --wait -- $cmd" ["xfce4-terminal"]="xfce4-terminal --disable-server --command '$cmd'" ["qterminal"]="qterminal -e $cmd" ["lxterminal"]="lxterminal -e $cmd" ["mate-terminal"]="mate-terminal --disable-factory -e $cmd" ["xterm"]="xterm -e $cmd" ["foot"]="foot -T exec-terminal -e $cmd")
|
|
declare -a term_order=("alacritty" "knosole" "kgx" "gnome-terminal" "mate-terminal" "xfce4-terminal" "qterminal" "lxterminal" "xterm" "foot")
|
|
|
|
case "$XDG_CURRENT_DESKTOP" in
|
|
KDE)
|
|
terminal="konsole"
|
|
;;
|
|
GNOME)
|
|
if command -v "kgx" &>/dev/null; then
|
|
terminal=kgx
|
|
else
|
|
terminal=gnome-terminal
|
|
fi
|
|
;;
|
|
XFCE)
|
|
terminal=xfce4-terminal
|
|
;;
|
|
LXQt)
|
|
terminal=qterminal
|
|
;;
|
|
MATE)
|
|
terminal=mate-terminal
|
|
;;
|
|
esac |