File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /bin/sh
22# Try to find a terminal emulator that's installed and run it.
3+ set -eu
34
4- is_command () {
5- # bogus warning from ShellCheck < 0.5.0
6- # shellcheck disable=SC2039
7- type " $1 " > /dev/null 2>&1
5+ is_cmd (){
6+ command -v " $1 " > /dev/null
87}
98
10- if is_command x-terminal-emulator; then
11- exec x-terminal-emulator
12- fi
13-
14- if is_command ptyxis; then
15- exec ptyxis
16- fi
9+ exec_cmd (){
10+ if is_cmd " $1 " ; then
11+ exec " $1 "
12+ fi
13+ }
1714
18- if is_command gnome-terminal; then
19- exec qubes-run-gnome-terminal
20- fi
15+ reassign_term (){
16+ if ! is_cmd " $1 " ; then
17+ return
18+ fi
19+ case " $1 " in
20+ gnome-terminal) terminal=" qubes-run-$1 " ;;
21+ kgx) terminal=" qubes-run-gnome-console" ;;
22+ esac
23+ }
2124
22- if is_command kgx; then
23- exec qubes-run-gnome-console
25+ if is_cmd " ${TERMINAL:- } " ; then
26+ terminal=" ${TERMINAL} "
27+ reassign_term " $terminal "
28+ exec_cmd " $terminal "
2429fi
2530
26- for terminal in xfce4-terminal konsole urxvt rxvt termit terminator Eterm aterm roxterm termite lxterminal mate-terminal terminology st xterm; do
27- if is_command " $terminal " ; then
28- exec " $terminal "
29- fi
31+ for terminal in \
32+ x-terminal-emulator ptyxis gnome-terminal kgx xfce4-terminal konsole \
33+ urxvt rxvt termit terminator Eterm aterm roxterm termite lxterminal \
34+ mate-terminal terminology st lxterm xterm
35+ do
36+ reassign_term " $terminal "
37+ exec_cmd " $terminal "
3038done
3139
3240echo " ERROR: No suitable terminal found." >&2
41+ exit 1
You can’t perform that action at this time.
0 commit comments