blob: a4f2acf15474b63c62da2af4ae98bdec17731d75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
#!/bin/sh
#---------------------------------------------
# xdg-terminal
#
# Utility script to open the registered terminal emulator
#
# Refer to the usage() function below for usage.
#
# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
#
# LICENSE:
#
#---------------------------------------------
manualpage()
{
cat << _MANUALPAGE
_MANUALPAGE
}
usage()
{
cat << _USAGE
_USAGE
}
#@xdg-utils-common@
terminal_kde()
{
terminal=`kreadconfig --file kdeglobals --group General --key TerminalApplication --default konsole`
terminal_exec=`which $terminal 2>/dev/null`
if [ -x "$terminal_exec" ]; then
if [ x"$1" == x"" ]; then
$terminal_exec
else
$terminal_exec -e "$1"
fi
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
else
exit_failure_operation_impossible "configured terminal program '$terminal' not found or not executable"
fi
}
terminal_gnome()
{
term_exec_key="/desktop/gnome/applications/terminal/exec"
term_exec_arg_key="/desktop/gnome/applications/terminal/exec_arg"
term_exec=`gconftool-2 --get ${term_exec_key}`
term_exec_arg=`gconftool-2 --get ${term_exec_arg_key}`
terminal_exec=`which $term_exec 2>/dev/null`
if [ -x "$terminal_exec" ]; then
if [ x"$1" == x"" ]; then
$terminal_exec
else
if [ x"$term_exec_arg" == x"" ]; then
$terminal_exec "$1"
else
$terminal_exec "$term_exec_arg" "$1"
fi
fi
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
else
exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
fi
}
terminal_xfce()
{
if [ x"$1" == x"" ]; then
exo-open --launch TerminalEmulator
else
exo-open --launch TerminalEmulator "$1"
fi
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
}
terminal_generic()
{
# if $TERM is not set, try xterm
if [ x"$TERM" == x"" ]; then
TERM=xterm
fi
terminal_exec=`which $TERM >/dev/null 2>/dev/null`
if [ -x "$terminal_exec" ]; then
if [ $? -eq 0 ]; then
exit_success
else
exit_failure_operation_failed
fi
else
exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable"
fi
}
terminal_lxde()
{
if which lxterminal &>/dev/null; then
if [ x"$1" == x"" ]; then
lxterminal
else
lxterminal -e "$1"
fi
else
terminal_generic "$1"
fi
}
#[ x"$1" != x"" ] || exit_failure_syntax
command=
while [ $# -gt 0 ] ; do
parm="$1"
shift
case "$parm" in
-*)
exit_failure_syntax "unexpected option '$parm'"
;;
*)
if [ -n "$command" ] ; then
exit_failure_syntax "unexpected argument '$parm'"
fi
command="$parm"
;;
esac
done
detectDE
if [ x"$DE" = x"" ]; then
# if TERM variable is not set, try xterm
if [ x"$TERM" = x"" ]; then
TERM=xterm
fi
DE=generic
fi
case "$DE" in
kde)
terminal_kde "$command"
;;
gnome*)
terminal_gnome "$command"
;;
xfce)
terminal_xfce "$command"
;;
lxde)
terminal_lxde "$command"
;;
generic)
terminal_generic "$command"
;;
*)
exit_failure_operation_impossible "no terminal emulator available"
;;
esac
|