2
#---------------------------------------------
5
# Utility script to open the registered terminal emulator
7
# Refer to the usage() function below for usage.
9
# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
10
# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
11
# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
15
#---------------------------------------------
33
terminal=`kreadconfig --file kdeglobals --group General --key TerminalApplication --default konsole`
35
terminal_exec=`which $terminal 2>/dev/null`
37
if [ -x "$terminal_exec" ]; then
38
if [ x"$1" = x"" ]; then
41
$terminal_exec -e "$1"
47
exit_failure_operation_failed
50
exit_failure_operation_impossible "configured terminal program '$terminal' not found or not executable"
56
term_exec_key="/desktop/gnome/applications/terminal/exec"
57
term_exec_arg_key="/desktop/gnome/applications/terminal/exec_arg"
59
term_exec=`gconftool-2 --get ${term_exec_key}`
60
term_exec_arg=`gconftool-2 --get ${term_exec_arg_key}`
62
terminal_exec=`which $term_exec 2>/dev/null`
64
if [ -x "$terminal_exec" ]; then
65
if [ x"$1" = x"" ]; then
68
if [ x"$term_exec_arg" = x"" ]; then
71
$terminal_exec "$term_exec_arg" "$1"
78
exit_failure_operation_failed
81
exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
87
term_schema="$1"; shift
89
term_exec=`gsettings get ${term_schema} exec`
90
term_exec_arg=`gsettings get ${term_schema} exec-arg`
92
terminal_exec=`which $term_exec 2>/dev/null`
94
if [ -x "$terminal_exec" ]; then
95
if [ x"$1" = x"" ]; then
98
if [ x"$term_exec_arg" = x"" ]; then
101
$terminal_exec "$term_exec_arg" "$1"
105
if [ $? -eq 0 ]; then
108
exit_failure_operation_failed
111
exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
117
if [ x"$1" = x"" ]; then
118
exo-open --launch TerminalEmulator
120
exo-open --launch TerminalEmulator "$1"
123
if [ $? -eq 0 ]; then
126
exit_failure_operation_failed
132
# if $TERM is a known non-command, use hard-coded fallbacks
133
if [ x"$TERM" = x"" ] || [ x"$TERM" = x"linux" ] || [ x"$TERM" = x"vt100" ]; then
137
terminal_exec=`which $TERM 2>/dev/null`
139
if [ -x "$terminal_exec" ]; then
140
if [ x"$1" = x"" ]; then
143
# screen and urxvt won't do their own parsing of quoted arguments
144
if [ x"$TERM" = x"screen" ]; then
145
# screen has an incompatible meaning for -e
146
sh -c "exec $terminal_exec $1"
147
elif [ x"$TERM" = x"urxvt" ] || [ x"$TERM" = x"rxvt-unicode" ] || [ x"$TERM" = x"rxvt" ]; then
148
#TODO: Use whatever mechanism dash supports to test for
149
# rxvt-* to match things like rxvt-unicode-256color
150
sh -c "exec $terminal_exec -e $1"
152
$terminal_exec -e "$1"
156
if [ $? -eq 0 ]; then
159
exit_failure_operation_failed
162
exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable"
168
if which lxterminal &>/dev/null; then
169
if [ x"$1" = x"" ]; then
175
terminal_generic "$1"
179
#[ x"$1" != x"" ] || exit_failure_syntax
182
while [ $# -gt 0 ] ; do
188
exit_failure_syntax "unexpected option '$parm'"
192
if [ -n "$command" ] ; then
193
exit_failure_syntax "unexpected argument '$parm'"
202
if [ x"$DE" = x"" ]; then
208
terminal_kde "$command"
212
terminal_gnome "$command"
216
terminal_gsettings org.gnome.desktop.default-applications.terminal "$command"
220
terminal_gsettings org.cinnamon.desktop.default-applications.terminal "$command"
224
terminal_gsettings org.mate.applications-terminal "$command"
228
terminal_xfce "$command"
232
terminal_lxde "$command"
236
terminal_generic "$command"
240
exit_failure_operation_impossible "no terminal emulator available"