~ubuntu-branches/ubuntu/wily/xdg-utils/wily

« back to all changes in this revision

Viewing changes to scripts/xdg-terminal.in

  • Committer: Package Import Robot
  • Author(s): Sean Davis
  • Date: 2015-09-13 12:39:10 UTC
  • mfrom: (13.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20150913123910-uba8c1sph2iwnqlr
Tags: 1.1.0~rc3+git20150907-1ubuntu1
* Merge from Debian unstable.  Remaining changes: (LP: #1495273)
  - debian/patches:
    * gnome-3.0.diff: Correctly open preferred browser with 
      gnome-open (LP: #670128)
    * lp779156-lubuntu.diff: Add open_lxde and run_sylpheed function
      for improved LXDE and sylpheed support (LP: #779156)
    * xdg-screensaver-restore-timeout.diff: restore previous X11 
      screensaver timeout when xdg-screensaver resume is used (LP: #1363540)
* New upstream release fixes the following bugs:
  - xdg-mime query filetype does not work on KDE 5 (LP: #1454833)
  - xdg-open doesn't properly detect Xfce/Xubuntu (LP: #1388922)
  - xserver-blanking patch in Ubuntu duplicates code (LP: #1330386)
  - Typo in manpage of 'xdg-icon-resource' (LP: #996304)
  - xdg-open (to gnome-open) fails to launch file:// URL with query string 
    (LP: #396162)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#---------------------------------------------
 
3
#   xdg-terminal
 
4
#
 
5
#   Utility script to open the registered terminal emulator
 
6
#
 
7
#   Refer to the usage() function below for usage.
 
8
#
 
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>
 
12
#
 
13
#   LICENSE:
 
14
#
 
15
#---------------------------------------------
 
16
 
 
17
manualpage()
 
18
{
 
19
cat << _MANUALPAGE
 
20
_MANUALPAGE
 
21
}
 
22
 
 
23
usage()
 
24
{
 
25
cat << _USAGE
 
26
_USAGE
 
27
}
 
28
 
 
29
#@xdg-utils-common@
 
30
 
 
31
terminal_kde()
 
32
{
 
33
    terminal=`kreadconfig --file kdeglobals --group General --key TerminalApplication --default konsole`
 
34
 
 
35
    terminal_exec=`which $terminal 2>/dev/null`
 
36
 
 
37
    if [ -x "$terminal_exec" ]; then
 
38
        if [ x"$1" = x"" ]; then
 
39
            $terminal_exec
 
40
        else
 
41
            $terminal_exec -e "$1"
 
42
        fi
 
43
 
 
44
        if [ $? -eq 0 ]; then
 
45
            exit_success
 
46
        else
 
47
            exit_failure_operation_failed
 
48
        fi
 
49
    else
 
50
        exit_failure_operation_impossible "configured terminal program '$terminal' not found or not executable"
 
51
    fi
 
52
}
 
53
 
 
54
terminal_gnome()
 
55
{
 
56
    term_exec_key="/desktop/gnome/applications/terminal/exec"
 
57
    term_exec_arg_key="/desktop/gnome/applications/terminal/exec_arg"
 
58
 
 
59
    term_exec=`gconftool-2 --get ${term_exec_key}`
 
60
    term_exec_arg=`gconftool-2 --get ${term_exec_arg_key}`
 
61
 
 
62
    terminal_exec=`which $term_exec 2>/dev/null`
 
63
 
 
64
    if [ -x "$terminal_exec" ]; then
 
65
        if [ x"$1" = x"" ]; then
 
66
            $terminal_exec
 
67
        else
 
68
            if [ x"$term_exec_arg" = x"" ]; then
 
69
                $terminal_exec "$1"
 
70
            else
 
71
                $terminal_exec "$term_exec_arg" "$1"
 
72
            fi
 
73
        fi
 
74
 
 
75
        if [ $? -eq 0 ]; then
 
76
            exit_success
 
77
        else
 
78
            exit_failure_operation_failed
 
79
        fi
 
80
    else
 
81
        exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
 
82
    fi
 
83
}
 
84
 
 
85
terminal_gsettings()
 
86
{
 
87
    term_schema="$1"; shift
 
88
 
 
89
    term_exec=`gsettings get ${term_schema} exec`
 
90
    term_exec_arg=`gsettings get ${term_schema} exec-arg`
 
91
 
 
92
    terminal_exec=`which $term_exec 2>/dev/null`
 
93
 
 
94
    if [ -x "$terminal_exec" ]; then
 
95
        if [ x"$1" = x"" ]; then
 
96
            $terminal_exec
 
97
        else
 
98
            if [ x"$term_exec_arg" = x"" ]; then
 
99
                $terminal_exec "$1"
 
100
            else
 
101
                $terminal_exec "$term_exec_arg" "$1"
 
102
            fi
 
103
        fi
 
104
 
 
105
        if [ $? -eq 0 ]; then
 
106
            exit_success
 
107
        else
 
108
            exit_failure_operation_failed
 
109
        fi
 
110
    else
 
111
        exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
 
112
    fi
 
113
}
 
114
 
 
115
terminal_xfce()
 
116
{
 
117
    if [ x"$1" = x"" ]; then
 
118
        exo-open --launch TerminalEmulator
 
119
    else
 
120
        exo-open --launch TerminalEmulator "$1"
 
121
    fi
 
122
 
 
123
    if [ $? -eq 0 ]; then
 
124
        exit_success
 
125
    else
 
126
        exit_failure_operation_failed
 
127
    fi
 
128
}
 
129
 
 
130
terminal_generic()
 
131
{
 
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
 
134
        TERM=xterm
 
135
    fi
 
136
 
 
137
    terminal_exec=`which $TERM 2>/dev/null`
 
138
 
 
139
    if [ -x "$terminal_exec" ]; then
 
140
        if [ x"$1" = x"" ]; then
 
141
            $terminal_exec
 
142
        else
 
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"
 
151
            else
 
152
                $terminal_exec -e "$1"
 
153
            fi
 
154
        fi
 
155
 
 
156
        if [ $? -eq 0 ]; then
 
157
            exit_success
 
158
        else
 
159
            exit_failure_operation_failed
 
160
        fi
 
161
    else
 
162
        exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable"
 
163
    fi
 
164
}
 
165
 
 
166
terminal_lxde()
 
167
{
 
168
    if which lxterminal &>/dev/null; then
 
169
        if [ x"$1" = x"" ]; then
 
170
            lxterminal
 
171
        else
 
172
            lxterminal -e "$1"
 
173
        fi
 
174
    else
 
175
        terminal_generic "$1"
 
176
    fi
 
177
}
 
178
 
 
179
#[ x"$1" != x"" ] || exit_failure_syntax
 
180
 
 
181
command=
 
182
while [ $# -gt 0 ] ; do
 
183
    parm="$1"
 
184
    shift
 
185
 
 
186
    case "$parm" in
 
187
      -*)
 
188
        exit_failure_syntax "unexpected option '$parm'"
 
189
        ;;
 
190
 
 
191
      *)
 
192
        if [ -n "$command" ] ; then
 
193
            exit_failure_syntax "unexpected argument '$parm'"
 
194
        fi
 
195
        command="$parm"
 
196
        ;;
 
197
    esac
 
198
done
 
199
 
 
200
detectDE
 
201
 
 
202
if [ x"$DE" = x"" ]; then
 
203
    DE=generic
 
204
fi
 
205
 
 
206
case "$DE" in
 
207
    kde)
 
208
    terminal_kde "$command"
 
209
    ;;
 
210
 
 
211
    gnome)
 
212
    terminal_gnome "$command"
 
213
    ;;
 
214
 
 
215
    gnome3)
 
216
    terminal_gsettings org.gnome.desktop.default-applications.terminal "$command"
 
217
    ;;
 
218
 
 
219
    cinnamon)
 
220
    terminal_gsettings org.cinnamon.desktop.default-applications.terminal "$command"
 
221
    ;;
 
222
 
 
223
    mate)
 
224
    terminal_gsettings org.mate.applications-terminal "$command"
 
225
    ;;
 
226
 
 
227
    xfce)
 
228
    terminal_xfce "$command"
 
229
    ;;
 
230
 
 
231
    lxde)
 
232
    terminal_lxde "$command"
 
233
    ;;
 
234
 
 
235
    generic)
 
236
    terminal_generic "$command"
 
237
    ;;
 
238
 
 
239
    *)
 
240
    exit_failure_operation_impossible "no terminal emulator available"
 
241
    ;;
 
242
esac