Merge lp:~ochosi/xdg-utils/support_xfce into lp:xdg-utils

Proposed by Simon Steinbeiß on 2014-06-16
Status: Superseded
Proposed branch: lp:~ochosi/xdg-utils/support_xfce
Merge into: lp:xdg-utils
Diff against target: 42444 lines (+41264/-0) (has conflicts)
215 files modified
.gitignore (+3/-0)
.pc/.quilt_patches (+1/-0)
.pc/.quilt_series (+1/-0)
.pc/.version (+1/-0)
.pc/applied-patches (+13/-0)
.pc/bashisms.diff/scripts/xdg-desktop-icon (+561/-0)
.pc/bashisms.diff/scripts/xdg-desktop-menu (+1226/-0)
.pc/bashisms.diff/scripts/xdg-email (+751/-0)
.pc/bashisms.diff/scripts/xdg-icon-resource (+843/-0)
.pc/bashisms.diff/scripts/xdg-mime (+1225/-0)
.pc/bashisms.diff/scripts/xdg-open (+557/-0)
.pc/bashisms.diff/scripts/xdg-screensaver (+984/-0)
.pc/bashisms.diff/scripts/xdg-settings (+874/-0)
.pc/gnome-3.0.diff/scripts/xdg-email (+751/-0)
.pc/gnome-3.0.diff/scripts/xdg-mime (+1225/-0)
.pc/gnome-3.0.diff/scripts/xdg-settings (+874/-0)
.pc/lp779156-lubuntu.diff/scripts/xdg-email (+771/-0)
.pc/lp779156-lubuntu.diff/scripts/xdg-mime (+1294/-0)
.pc/x-www-browser.diff/scripts/xdg-email (+726/-0)
.pc/x-www-browser.diff/scripts/xdg-open (+557/-0)
.pc/xdg-email-envvar.diff/scripts/xdg-email (+726/-0)
.pc/xdg-email-mutt-detect.diff/scripts/xdg-email (+748/-0)
.pc/xdg-mime-follow-symlinks.diff/scripts/xdg-mime (+1215/-0)
.pc/xdg-mime-generic-use-mimetype.diff/scripts/xdg-mime (+1214/-0)
.pc/xdg-open-browser-multiword.diff/scripts/xdg-open (+557/-0)
.pc/xdg-open-printf.diff/scripts/xdg-open (+559/-0)
.pc/xdg-screensaver-dbus.patch/scripts/xdg-screensaver (+984/-0)
.pc/xdg-update-menu-caonicalize-defaults.list.diff/scripts/xdg-desktop-menu (+1226/-0)
.pc/xserver-blanking.diff/scripts/xdg-screensaver (+937/-0)
ChangeLog (+277/-0)
LICENSE (+18/-0)
Makefile (+39/-0)
Makefile.in (+39/-0)
README (+100/-0)
RELEASE_NOTES (+64/-0)
TODO (+25/-0)
configure (+2320/-0)
configure.ac (+13/-0)
debian/NEWS (+12/-0)
debian/changelog (+320/-0)
debian/compat (+1/-0)
debian/control (+36/-0)
debian/copyright (+44/-0)
debian/docs (+3/-0)
debian/gbp.conf (+2/-0)
debian/patches/bashisms.diff (+92/-0)
debian/patches/gnome-3.0.diff (+289/-0)
debian/patches/lp779156-lubuntu.diff (+127/-0)
debian/patches/series (+13/-0)
debian/patches/x-www-browser.diff (+26/-0)
debian/patches/xdg-email-envvar.diff (+52/-0)
debian/patches/xdg-email-mutt-detect.diff (+14/-0)
debian/patches/xdg-mime-follow-symlinks.diff (+34/-0)
debian/patches/xdg-mime-generic-use-mimetype.diff (+45/-0)
debian/patches/xdg-open-browser-multiword.diff (+25/-0)
debian/patches/xdg-open-printf.diff (+20/-0)
debian/patches/xdg-screensaver-dbus.patch (+93/-0)
debian/patches/xdg-update-menu-caonicalize-defaults.list.diff (+29/-0)
debian/patches/xserver-blanking.diff (+68/-0)
debian/rules (+7/-0)
debian/source/format (+1/-0)
debian/watch (+3/-0)
install-sh (+251/-0)
scripts/.gitignore (+1/-0)
scripts/Makefile (+116/-0)
scripts/Makefile.in (+116/-0)
scripts/README (+19/-0)
scripts/html/index.html (+19/-0)
scripts/html/index.html.post (+3/-0)
scripts/html/index.html.pre (+7/-0)
scripts/html/xdg-desktop-icon.html (+133/-0)
scripts/html/xdg-desktop-menu.html (+334/-0)
scripts/html/xdg-email.html (+89/-0)
scripts/html/xdg-icon-resource.html (+128/-0)
scripts/html/xdg-mime.html (+145/-0)
scripts/html/xdg-open.html (+38/-0)
scripts/html/xdg-screensaver.html (+63/-0)
scripts/html/xdg-settings.html (+46/-0)
scripts/man/xdg-desktop-icon.1 (+241/-0)
scripts/man/xdg-desktop-menu.1 (+448/-0)
scripts/man/xdg-email.1 (+199/-0)
scripts/man/xdg-icon-resource.1 (+244/-0)
scripts/man/xdg-mime.1 (+286/-0)
scripts/man/xdg-open.1 (+124/-0)
scripts/man/xdg-screensaver.1 (+154/-0)
scripts/man/xdg-settings.1 (+136/-0)
scripts/xdg-desktop-icon (+561/-0)
scripts/xdg-desktop-menu (+1226/-0)
scripts/xdg-email (+821/-0)
scripts/xdg-icon-resource (+843/-0)
scripts/xdg-mime (+1297/-0)
scripts/xdg-open (+563/-0)
scripts/xdg-screensaver (+1005/-0)
scripts/xdg-settings (+894/-0)
tests/.gitignore (+1/-0)
tests/Makefile (+45/-0)
tests/Makefile.in (+45/-0)
tests/NOTES (+8/-0)
tests/README (+124/-0)
tests/TODO (+23/-0)
tests/debug/README (+5/-0)
tests/debug/t.extraout (+17/-0)
tests/debug/t.failoverride (+17/-0)
tests/debug/t.interactive (+20/-0)
tests/debug/t.nodisplay (+35/-0)
tests/debug/t.var_bleed (+55/-0)
tests/doc_gen.pl (+164/-0)
tests/generic/t.bogus_arg (+25/-0)
tests/generic/t.help (+25/-0)
tests/generic/t.manual (+25/-0)
tests/generic/t.no_arg (+25/-0)
tests/generic/t.version (+26/-0)
tests/icons/red-SVG.svg (+6/-0)
tests/include/desktop_environment (+56/-0)
tests/include/linux_distro (+209/-0)
tests/include/listargs (+10/-0)
tests/include/system_info (+23/-0)
tests/include/tempfile.sh (+47/-0)
tests/include/testassertions.sh (+379/-0)
tests/include/testcontrol.sh (+121/-0)
tests/include/testfuncs.sh (+138/-0)
tests/testrun (+226/-0)
tests/tet_run (+36/-0)
tests/xdg-desktop-icon/data/desktop_icon_install.desktop (+9/-0)
tests/xdg-desktop-icon/t.00-apply_generic (+13/-0)
tests/xdg-desktop-icon/t.01-notexist_file_uninstall (+37/-0)
tests/xdg-desktop-icon/t.02-plain_file_install (+43/-0)
tests/xdg-desktop-icon/t.03-plain_file_uninstall (+40/-0)
tests/xdg-desktop-icon/t.04-desktop_icon_install (+53/-0)
tests/xdg-desktop-icon/t.05-desktop_icon_uninstall (+44/-0)
tests/xdg-desktop-menu/data/menu_install.directory (+3/-0)
tests/xdg-desktop-menu/data/menu_item_category.desktop (+6/-0)
tests/xdg-desktop-menu/data/menu_item_dummy.desktop (+5/-0)
tests/xdg-desktop-menu/data/menu_item_dummy2.desktop (+5/-0)
tests/xdg-desktop-menu/data/menu_item_test.desktop (+5/-0)
tests/xdg-desktop-menu/data/shinythings_example/install-webmirror.sh (+34/-0)
tests/xdg-desktop-menu/data/shinythings_example/webmirror-admin.desktop (+9/-0)
tests/xdg-desktop-menu/data/shinythings_example/webmirror.desktop (+10/-0)
tests/xdg-desktop-menu/data/shinythings_example/webmirror.directory (+7/-0)
tests/xdg-desktop-menu/data/shinythings_example/webmirror.menu (+13/-0)
tests/xdg-desktop-menu/t.00-apply_generic (+13/-0)
tests/xdg-desktop-menu/t.01-menu_user_forceupdate (+24/-0)
tests/xdg-desktop-menu/t.02-menu_system_as_nonroot (+40/-0)
tests/xdg-desktop-menu/t.03-menu_system_forceupdate (+25/-0)
tests/xdg-desktop-menu/t.10-simple_menu_item_user_install (+60/-0)
tests/xdg-desktop-menu/t.12-menu_user_install (+68/-0)
tests/xdg-desktop-menu/t.13-menu_user_uninstall (+61/-0)
tests/xdg-desktop-menu/t.14-menu_install_category (+53/-0)
tests/xdg-desktop-menu/t.15-menu_advanced_install (+87/-0)
tests/xdg-desktop-menu/t.20-simple_menu_item_system_install (+61/-0)
tests/xdg-desktop-menu/t.22-menu_system_install (+67/-0)
tests/xdg-desktop-menu/t.23-menu_system_uninstall (+67/-0)
tests/xdg-email/t.00-apply_generic (+12/-0)
tests/xdg-email/t.10-email_basic (+31/-0)
tests/xdg-email/t.12-email_cc_args (+43/-0)
tests/xdg-email/t.13-email_multi_address (+43/-0)
tests/xdg-email/t.21-email_uri_multi_address (+36/-0)
tests/xdg-email/t.22-email_mix_args_uri (+36/-0)
tests/xdg-email/t.30-email_attach (+38/-0)
tests/xdg-email/t.31-email_attach_full_path (+38/-0)
tests/xdg-email/t.32-email_missing_attach (+34/-0)
tests/xdg-icon-resource/t.apply_generic (+13/-0)
tests/xdg-icon-resource/t.icon_duplicate_install (+42/-0)
tests/xdg-icon-resource/t.icon_nonexist_uninstall (+38/-0)
tests/xdg-icon-resource/t.icon_system_as_nonroot (+42/-0)
tests/xdg-icon-resource/t.icon_system_install (+44/-0)
tests/xdg-icon-resource/t.icon_system_uninstall (+40/-0)
tests/xdg-icon-resource/t.icon_user_install (+40/-0)
tests/xdg-icon-resource/t.icon_user_uninstall (+39/-0)
tests/xdg-mime/data/test2mime.xml (+11/-0)
tests/xdg-mime/data/testmime.xml (+7/-0)
tests/xdg-mime/t.00-apply_generic (+13/-0)
tests/xdg-mime/t.01-query_text_plain (+34/-0)
tests/xdg-mime/t.02-query_missing_file (+30/-0)
tests/xdg-mime/t.03-system_as_nonroot (+50/-0)
tests/xdg-mime/t.10-user_mime_install (+52/-0)
tests/xdg-mime/t.11-user_mime_uninstall (+51/-0)
tests/xdg-mime/t.12-user_install_missing_file (+28/-0)
tests/xdg-mime/t.13-notexist_mime_uninstall (+44/-0)
tests/xdg-mime/t.14-user_mime_install2in1 (+61/-0)
tests/xdg-mime/t.15-user_mime_uninstall2in1 (+66/-0)
tests/xdg-mime/t.20-system_mime_install (+47/-0)
tests/xdg-mime/t.21-system_mime_uninstall (+53/-0)
tests/xdg-mime/t.22-system_install_missing_file (+31/-0)
tests/xdg-mime/t.23-double_mime_install (+48/-0)
tests/xdg-open/t.00-apply_generic (+14/-0)
tests/xdg-open/t.01-open_basic (+35/-0)
tests/xdg-open/t.02-open_dir (+30/-0)
tests/xdg-open/t.03-open_url (+30/-0)
tests/xdg-open/t.04-open_html (+34/-0)
tests/xdg-open/t.05-open_abs_path_html (+34/-0)
tests/xdg-screensaver/t.00-apply_generic (+13/-0)
tests/xdg-screensaver/t.01-screensave_status (+32/-0)
tests/xdg-screensaver/t.02-screensave_suspend_basic (+40/-0)
tests/xdg-screensaver/t.03-screensave_resume_basic (+43/-0)
tests/xdg-screensaver/t.10-screensave_activate (+43/-0)
tests/xdg-screensaver/t.11-screensave_reset (+41/-0)
tests/xdg-screensaver/t.12-screensave_lock (+44/-0)
tests/xdg-su/t.00-apply_generic (+13/-0)
tests/xdg-su/t.01-su_basic_asroot (+29/-0)
tests/xdg-su/t.02-su_basic (+34/-0)
tests/xdg-su/t.03-su_badpass (+30/-0)
tests/xdg-su/t.04-su_no_carg (+24/-0)
tests/xdg-su/t.05-su_no_cflag (+25/-0)
tests/xdg-utils-usecases/data/icon_file.xml (+7/-0)
tests/xdg-utils-usecases/data/icon_test.desktop (+10/-0)
tests/xdg-utils-usecases/data/menu_install.directory (+4/-0)
tests/xdg-utils-usecases/data/menu_item_dummy.desktop (+5/-0)
tests/xdg-utils-usecases/data/mime_launch.desktop (+7/-0)
tests/xdg-utils-usecases/data/mime_launch.sh (+2/-0)
tests/xdg-utils-usecases/data/mime_launch.xml (+7/-0)
tests/xdg-utils-usecases/t.01-default_mime_launch (+77/-0)
tests/xdg-utils-usecases/t.10-file_icon (+85/-0)
tests/xdg-utils-usecases/t.11-desktop_file_icon (+68/-0)
tests/xdg-utils-usecases/t.14-desktop_menu_icon (+66/-0)
Conflict adding file .gitignore.  Moved existing file to .gitignore.moved.
Conflict adding file ChangeLog.  Moved existing file to ChangeLog.moved.
Conflict adding file LICENSE.  Moved existing file to LICENSE.moved.
Conflict adding file Makefile.in.  Moved existing file to Makefile.in.moved.
Conflict adding file README.  Moved existing file to README.moved.
Conflict adding file RELEASE_NOTES.  Moved existing file to RELEASE_NOTES.moved.
Conflict adding file TODO.  Moved existing file to TODO.moved.
Conflict adding file configure.ac.  Moved existing file to configure.ac.moved.
Conflict adding file configure.  Moved existing file to configure.moved.
Conflict adding file install-sh.  Moved existing file to install-sh.moved.
Conflict adding file scripts.  Moved existing file to scripts.moved.
Conflict adding file tests.  Moved existing file to tests.moved.
To merge this branch: bzr merge lp:~ochosi/xdg-utils/support_xfce
Reviewer Review Type Date Requested Status
Sebastien Bacher 2014-06-16 Pending
Review via email: mp+223206@code.launchpad.net

This proposal has been superseded by a proposal from 2014-06-23.

Description of the change

This is a very simple patch that provides a fallback for the Xfce DE. Until 14.04, we used xscreensaver, so there was no special case needed for Xfce. However, now that we're using light-locker, xdg-screensaver should handle the X11 screensaver extension's settings (if XScreenSaver isn't installed or in use).

This simple patch does exactly that. It checks for the "xfce" DE *after* checking for XScreenSaver and then let's xdg-screensaver handle things correctly.

This branch fixes https://bugs.launchpad.net/ubuntu/+source/xdg-utils/+bug/1309744

To post a comment you must log in.
Simon Steinbeiß (ochosi) wrote :

Here goes the upstream bugreport: https://bugs.freedesktop.org/show_bug.cgi?id=80089

Sebastien Bacher (seb128) wrote :

Thanks, could you change the merge target to be lp:ubuntu/xdg-utils? The change seems fine to me, but I see that there is some alternative approch discussion on the upstream bug report, so I'm going to wait a few days to see if things come to an agreement there and use the upstream solution if they get one

lp:~ochosi/xdg-utils/support_xfce updated on 2014-07-16
22. By Simon Steinbeiß on 2014-07-16

Add fallback-mode for Xfce (only gets used if xscreensaver isn't installed/in use)

23. By Simon Steinbeiß on 2014-07-16

Add patch tags

Unmerged revisions

23. By Simon Steinbeiß on 2014-07-16

Add patch tags

22. By Simon Steinbeiß on 2014-07-16

Add fallback-mode for Xfce (only gets used if xscreensaver isn't installed/in use)

21. By Scott Ritchie on 2013-03-20

Mark as Multi-Arch: foreign (Closes: #688681, LP: #1123710)

20. By Daniel Hahler on 2011-10-03

* Use D-Bus API for GNOME screensaver
  - debian/patches/xdg-screensaver-dbus.patch
  - LP: #805386

19. By Jamie Strandboge on 2011-07-13

rename debian/patches/debian-changes-1.1.0~rc1-2ubuntu4 to
lp779156-lubuntu.diff and make DEP-3 compliant. Correctly reference
LP: #779156 so the bug gets auto-closed.

18. By Jonathan Marsden on 2011-05-07

* scripts/xdg-mime:
 - Fix detectDE to detect LXDE.
 - Create ~/.local/share/applications/mimeapps.list when needed in
   non-gnome/kde environments.

* scripts/xdg-email:
 - Fix detectDE to detect LXDE.
 - Added open_lxde shell function, used when LXDE detected.
 - Added run_sylpheed function, used to call sylpheed (LP: 779156).

17. By Kees Cook on 2011-04-08

releasing version 1.1.0~rc1-2ubuntu3

16. By Kees Cook on 2011-04-08

No-change rebuild to correct archive vs bzr tree delta:
lp:~ubuntu-branches/ubuntu/natty/xdg-utils/natty-201104080911
/usr/share/applications/defaults.list symlink. Thanks to Joel Ebel for the

15. By Chris Coulson on 2011-04-08

* Fix LP: #670128 - gnome-open uses firefox while it's not the preferred
  browser. Backport upstream changes to use the x-scheme-handler types
  for checking/setting the default browser/mail client in xdg-settings
  and xdg-email. In addition to this, we fix xdg-mime to get/set
  default mimetype handlers using the users mimeapps.list, rather than
  the defaults.list, which doesn't work anywhere
  - add debian/patches/gnome-3.0.diff
  - update debian/patches/series

14. By Martin Pitt on 2011-03-30

[ Martin Pitt ]
* Add xdg-update-menu-caonicalize-defaults.list.diff: Don't overwrite a
  /usr/share/applications/defaults.list symlink. Thanks to Joe Ebel for the
  original patch! (LP: #703106)

[ Scott Ritchie ]
* debian/patches/xdg-generic-use-mimetype.diff:
  - Update to fallback to generic on Gnome (LP: #602799)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.gitignore'
2--- .gitignore 1970-01-01 00:00:00 +0000
3+++ .gitignore 2014-06-16 08:53:37 +0000
4@@ -0,0 +1,3 @@
5+Makefile
6+config.log
7+config.status
8
9=== renamed file '.gitignore' => '.gitignore.moved'
10=== added directory '.pc'
11=== added file '.pc/.quilt_patches'
12--- .pc/.quilt_patches 1970-01-01 00:00:00 +0000
13+++ .pc/.quilt_patches 2014-06-16 08:53:37 +0000
14@@ -0,0 +1,1 @@
15+debian/patches
16
17=== added file '.pc/.quilt_series'
18--- .pc/.quilt_series 1970-01-01 00:00:00 +0000
19+++ .pc/.quilt_series 2014-06-16 08:53:37 +0000
20@@ -0,0 +1,1 @@
21+series
22
23=== added file '.pc/.version'
24--- .pc/.version 1970-01-01 00:00:00 +0000
25+++ .pc/.version 2014-06-16 08:53:37 +0000
26@@ -0,0 +1,1 @@
27+2
28
29=== added file '.pc/applied-patches'
30--- .pc/applied-patches 1970-01-01 00:00:00 +0000
31+++ .pc/applied-patches 2014-06-16 08:53:37 +0000
32@@ -0,0 +1,13 @@
33+xdg-mime-follow-symlinks.diff
34+x-www-browser.diff
35+xserver-blanking.diff
36+xdg-email-envvar.diff
37+xdg-email-mutt-detect.diff
38+xdg-mime-generic-use-mimetype.diff
39+bashisms.diff
40+xdg-open-browser-multiword.diff
41+xdg-open-printf.diff
42+xdg-update-menu-caonicalize-defaults.list.diff
43+gnome-3.0.diff
44+lp779156-lubuntu.diff
45+xdg-screensaver-dbus.patch
46
47=== added directory '.pc/bashisms.diff'
48=== added directory '.pc/bashisms.diff/scripts'
49=== added file '.pc/bashisms.diff/scripts/xdg-desktop-icon'
50--- .pc/bashisms.diff/scripts/xdg-desktop-icon 1970-01-01 00:00:00 +0000
51+++ .pc/bashisms.diff/scripts/xdg-desktop-icon 2014-06-16 08:53:37 +0000
52@@ -0,0 +1,561 @@
53+#!/bin/sh
54+#---------------------------------------------
55+# xdg-desktop-icon
56+#
57+# Utility script to install desktop items on a Linux desktop.
58+#
59+# Refer to the usage() function below for usage.
60+#
61+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
62+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
63+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
64+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
65+#
66+# LICENSE:
67+#
68+# Permission is hereby granted, free of charge, to any person obtaining a
69+# copy of this software and associated documentation files (the "Software"),
70+# to deal in the Software without restriction, including without limitation
71+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
72+# and/or sell copies of the Software, and to permit persons to whom the
73+# Software is furnished to do so, subject to the following conditions:
74+#
75+# The above copyright notice and this permission notice shall be included
76+# in all copies or substantial portions of the Software.
77+#
78+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
79+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
80+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
81+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
82+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
83+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
84+# OTHER DEALINGS IN THE SOFTWARE.
85+#
86+#---------------------------------------------
87+
88+usage()
89+{
90+cat << _USAGE
91+xdg-desktop-icon - command line tool for (un)installing icons to the desktop
92+
93+Synopsis
94+
95+xdg-desktop-icon install [--novendor] FILE
96+
97+xdg-desktop-icon uninstall FILE
98+
99+xdg-desktop-icon { --help | --manual | --version }
100+
101+_USAGE
102+}
103+
104+manualpage()
105+{
106+cat << _MANUALPAGE
107+Name
108+
109+xdg-desktop-icon - command line tool for (un)installing icons to the desktop
110+
111+Synopsis
112+
113+xdg-desktop-icon install [--novendor] FILE
114+
115+xdg-desktop-icon uninstall FILE
116+
117+xdg-desktop-icon { --help | --manual | --version }
118+
119+Description
120+
121+The xdg-desktop-icon program can be used to install an application launcher or
122+other file on the desktop of the current user.
123+
124+An application launcher is represented by a *.desktop file. Desktop files are
125+defined by the freedesktop.org Desktop Entry Specification. The most important
126+aspects of *.desktop files are summarized below.
127+
128+Commands
129+
130+install
131+ Installs FILE to the desktop of the current user. FILE can be a *.desktop
132+ file or any other type of file.
133+uninstall
134+ Removes FILE from the desktop of the current user.
135+
136+Options
137+
138+--novendor
139+
140+ Normally, xdg-desktop-icon checks to ensure that a *.desktop file to be
141+ installed has a vendor prefix. This option can be used to disable that
142+ check.
143+
144+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
145+ with a dash ("-"). Companies and organizations are encouraged to use a word
146+ or phrase, preferably the organizations name, for which they hold a
147+ trademark as their vendor prefix. The purpose of the vendor prefix is to
148+ prevent name conflicts.
149+
150+--help
151+ Show command synopsis.
152+--manual
153+ Show this manualpage.
154+--version
155+ Show the xdg-utils version information.
156+
157+Desktop Files
158+
159+An application launcher can be added to the desktop by installing a *.desktop
160+file. A *.desktop file consists of a [Desktop Entry] header followed by several
161+Key=Value lines.
162+
163+A *.desktop file can provide a name and description for an application in
164+several different languages. This is done by adding a language code as used by
165+LC_MESSAGES in square brackets behind the Key. This way one can specify
166+different values for the same Key depending on the currently selected language.
167+
168+The following keys are often used:
169+
170+Value=1.0
171+ This is a mandatory field to indicate that the *.desktop file follows the
172+ 1.0 version of the specification.
173+Type=Application
174+ This is a mandatory field that indicates that the *.desktop file describes
175+ an application launcher.
176+Name=Application Name
177+ The name of the application. For example Mozilla
178+GenericName=Generic Name
179+ A generic description of the application. For example Web Browser
180+Comment=Comment
181+ Optional field to specify a tooltip for the application. For example Visit
182+ websites on the Internet
183+Icon=Icon File
184+ The icon to use for the application. This can either be an absolute path to
185+ an image file or an icon-name. If an icon-name is provided an image lookup
186+ by name is done in the user's current icon theme. The xdg-icon-resource
187+ command can be used to install image files into icon themes. The advantage
188+ of using an icon-name instead of an absolute path is that with an icon-name
189+ the application icon can be provided in several different sizes as well as
190+ in several differently themed styles.
191+Exec=Command Line
192+ The command line to start the application. If the application can open
193+ files the %f placeholder should be specified. When a file is dropped on the
194+ application launcher the %f is replaced with the file path of the dropped
195+ file. If multiple files can be specified on the command line the %F
196+ placeholder should be used instead of %f. If the application is able to
197+ open URLs in addition to local files then %u or %U can be used instead of
198+ %f or %F.
199+
200+For a complete oveview of the *.desktop file format please visit http://
201+www.freedesktop.org/wiki/Standards/desktop-entry-spec
202+
203+Environment Variables
204+
205+xdg-desktop-icon honours the following environment variables:
206+
207+XDG_UTILS_DEBUG_LEVEL
208+ Setting this environment variable to a non-zero numerical value makes
209+ xdg-desktop-icon do more verbose reporting on stderr. Setting a higher
210+ value increases the verbosity.
211+
212+Exit Codes
213+
214+An exit code of 0 indicates success while a non-zero exit code indicates
215+failure. The following failure codes can be returned:
216+
217+1
218+ Error in command line syntax.
219+2
220+ One of the files passed on the command line did not exist.
221+3
222+ A required tool could not be found.
223+4
224+ The action failed.
225+5
226+ No permission to read one of the files passed on the command line.
227+
228+See Also
229+
230+xdg-icon-resource(1)
231+
232+Examples
233+
234+The company ShinyThings Inc. has developed an application named "WebMirror" and
235+would like to add a launcher for for on the desktop. The company will use
236+"shinythings" as its vendor id. In order to add the application to the desktop
237+there needs to be a .desktop file for the application:
238+
239+shinythings-webmirror.desktop:
240+
241+ [Desktop Entry]
242+ Encoding=UTF-8
243+ Type=Application
244+
245+ Exec=webmirror
246+ Icon=shinythings-webmirror
247+
248+ Name=WebMirror
249+ Name[nl]=WebSpiegel
250+
251+Now the xdg-desktop-icon tool can be used to add the webmirror.desktop file to
252+the desktop:
253+
254+xdg-desktop-icon install ./shinythings-webmirror.desktop
255+
256+To add a README file to the desktop as well, the following command can be used:
257+
258+xdg-desktop-icon install ./shinythings-README
259+
260+_MANUALPAGE
261+}
262+
263+#@xdg-utils-common@
264+
265+#----------------------------------------------------------------------------
266+# Common utility functions included in all XDG wrapper scripts
267+#----------------------------------------------------------------------------
268+
269+DEBUG()
270+{
271+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
272+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
273+ shift
274+ echo "$@" >&2
275+}
276+
277+#-------------------------------------------------------------
278+# Exit script on successfully completing the desired operation
279+
280+exit_success()
281+{
282+ if [ $# -gt 0 ]; then
283+ echo "$@"
284+ echo
285+ fi
286+
287+ exit 0
288+}
289+
290+
291+#-----------------------------------------
292+# Exit script on malformed arguments, not enough arguments
293+# or missing required option.
294+# prints usage information
295+
296+exit_failure_syntax()
297+{
298+ if [ $# -gt 0 ]; then
299+ echo "xdg-desktop-icon: $@" >&2
300+ echo "Try 'xdg-desktop-icon --help' for more information." >&2
301+ else
302+ usage
303+ echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for additional info."
304+ fi
305+
306+ exit 1
307+}
308+
309+#-------------------------------------------------------------
310+# Exit script on missing file specified on command line
311+
312+exit_failure_file_missing()
313+{
314+ if [ $# -gt 0 ]; then
315+ echo "xdg-desktop-icon: $@" >&2
316+ fi
317+
318+ exit 2
319+}
320+
321+#-------------------------------------------------------------
322+# Exit script on failure to locate necessary tool applications
323+
324+exit_failure_operation_impossible()
325+{
326+ if [ $# -gt 0 ]; then
327+ echo "xdg-desktop-icon: $@" >&2
328+ fi
329+
330+ exit 3
331+}
332+
333+#-------------------------------------------------------------
334+# Exit script on failure returned by a tool application
335+
336+exit_failure_operation_failed()
337+{
338+ if [ $# -gt 0 ]; then
339+ echo "xdg-desktop-icon: $@" >&2
340+ fi
341+
342+ exit 4
343+}
344+
345+#------------------------------------------------------------
346+# Exit script on insufficient permission to read a specified file
347+
348+exit_failure_file_permission_read()
349+{
350+ if [ $# -gt 0 ]; then
351+ echo "xdg-desktop-icon: $@" >&2
352+ fi
353+
354+ exit 5
355+}
356+
357+#------------------------------------------------------------
358+# Exit script on insufficient permission to write a specified file
359+
360+exit_failure_file_permission_write()
361+{
362+ if [ $# -gt 0 ]; then
363+ echo "xdg-desktop-icon: $@" >&2
364+ fi
365+
366+ exit 6
367+}
368+
369+check_input_file()
370+{
371+ if [ ! -e "$1" ]; then
372+ exit_failure_file_missing "file '$1' does not exist"
373+ fi
374+ if [ ! -r "$1" ]; then
375+ exit_failure_file_permission_read "no permission to read file '$1'"
376+ fi
377+}
378+
379+check_vendor_prefix()
380+{
381+ file_label="$2"
382+ [ -n "$file_label" ] || file_label="filename"
383+ file=`basename "$1"`
384+ case "$file" in
385+ [a-zA-Z]*-*)
386+ return
387+ ;;
388+ esac
389+
390+ echo "xdg-desktop-icon: $file_label '$file' does not have a proper vendor prefix" >&2
391+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
392+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
393+ echo "Use --novendor to override or 'xdg-desktop-icon --manual' for additional info." >&2
394+ exit 1
395+}
396+
397+check_output_file()
398+{
399+ # if the file exists, check if it is writeable
400+ # if it does not exists, check if we are allowed to write on the directory
401+ if [ -e "$1" ]; then
402+ if [ ! -w "$1" ]; then
403+ exit_failure_file_permission_write "no permission to write to file '$1'"
404+ fi
405+ else
406+ DIR=`dirname "$1"`
407+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
408+ exit_failure_file_permission_write "no permission to create file '$1'"
409+ fi
410+ fi
411+}
412+
413+#----------------------------------------
414+# Checks for shared commands, e.g. --help
415+
416+check_common_commands()
417+{
418+ while [ $# -gt 0 ] ; do
419+ parm="$1"
420+ shift
421+
422+ case "$parm" in
423+ --help)
424+ usage
425+ echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for additional info."
426+ exit_success
427+ ;;
428+
429+ --manual)
430+ manualpage
431+ exit_success
432+ ;;
433+
434+ --version)
435+ echo "xdg-desktop-icon 1.0.2"
436+ exit_success
437+ ;;
438+ esac
439+ done
440+}
441+
442+check_common_commands "$@"
443+
444+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
445+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
446+ # Be silent
447+ xdg_redirect_output=" > /dev/null 2> /dev/null"
448+else
449+ # All output to stderr
450+ xdg_redirect_output=" >&2"
451+fi
452+
453+#--------------------------------------
454+# Checks for known desktop environments
455+# set variable DE to the desktop environments name, lowercase
456+
457+detectDE()
458+{
459+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
460+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
461+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
462+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
463+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
464+ else DE=""
465+ fi
466+}
467+
468+#----------------------------------------------------------------------------
469+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
470+# It also always returns 1 in KDE 3.4 and earlier
471+# Simply return 0 in such case
472+
473+kfmclient_fix_exit_code()
474+{
475+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
476+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
477+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
478+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
479+ test "$major" -gt 3 && return $1
480+ test "$minor" -gt 5 && return $1
481+ test "$release" -gt 4 && return $1
482+ return 0
483+}
484+
485+[ x"$1" != x"" ] || exit_failure_syntax
486+
487+action=
488+desktop_file=
489+
490+case $1 in
491+ install)
492+ action=install
493+ ;;
494+
495+ uninstall)
496+ action=uninstall
497+ ;;
498+
499+ *)
500+ exit_failure_syntax "unknown command '$1'"
501+ ;;
502+esac
503+
504+shift
505+
506+vendor=true
507+while [ $# -gt 0 ] ; do
508+ parm=$1
509+ shift
510+
511+ case $parm in
512+ --novendor)
513+ vendor=false
514+ ;;
515+
516+ -*)
517+ exit_failure_syntax "unexpected option '$parm'"
518+ ;;
519+
520+ *)
521+ if [ -n "$desktop_file" ] ; then
522+ exit_failure_syntax "unexpected argument '$parm'"
523+ fi
524+ if [ "$action" = "install" ] ; then
525+ check_input_file "$parm"
526+ fi
527+ desktop_file=$parm
528+ ;;
529+ esac
530+done
531+
532+# Shouldn't happen
533+if [ -z "$action" ] ; then
534+ exit_failure_syntax "command argument missing"
535+fi
536+
537+if [ -z "$desktop_file" ] ; then
538+ exit_failure_syntax "FILE argument missing"
539+fi
540+
541+filetype=
542+case "$desktop_file" in
543+ *.desktop)
544+ filetype=desktop
545+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
546+ check_vendor_prefix "$desktop_file"
547+ fi
548+ ;;
549+ *)
550+ filetype=other
551+ ;;
552+esac
553+
554+my_umask=077
555+desktop_dir="$HOME/Desktop"
556+if xdg-user-dir 2>/dev/null 1>&2; then
557+ desktop_dir=`xdg-user-dir DESKTOP`
558+fi
559+desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/null`
560+if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then
561+ desktop_dir_gnome="$HOME"
562+ # Don't create $HOME/Desktop if it doesn't exist
563+ [ -w "$desktop_dir" ] || desktop_dir=
564+fi
565+if [ -n "$desktop_dir_kde" ]; then
566+ if [ ! -d "$desktop_dir_kde" ]; then
567+ save_umask=`umask`
568+ umask $my_umask
569+ mkdir -p "$desktop_dir_kde"
570+ umask $save_umask
571+ fi
572+ # Is the KDE desktop dir != $HOME/Desktop ?
573+ if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; then
574+ # If so, don't create $HOME/Desktop if it doesn't exist
575+ [ -w "$desktop_dir" ] || desktop_dir=
576+ else
577+ desktop_dir_kde=
578+ fi
579+fi
580+
581+basefile=`basename "$desktop_file"`
582+
583+DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gnome"
584+
585+case $action in
586+ install)
587+ save_umask=`umask`
588+ umask $my_umask
589+
590+ for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
591+ if [ -n "$x" ]; then
592+ mkdir -p "$x"
593+ eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output
594+ chmod u+x "$x/$basefile"
595+ fi
596+ done
597+
598+ umask $save_umask
599+ ;;
600+
601+ uninstall)
602+ for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
603+ if [ -n "$x" ]; then
604+ rm -f "$x/$basefile"
605+ fi
606+ done
607+
608+ ;;
609+esac
610+
611+exit_success
612+
613+
614
615=== added file '.pc/bashisms.diff/scripts/xdg-desktop-menu'
616--- .pc/bashisms.diff/scripts/xdg-desktop-menu 1970-01-01 00:00:00 +0000
617+++ .pc/bashisms.diff/scripts/xdg-desktop-menu 2014-06-16 08:53:37 +0000
618@@ -0,0 +1,1226 @@
619+#!/bin/sh
620+#---------------------------------------------
621+# xdg-desktop-menu
622+#
623+# Utility script to install menu items on a Linux desktop.
624+# Refer to the usage() function below for usage.
625+#
626+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
627+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
628+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
629+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
630+#
631+# LICENSE:
632+#
633+# Permission is hereby granted, free of charge, to any person obtaining a
634+# copy of this software and associated documentation files (the "Software"),
635+# to deal in the Software without restriction, including without limitation
636+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
637+# and/or sell copies of the Software, and to permit persons to whom the
638+# Software is furnished to do so, subject to the following conditions:
639+#
640+# The above copyright notice and this permission notice shall be included
641+# in all copies or substantial portions of the Software.
642+#
643+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
644+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
645+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
646+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
647+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
648+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
649+# OTHER DEALINGS IN THE SOFTWARE.
650+#
651+#---------------------------------------------
652+
653+manualpage()
654+{
655+cat << _MANUALPAGE
656+Name
657+
658+xdg-desktop-menu - command line tool for (un)installing desktop menu items
659+
660+Synopsis
661+
662+xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file
663+(s) desktop-file(s)
664+
665+xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s)
666+desktop-file(s)
667+
668+xdg-desktop-menu forceupdate [--mode mode]
669+
670+xdg-desktop-menu { --help | --manual | --version }
671+
672+Description
673+
674+The xdg-desktop-menu program can be used to install new menu entries to the
675+desktop's application menu.
676+
677+The application menu works according to the XDG Desktop Menu Specification at
678+http://www.freedesktop.org/Standards/menu-spec
679+
680+Commands
681+
682+install
683+
684+ Install one or more applications in a submenu of the desktop menu system.
685+
686+ desktop-file: A desktop file represents a single menu entry in the menu.
687+ Desktop files are defined by the freedesktop.org Desktop Entry
688+ Specification. The most important aspects of *.desktop files are summarized
689+ below.
690+
691+ Menu entries can be added to the menu system in two different ways. They
692+ can either be added to a predefined submenu in the menu system based on one
693+ or more category keywords, or they can be added to a new submenu.
694+
695+ To add a menu entry to a predefined submenu the desktop file that
696+ represents the menu entry must have a Categories= entry that lists one or
697+ more keywords. The menu item will be included in an appropriate submenu
698+ based on the included keywords.
699+
700+ To add menu items to a new submenu the desktop-files must be preceded by a
701+ directory-file that describes the submenu. If multiple desktop-files are
702+ specified, all entries will be added to the same menu. If entries are
703+ installed to a menu that has been created with a previous call to
704+ xdg-desktop-menu the entries will be installed in addition to any already
705+ existing entries.
706+
707+ directory-file: The *.directory file indicated by directory-file represents
708+ a submenu. The directory file provides the name and icon for a submenu. The
709+ name of the directory file is used to identify the submenu.
710+
711+ If multiple directory files are provided each file will represent a submenu
712+ within the menu that preceeds it, creating a nested menu hierarchy
713+ (sub-sub-menus). The menu entries themselves will be added to the last
714+ submenu.
715+
716+ Directory files follow the syntax defined by the freedesktop.org Desktop
717+ Entry Specification.
718+
719+uninstall
720+
721+ Remove applications or submenus from the desktop menu system previously
722+ installed with xdg-desktop-menu install.
723+
724+ A submenu and the associated directory file is only removed when the
725+ submenu no longer contains any menu entries.
726+
727+forceupdate
728+
729+ Force an update of the menu system.
730+
731+ This command is only useful if the last call to xdg-desktop-menu included
732+ the --noupdate option.
733+
734+Options
735+
736+--noupdate
737+ Postpone updating the menu system. If multiple updates to the menu system
738+ are made in sequence this flag can be used to indicate that additional
739+ changes will follow and that it is not necassery to update the menu system
740+ right away.
741+--novendor
742+
743+ Normally, xdg-desktop-menu checks to ensure that any *.directory and
744+ *.desktop files to be installed has a vendor prefix. This option can be
745+ used to disable that check.
746+
747+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
748+ with a dash ("-"). Companies and organizations are encouraged to use a word
749+ or phrase, preferably the organizations name, for which they hold a
750+ trademark as their vendor prefix. The purpose of the vendor prefix is to
751+ prevent name conflicts.
752+
753+--mode mode
754+
755+ mode can be user or system. In user mode the file is (un)installed for the
756+ current user only. In system mode the file is (un)installed for all users
757+ on the system. Usually only root is allowed to install in system mode.
758+
759+ The default is to use system mode when called by root and to use user mode
760+ when called by a non-root user.
761+
762+--help
763+ Show command synopsis.
764+--manual
765+ Show this manualpage.
766+--version
767+ Show the xdg-utils version information.
768+
769+Desktop Files
770+
771+An application item in the application menu is represented by a *.desktop file.
772+A *.desktop file consists of a [Desktop Entry] header followed by several Key=
773+Value lines.
774+
775+A *.desktop file can provide a name and description for an application in
776+several different languages. This is done by adding a language code as used by
777+LC_MESSAGES in square brackets behind the Key. This way one can specify
778+different values for the same Key depending on the currently selected language.
779+
780+The following keys are often used:
781+
782+Value=1.0
783+ This is a mandatory field to indicate that the *.desktop file follows the
784+ 1.0 version of the specification.
785+Type=Application
786+ This is a mandatory field that indicates that the *.desktop file describes
787+ an application launcher.
788+Name=Application Name
789+ The name of the application. For example Mozilla
790+GenericName=Generic Name
791+ A generic description of the application. For example Web Browser
792+Comment=Comment
793+ Optional field to specify a tooltip for the application. For example Visit
794+ websites on the Internet
795+Icon=Icon File
796+ The icon to use for the application. This can either be an absolute path to
797+ an image file or an icon-name. If an icon-name is provided an image lookup
798+ by name is done in the user's current icon theme. The xdg-icon-resource
799+ command can be used to install image files into icon themes. The advantage
800+ of using an icon-name instead of an absolute path is that with an icon-name
801+ the application icon can be provided in several different sizes as well as
802+ in several differently themed styles.
803+Exec=Command Line
804+ The command line to start the application. If the application can open
805+ files the %f placeholder should be specified. When a file is dropped on the
806+ application launcher the %f is replaced with the file path of the dropped
807+ file. If multiple files can be specified on the command line the %F
808+ placeholder should be used instead of %f. If the application is able to
809+ open URLs in addition to local files then %u or %U can be used instead of
810+ %f or %F.
811+Categories=Categories
812+
813+ A list of categories separated by semi-colons. A category is a keyword that
814+ describes and classifies the application. By default applications are
815+ organized in the application menu based on category. When menu entries are
816+ explicitly assigned to a new submenu it is not necassery to list any
817+ categories.
818+
819+ When using categories it is recommended to include one of the following
820+ categories: AudioVideo, Development, Education, Game, Graphics, Network,
821+ Office, Settings, System, Utility.
822+
823+ See Appendix A of the XDG Desktop Menu Specification for information about
824+ additional categories. http://standards.freedesktop.org/menu-spec/
825+ menu-spec-1.0.html
826+
827+MimeType=Mimetypes
828+ A list of mimetypes separated by semi-colons. This field is used to
829+ indicate which file types the application is able to open.
830+
831+For a complete oveview of the *.desktop file format please visit http://
832+www.freedesktop.org/wiki/Standards/desktop-entry-spec
833+
834+Directory Files
835+
836+The appearance of submenu in the application menu is provided by a *.directory
837+file. In particular it provides the title of the submenu and a possible icon. A
838+*.directory file consists of a [Desktop Entry] header followed by several Key=
839+Value lines.
840+
841+A *.directory file can provide a title (name) for the submenu in several
842+different languages. This is done by adding a language code as used by
843+LC_MESSAGES in square brackets behind the Key. This way one can specify
844+different values for the same Key depending on the currently selected language.
845+
846+The following keys are relevqnt for submenus:
847+
848+Value=1.0
849+ This is a mandatory field to indicate that the *.directory file follows the
850+ 1.0 version of the Desktop Entry specification.
851+Type=Directory
852+ This is a mandatory field that indicates that the *.directory file
853+ describes a submenu.
854+Name=Menu Name
855+ The title of submenu. For example Mozilla
856+Comment=Comment
857+ Optional field to specify a tooltip for the submenu.
858+Icon=Icon File
859+ The icon to use for the submenu. This can either be an absolute path to an
860+ image file or an icon-name. If an icon-name is provided an image lookup by
861+ name is done in the user's current icon theme. The xdg-icon-resource
862+ command can be used to install image files into icon themes. The advantage
863+ of using an icon-name instead of an absolute path is that with an icon-name
864+ the submenu icon can be provided in several different sizes as well as in
865+ several differently themed styles.
866+
867+Environment Variables
868+
869+xdg-desktop-menu honours the following environment variables:
870+
871+XDG_UTILS_DEBUG_LEVEL
872+ Setting this environment variable to a non-zero numerical value makes
873+ xdg-desktop-menu do more verbose reporting on stderr. Setting a higher
874+ value increases the verbosity.
875+XDG_UTILS_INSTALL_MODE
876+ This environment variable can be used by the user or administrator to
877+ override the installation mode. Valid values are user and system.
878+
879+Exit Codes
880+
881+An exit code of 0 indicates success while a non-zero exit code indicates
882+failure. The following failure codes can be returned:
883+
884+1
885+ Error in command line syntax.
886+2
887+ One of the files passed on the command line did not exist.
888+3
889+ A required tool could not be found.
890+4
891+ The action failed.
892+5
893+ No permission to read one of the files passed on the command line.
894+
895+See Also
896+
897+xdg-desktop-icon(1), xdg-icon-resource(1), xdg-mime(1)
898+
899+Examples
900+
901+The company ShinyThings Inc. has developed an application named "WebMirror" and
902+would like to add it to the application menu. The company will use
903+"shinythings" as its vendor id. In order to add the application to the menu
904+there needs to be a .desktop file with a suitable Categories entry:
905+
906+shinythings-webmirror.desktop:
907+
908+ [Desktop Entry]
909+ Encoding=UTF-8
910+ Type=Application
911+
912+ Exec=webmirror
913+ Icon=webmirror
914+
915+ Name=WebMirror
916+ Name[nl]=WebSpiegel
917+
918+ Categories=Network;WebDevelopment;
919+
920+Now the xdg-desktop-menu tool can be used to add the
921+shinythings-webmirror.desktop file to the desktop application menu:
922+
923+xdg-desktop-menu install ./shinythings-webmirror.desktop
924+
925+Note that for the purpose of this example the menu items are available in two
926+languages, English and Dutch. The language code for Dutch is nl.
927+
928+In the next example the company ShinyThings Inc. will add its own submenu to
929+the desktop application menu consisting of a "WebMirror" menu item and a
930+"WebMirror Admin Tool" menu item.
931+
932+First the company needs to create two .desktop files that describe the two menu
933+items. Since the items are to be added to a new submenu it is not necassery to
934+include a Categories= line:
935+
936+shinythings-webmirror.desktop:
937+
938+ [Desktop Entry]
939+ Encoding=UTF-8
940+ Type=Application
941+
942+ Exec=webmirror
943+ Icon=shinythings-webmirror
944+
945+ Name=WebMirror
946+ Name[nl]=WebSpiegel
947+
948+
949+shinythings-webmirror-admin.desktop:
950+
951+ [Desktop Entry]
952+ Encoding=UTF-8
953+ Type=Application
954+
955+ Exec=webmirror-admintool
956+ Icon=shinythings-webmirror-admintool
957+
958+ Name=WebMirror Admin Tool
959+ Name[nl]=WebSpiegel Administratie Tool
960+
961+In addition a .directory file needs to be created to provide a title and icon
962+for the sub-menu itself:
963+
964+shinythings-webmirror.directory:
965+
966+ [Desktop Entry]
967+ Encoding=UTF-8
968+
969+ Icon=shinythings-webmirror-menu
970+
971+ Name=WebMirror
972+ Name[nl]=WebSpiegel
973+
974+These file can now be installed with:
975+
976+xdg-desktop-menu install ./shinythings-webmirror.directory \
977+ ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop
978+
979+The menu entries could also be installed one by one:
980+
981+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
982+ ./shinythings-webmirror.desktop
983+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
984+ ./shinythings-webmirror-admin.desktop
985+xdg-desktop-menu forceupdate
986+
987+Although the result is the same it is slightly more efficient to install all
988+files at the same time.
989+
990+The *.desktop and *.directory files reference icons with the names webmirror,
991+webmirror-admin and webmirror-menu which should also be installed. In this
992+example the icons are installed in two different sizes, once with a size of
993+22x22 pixels and once with a size of 64x64 pixels:
994+
995+xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror
996+xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu
997+xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin
998+xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror
999+xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu
1000+xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin
1001+
1002+_MANUALPAGE
1003+}
1004+
1005+usage()
1006+{
1007+cat << _USAGE
1008+xdg-desktop-menu - command line tool for (un)installing desktop menu items
1009+
1010+Synopsis
1011+
1012+xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file
1013+(s) desktop-file(s)
1014+
1015+xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s)
1016+desktop-file(s)
1017+
1018+xdg-desktop-menu forceupdate [--mode mode]
1019+
1020+xdg-desktop-menu { --help | --manual | --version }
1021+
1022+_USAGE
1023+}
1024+
1025+#@xdg-utils-common@
1026+
1027+#----------------------------------------------------------------------------
1028+# Common utility functions included in all XDG wrapper scripts
1029+#----------------------------------------------------------------------------
1030+
1031+DEBUG()
1032+{
1033+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
1034+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
1035+ shift
1036+ echo "$@" >&2
1037+}
1038+
1039+#-------------------------------------------------------------
1040+# Exit script on successfully completing the desired operation
1041+
1042+exit_success()
1043+{
1044+ if [ $# -gt 0 ]; then
1045+ echo "$@"
1046+ echo
1047+ fi
1048+
1049+ exit 0
1050+}
1051+
1052+
1053+#-----------------------------------------
1054+# Exit script on malformed arguments, not enough arguments
1055+# or missing required option.
1056+# prints usage information
1057+
1058+exit_failure_syntax()
1059+{
1060+ if [ $# -gt 0 ]; then
1061+ echo "xdg-desktop-menu: $@" >&2
1062+ echo "Try 'xdg-desktop-menu --help' for more information." >&2
1063+ else
1064+ usage
1065+ echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info."
1066+ fi
1067+
1068+ exit 1
1069+}
1070+
1071+#-------------------------------------------------------------
1072+# Exit script on missing file specified on command line
1073+
1074+exit_failure_file_missing()
1075+{
1076+ if [ $# -gt 0 ]; then
1077+ echo "xdg-desktop-menu: $@" >&2
1078+ fi
1079+
1080+ exit 2
1081+}
1082+
1083+#-------------------------------------------------------------
1084+# Exit script on failure to locate necessary tool applications
1085+
1086+exit_failure_operation_impossible()
1087+{
1088+ if [ $# -gt 0 ]; then
1089+ echo "xdg-desktop-menu: $@" >&2
1090+ fi
1091+
1092+ exit 3
1093+}
1094+
1095+#-------------------------------------------------------------
1096+# Exit script on failure returned by a tool application
1097+
1098+exit_failure_operation_failed()
1099+{
1100+ if [ $# -gt 0 ]; then
1101+ echo "xdg-desktop-menu: $@" >&2
1102+ fi
1103+
1104+ exit 4
1105+}
1106+
1107+#------------------------------------------------------------
1108+# Exit script on insufficient permission to read a specified file
1109+
1110+exit_failure_file_permission_read()
1111+{
1112+ if [ $# -gt 0 ]; then
1113+ echo "xdg-desktop-menu: $@" >&2
1114+ fi
1115+
1116+ exit 5
1117+}
1118+
1119+#------------------------------------------------------------
1120+# Exit script on insufficient permission to write a specified file
1121+
1122+exit_failure_file_permission_write()
1123+{
1124+ if [ $# -gt 0 ]; then
1125+ echo "xdg-desktop-menu: $@" >&2
1126+ fi
1127+
1128+ exit 6
1129+}
1130+
1131+check_input_file()
1132+{
1133+ if [ ! -e "$1" ]; then
1134+ exit_failure_file_missing "file '$1' does not exist"
1135+ fi
1136+ if [ ! -r "$1" ]; then
1137+ exit_failure_file_permission_read "no permission to read file '$1'"
1138+ fi
1139+}
1140+
1141+check_vendor_prefix()
1142+{
1143+ file_label="$2"
1144+ [ -n "$file_label" ] || file_label="filename"
1145+ file=`basename "$1"`
1146+ case "$file" in
1147+ [a-zA-Z]*-*)
1148+ return
1149+ ;;
1150+ esac
1151+
1152+ echo "xdg-desktop-menu: $file_label '$file' does not have a proper vendor prefix" >&2
1153+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
1154+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
1155+ echo "Use --novendor to override or 'xdg-desktop-menu --manual' for additional info." >&2
1156+ exit 1
1157+}
1158+
1159+check_output_file()
1160+{
1161+ # if the file exists, check if it is writeable
1162+ # if it does not exists, check if we are allowed to write on the directory
1163+ if [ -e "$1" ]; then
1164+ if [ ! -w "$1" ]; then
1165+ exit_failure_file_permission_write "no permission to write to file '$1'"
1166+ fi
1167+ else
1168+ DIR=`dirname "$1"`
1169+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
1170+ exit_failure_file_permission_write "no permission to create file '$1'"
1171+ fi
1172+ fi
1173+}
1174+
1175+#----------------------------------------
1176+# Checks for shared commands, e.g. --help
1177+
1178+check_common_commands()
1179+{
1180+ while [ $# -gt 0 ] ; do
1181+ parm="$1"
1182+ shift
1183+
1184+ case "$parm" in
1185+ --help)
1186+ usage
1187+ echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info."
1188+ exit_success
1189+ ;;
1190+
1191+ --manual)
1192+ manualpage
1193+ exit_success
1194+ ;;
1195+
1196+ --version)
1197+ echo "xdg-desktop-menu 1.0.2"
1198+ exit_success
1199+ ;;
1200+ esac
1201+ done
1202+}
1203+
1204+check_common_commands "$@"
1205+
1206+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
1207+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
1208+ # Be silent
1209+ xdg_redirect_output=" > /dev/null 2> /dev/null"
1210+else
1211+ # All output to stderr
1212+ xdg_redirect_output=" >&2"
1213+fi
1214+
1215+#--------------------------------------
1216+# Checks for known desktop environments
1217+# set variable DE to the desktop environments name, lowercase
1218+
1219+detectDE()
1220+{
1221+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
1222+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
1223+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
1224+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
1225+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
1226+ else DE=""
1227+ fi
1228+}
1229+
1230+#----------------------------------------------------------------------------
1231+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
1232+# It also always returns 1 in KDE 3.4 and earlier
1233+# Simply return 0 in such case
1234+
1235+kfmclient_fix_exit_code()
1236+{
1237+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
1238+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
1239+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
1240+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
1241+ test "$major" -gt 3 && return $1
1242+ test "$minor" -gt 5 && return $1
1243+ test "$release" -gt 4 && return $1
1244+ return 0
1245+}
1246+
1247+update_desktop_database()
1248+{
1249+# echo Update desktop database: $mode
1250+ if [ "$mode" = "system" ] ; then
1251+ for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do
1252+ if [ -x $x/update-desktop-database ] ; then
1253+ DEBUG 1 "Running $x/update-desktop-database"
1254+ eval '$x/update-desktop-database'$xdg_redirect_output
1255+ return
1256+ fi
1257+ done
1258+ fi
1259+}
1260+
1261+# Make application $1/$2 the default for all the mimetypes it support,
1262+# iff such mimetype didn't had a default application already.
1263+# $1 Install dir for desktop file
1264+# $2 base name of desktop file
1265+make_lazy_default()
1266+{
1267+ local mimetypes
1268+ local xdg_user_dir
1269+ local xdg_default_dirs
1270+
1271+ DEBUG 1 "make_lazy_default $1/$2"
1272+ mimetypes=`awk '
1273+{
1274+ if (match($0,/MimeType=/)) {
1275+ split(substr($0,RSTART+9),mimetypes,";")
1276+ for (n in mimetypes)
1277+ {
1278+ if (mimetypes[n])
1279+ print mimetypes[n]
1280+ }
1281+ }
1282+}' "$1/$2" 2> /dev/null`
1283+
1284+ for MIME in $mimetypes ; do
1285+ xdg_default_dirs="$XDG_DATA_DIRS"
1286+ [ -n "$xdg_default_dirs" ] || xdg_default_dirs=/usr/local/share/:/usr/share/
1287+ if [ x"$mode" = x"user" ] ; then
1288+ xdg_user_dir="$XDG_DATA_HOME"
1289+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
1290+ xdg_default_dirs="$xdg_user_dir:$xdg_default_dirs"
1291+ fi
1292+ local default_app
1293+ for x in `echo "$xdg_default_dirs" | sed 's/:/ /g'`; do
1294+ DEBUG 2 "Checking $x/applications/defaults.list"
1295+ default_app=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2`
1296+ if [ -n "$default_app" ] ; then
1297+ DEBUG 2 "Found default apps for $MIME: $default_app"
1298+ default_app="$default_app;"
1299+ break;
1300+ fi
1301+ done
1302+ DEBUG 2 "Current default apps for $MIME: $default_app"
1303+ if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then
1304+ # App already listed as default
1305+ continue;
1306+ fi
1307+ default_file="$1/defaults.list"
1308+ DEBUG 1 "Updating $default_file"
1309+ grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null
1310+ if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then
1311+ echo "[Default Applications]" >> ${default_file}.new
1312+ fi
1313+ echo $MIME="$default_app$2" >> ${default_file}.new
1314+ mv ${default_file}.new $default_file
1315+ done
1316+}
1317+
1318+update_submenu()
1319+{
1320+ DEBUG 1 "update_submenu $1"
1321+ menu_file="$1"
1322+
1323+ xdg_dir_name=menus
1324+ xdg_user_dir="$XDG_CONFIG_HOME"
1325+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.config"
1326+ xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
1327+
1328+ xdg_system_dirs="$XDG_CONFIG_DIRS"
1329+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/etc/xdg
1330+ xdg_global_dir=
1331+ for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
1332+ if [ -w $x/$xdg_dir_name ] ; then
1333+ xdg_global_dir="$x/$xdg_dir_name"
1334+ break
1335+ fi
1336+ done
1337+ xdg_user_dir="$xdg_user_dir/applications-merged"
1338+ xdg_global_dir="$xdg_global_dir/applications-merged"
1339+
1340+ DEBUG 3 "Install locations for *.menu file:"
1341+ DEBUG 3 "xdg_user_dir: $xdg_user_dir"
1342+ DEBUG 3 "xdg_global_dir: $xdg_global_dir"
1343+ DEBUG 3 "kde_user_dir: $kde_user_dir"
1344+ DEBUG 3 "kde_global_dir: $kde_global_dir"
1345+ DEBUG 3 "gnome_user_dir: $gnome_user_dir"
1346+ DEBUG 3 "gnome_global_dir: $gnome_global_dir"
1347+
1348+ if [ x"$mode" = x"user" ] ; then
1349+ xdg_dir="$xdg_user_dir"
1350+ kde_dir="$kde_user_dir"
1351+ gnome_dir="$gnome_user_dir"
1352+ my_umask=077
1353+ my_chmod=0600
1354+ else
1355+ xdg_dir="$xdg_global_dir"
1356+ kde_dir="$kde_global_dir"
1357+ gnome_dir="$gnome_global_dir"
1358+ my_umask=022
1359+ my_chmod=0644
1360+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
1361+ exit_failure_operation_impossible "No writable system menu directory found."
1362+ fi
1363+ fi
1364+
1365+ if [ -z "$menu_file" ] ; then
1366+ # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications
1367+ save_umask=`umask`
1368+ umask $my_umask
1369+
1370+ mkdir -p $xdg_dir
1371+ touch $xdg_dir/xdg-desktop-menu-dummy.menu
1372+
1373+ umask $save_umask
1374+ return
1375+ fi
1376+
1377+ if [ $action = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then
1378+ # Work around for Debian Gnome
1379+ gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'`
1380+ if [ ! -e "$gnome_xdg_dir" ] ; then
1381+ DEBUG 1 "Debian Workaround: Link '$xdg_dir' to '$gnome_xdg_dir'"
1382+ mkdir -p `dirname "$gnome_xdg_dir"`
1383+ eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output
1384+ fi
1385+ fi
1386+ if [ $action = "install" -a -f "/etc/mandrake-release" ] ; then
1387+ # Work around for Mandriva 2006
1388+ mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'`
1389+ if [ ! -e "$mandrake_xdg_dir" ] ; then
1390+ DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'"
1391+ mkdir -p `dirname "$mandrake_xdg_dir"`
1392+ eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output
1393+ fi
1394+ fi
1395+ if [ $action = "install" -a x"$mode" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then
1396+ # Work around for Fedora Core 5 + patched KDE
1397+ kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
1398+ if [ ! -e "$kde_xdg_dir" ] ; then
1399+ DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'"
1400+ mkdir -p `dirname "$kde_xdg_dir"`
1401+ eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output
1402+ fi
1403+ fi
1404+ if [ $action = "install" -a x"$mode" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then
1405+ # Work around for Kubuntu 6.06
1406+ kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
1407+ DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'"
1408+ eval 'ln -s "kde-applications-merged" "$xdg_dir"'$xdg_redirect_output
1409+ fi
1410+
1411+ orig_menu_file=$xdg_dir/$menu_file
1412+
1413+ DEBUG 1 "Updating $orig_menu_file ($action)"
1414+
1415+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
1416+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
1417+ orig_desktop_files=
1418+ if [ -r "$orig_menu_file" ] ; then
1419+ awk '
1420+# List all files within <Filename> tags
1421+BEGIN {
1422+ RS="<"
1423+}
1424+/^Filename/ {
1425+ if (match($0,/>/)) {
1426+ print substr($0,RSTART+1)
1427+ }
1428+}' $orig_menu_file > $tmpfile
1429+ fi
1430+
1431+ orig_desktop_files=`cat $tmpfile`
1432+ new_desktop_files=
1433+ if [ $action = "install" ] ; then
1434+ for desktop_file in $desktop_files; do
1435+ basefile=`basename "$desktop_file"`
1436+ if ! grep '^'$basefile'$' $tmpfile > /dev/null 2> /dev/null ; then
1437+ # Append
1438+ echo "$basefile" >> $tmpfile
1439+ fi
1440+ done
1441+ new_desktop_files=`cat $tmpfile`
1442+ fi
1443+ if [ $action = "uninstall" ] ; then
1444+ echo > $tmpfile
1445+ for desktop_file in $desktop_files; do
1446+ echo "$desktop_file" >> $tmpfile
1447+ done
1448+ # Files to uninstall are listed in $tmpfile
1449+ # Existing files are in $orig_desktop_files
1450+ for desktop_file in $orig_desktop_files; do
1451+ if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then
1452+ # Keep this file, it's not in the uninstall list
1453+ new_desktop_files="$new_desktop_files $desktop_file"
1454+ fi
1455+ done
1456+ fi
1457+ rm -f "$tmpfile"
1458+
1459+ DEBUG 3 "Files to list in $menu_file: $new_desktop_files"
1460+
1461+ if [ -n "$new_desktop_files" ] ; then
1462+ # Install/update
1463+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
1464+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
1465+ (
1466+ echo '<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"'
1467+ echo ' "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">'
1468+ echo '<!-- Do not edit manually - generated and managed by xdg-desktop-menu -->'
1469+ echo '<Menu>'
1470+ echo ' <Name>Applications</Name>'
1471+
1472+ for desktop_file in $directory_files; do
1473+ basefile=`basename "$desktop_file"`
1474+ basefilename=`echo "$basefile"|cut -d '.' -f 1`
1475+ echo "<Menu>"
1476+ echo " <Name>$basefilename</Name>"
1477+ echo " <Directory>$basefile</Directory>"
1478+ done
1479+
1480+ echo " <Include>"
1481+ for desktop_file in $new_desktop_files; do
1482+ echo " <Filename>$desktop_file</Filename>"
1483+ done
1484+ echo " </Include>"
1485+
1486+ for desktop_file in $directory_files; do
1487+ echo "</Menu>"
1488+ done
1489+
1490+ echo '</Menu>'
1491+ ) > $tmpfile
1492+ chmod $my_chmod $tmpfile
1493+
1494+ save_umask=`umask`
1495+ umask $my_umask
1496+
1497+ mkdir -p $xdg_dir
1498+ eval 'cp $tmpfile $xdg_dir/$menu_file'$xdg_redirect_output
1499+
1500+ umask $save_umask
1501+ rm -f "$tmpfile"
1502+ else
1503+ # Uninstall
1504+ rm -f $xdg_dir/$menu_file
1505+ fi
1506+
1507+ # Uninstall .directory files only if no longer referenced
1508+ if [ $action = "uninstall" ] ; then
1509+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
1510+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
1511+ for menu_file in $xdg_dir/*; do
1512+ if grep 'generated and managed by xdg-desktop-menu' $menu_file > /dev/null 2> /dev/null; then
1513+ awk '
1514+# List all files within <Directory> tags
1515+BEGIN {
1516+ RS="<"
1517+}
1518+/^Directory/ {
1519+ if (match($0,/>/)) {
1520+ print substr($0,RSTART+1)
1521+ }
1522+}' $menu_file >> $tmpfile
1523+ fi
1524+ done
1525+ orig_directory_files="$directory_files"
1526+ directory_files=
1527+ for desktop_file in $orig_directory_files; do
1528+ if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then
1529+ # No longer in use, safe to delete
1530+ directory_files="$directory_files $desktop_file"
1531+ fi
1532+ done
1533+ rm -f "$tmpfile"
1534+ fi
1535+}
1536+
1537+
1538+[ x"$1" != x"" ] || exit_failure_syntax
1539+
1540+mode=
1541+action=
1542+update=yes
1543+desktop_files=
1544+directory_files=
1545+
1546+case $1 in
1547+ install)
1548+ action=install
1549+ ;;
1550+
1551+ uninstall)
1552+ action=uninstall
1553+ ;;
1554+
1555+ forceupdate)
1556+ action=forceupdate
1557+ ;;
1558+
1559+ *)
1560+ exit_failure_syntax "unknown command '$1'"
1561+ ;;
1562+esac
1563+
1564+shift
1565+
1566+vendor=true
1567+while [ $# -gt 0 ] ; do
1568+ parm="$1"
1569+ shift
1570+
1571+ case "$parm" in
1572+ --noupdate)
1573+ update=no
1574+ ;;
1575+
1576+ --mode)
1577+ if [ -z "$1" ] ; then
1578+ exit_failure_syntax "mode argument missing for --mode"
1579+ fi
1580+ case "$1" in
1581+ user)
1582+ mode="user"
1583+ ;;
1584+
1585+ system)
1586+ mode="system"
1587+ ;;
1588+
1589+ *)
1590+ exit_failure_syntax "unknown mode '$1'"
1591+ ;;
1592+ esac
1593+ shift
1594+ ;;
1595+
1596+ --novendor)
1597+ vendor=false
1598+ ;;
1599+
1600+ -*)
1601+ exit_failure_syntax "unexpected option '$parm'"
1602+ ;;
1603+
1604+ *)
1605+ if [ "$action" = "install" ] ; then
1606+ check_input_file "$parm"
1607+ fi
1608+ case "$parm" in
1609+ *.directory)
1610+ if [ -n "$desktop_files" ] ; then
1611+ exit_failure_syntax "'$parm' must preceed any *.desktop file"
1612+ fi
1613+ directory_files="$directory_files $parm"
1614+ ;;
1615+ *.desktop)
1616+ desktop_files="$desktop_files $parm"
1617+ ;;
1618+ *)
1619+ exit_failure_syntax "file to $action must be a *.directory or *.desktop file"
1620+ ;;
1621+ esac
1622+ ;;
1623+ esac
1624+done
1625+
1626+# Shouldn't happen
1627+if [ -z "$action" ] ; then
1628+ exit_failure_syntax "command argument missing"
1629+fi
1630+
1631+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
1632+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
1633+ mode="system"
1634+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
1635+ mode="user"
1636+ fi
1637+fi
1638+
1639+if [ -z "$mode" ] ; then
1640+ if [ `whoami` = "root" ] ; then
1641+ mode="system"
1642+ else
1643+ mode="user"
1644+ fi
1645+fi
1646+
1647+if [ x"$action" = x"forceupdate" ] ; then
1648+ update_desktop_database
1649+ exit_success
1650+fi
1651+
1652+if [ -z "$desktop_files" ] ; then
1653+ exit_failure_syntax "desktop-file argument missing"
1654+fi
1655+
1656+menu_name=
1657+for desktop_file in $directory_files; do
1658+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
1659+ check_vendor_prefix "$desktop_file"
1660+ fi
1661+
1662+ basefilename=`basename "$desktop_file" | cut -d '.' -f 1`
1663+ if [ -z "$menu_name" ] ; then
1664+ menu_name="$basefilename"
1665+ else
1666+ menu_name="$menu_name-$basefilename"
1667+ fi
1668+done
1669+
1670+if [ -n "$menu_name" ] ; then
1671+ if [ x"$mode" = x"user" ] ; then
1672+ update_submenu "user-$menu_name.menu"
1673+ else
1674+ update_submenu "$menu_name.menu"
1675+ fi
1676+else
1677+ # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications
1678+ if [ x"$mode" = x"user" ] ; then
1679+ update_submenu
1680+ fi
1681+fi
1682+
1683+# Install *.directory files
1684+
1685+xdg_dir_name=desktop-directories
1686+
1687+xdg_user_dir="$XDG_DATA_HOME"
1688+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
1689+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
1690+
1691+xdg_system_dirs="$XDG_DATA_DIRS"
1692+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
1693+xdg_global_dir=
1694+for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
1695+ if [ -w $x/$xdg_dir_name ] ; then
1696+ xdg_global_dir="$x/$xdg_dir_name"
1697+ break
1698+ fi
1699+done
1700+
1701+DEBUG 3 "Install locations for *.directory files:"
1702+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
1703+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
1704+DEBUG 3 "kde_user_dir: $kde_user_dir"
1705+DEBUG 3 "kde_global_dir: $kde_global_dir"
1706+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
1707+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
1708+
1709+if [ x"$mode" = x"user" ] ; then
1710+ xdg_dir="$xdg_user_dir"
1711+ kde_dir="$kde_user_dir"
1712+ gnome_dir="$gnome_user_dir"
1713+ my_umask=077
1714+else
1715+ xdg_dir="$xdg_global_dir"
1716+ kde_dir="$kde_global_dir"
1717+ gnome_dir="$gnome_global_dir"
1718+ my_umask=022
1719+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
1720+ exit_failure_operation_impossible "No writable system menu directory found."
1721+ fi
1722+fi
1723+
1724+for desktop_file in $directory_files; do
1725+ basefile=`basename "$desktop_file"`
1726+
1727+ DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir"
1728+
1729+ case $action in
1730+ install)
1731+ save_umask=`umask`
1732+ umask $my_umask
1733+
1734+ for x in $xdg_dir $kde_dir $gnome_dir ; do
1735+ mkdir -p $x
1736+ eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
1737+ done
1738+
1739+ umask $save_umask
1740+ ;;
1741+
1742+ uninstall)
1743+ for x in $xdg_dir $kde_dir $gnome_dir ; do
1744+ rm -f $x/$basefile
1745+ done
1746+
1747+ ;;
1748+ esac
1749+done
1750+
1751+# Install *.desktop files
1752+xdg_dir_name=applications
1753+
1754+xdg_user_dir="$XDG_DATA_HOME"
1755+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
1756+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
1757+
1758+xdg_system_dirs="$XDG_DATA_DIRS"
1759+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
1760+xdg_global_dir=
1761+for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
1762+ if [ -w $x/$xdg_dir_name ] ; then
1763+ xdg_global_dir="$x/$xdg_dir_name"
1764+ break
1765+ fi
1766+done
1767+
1768+kde_user_dir=`kde${KDE_SESSION_VERSION}-config --path apps 2> /dev/null | cut -d ':' -f 1`
1769+kde_global_dir=`kde${KDE_SESSION_VERSION}-config --path apps 2> /dev/null | cut -d ':' -f 2`
1770+[ -w $kde_global_dir ] || kde_global_dir=
1771+
1772+gnome_user_dir="$HOME/.gnome/apps"
1773+gnome_global_dir="/usr/share/gnome/apps"
1774+[ -w $gnome_global_dir ] || gnome_global_dir=
1775+
1776+DEBUG 3 "Install locations for *.desktop files:"
1777+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
1778+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
1779+DEBUG 3 "kde_user_dir: $kde_user_dir"
1780+DEBUG 3 "kde_global_dir: $kde_global_dir"
1781+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
1782+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
1783+
1784+if [ x"$mode" = x"user" ] ; then
1785+ xdg_dir="$xdg_user_dir"
1786+ kde_dir="$kde_user_dir"
1787+ gnome_dir="$gnome_user_dir"
1788+ my_umask=077
1789+else
1790+ xdg_dir="$xdg_global_dir"
1791+ kde_dir="$kde_global_dir"
1792+ gnome_dir="$gnome_global_dir"
1793+ my_umask=022
1794+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
1795+ exit_failure_operation_impossible "No writable system menu directory found."
1796+ fi
1797+fi
1798+
1799+for desktop_file in $desktop_files; do
1800+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
1801+ check_vendor_prefix "$desktop_file"
1802+ fi
1803+
1804+ basefile=`basename "$desktop_file"`
1805+
1806+ DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir"
1807+
1808+ case $action in
1809+ install)
1810+ save_umask=`umask`
1811+ umask $my_umask
1812+
1813+ for x in $xdg_dir $kde_dir $gnome_dir ; do
1814+ mkdir -p $x
1815+ eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
1816+ done
1817+
1818+ if [ -f $kde_dir/$basefile ] ; then
1819+ echo "OnlyShowIn=Old;" >> $kde_dir/$basefile
1820+ fi
1821+
1822+ if [ -f $gnome_dir/$basefile ] ; then
1823+ echo "OnlyShowIn=Old;" >> $gnome_dir/$basefile
1824+ fi
1825+
1826+ make_lazy_default "$xdg_dir" "$basefile"
1827+
1828+ umask $save_umask
1829+ ;;
1830+
1831+ uninstall)
1832+ for x in $xdg_dir $kde_dir $gnome_dir ; do
1833+ rm -f $x/$basefile
1834+ done
1835+
1836+ ;;
1837+ esac
1838+done
1839+
1840+if [ x"$update" = x"yes" ] ; then
1841+ update_desktop_database
1842+fi
1843+
1844+exit_success
1845
1846=== added file '.pc/bashisms.diff/scripts/xdg-email'
1847--- .pc/bashisms.diff/scripts/xdg-email 1970-01-01 00:00:00 +0000
1848+++ .pc/bashisms.diff/scripts/xdg-email 2014-06-16 08:53:37 +0000
1849@@ -0,0 +1,751 @@
1850+#!/bin/sh
1851+#---------------------------------------------
1852+# xdg-email
1853+#
1854+# Utility script to open the users favorite email program, using the
1855+# RFC 2368 mailto: URI spec
1856+#
1857+# Refer to the usage() function below for usage.
1858+#
1859+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
1860+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
1861+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
1862+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
1863+#
1864+# LICENSE:
1865+#
1866+# Permission is hereby granted, free of charge, to any person obtaining a
1867+# copy of this software and associated documentation files (the "Software"),
1868+# to deal in the Software without restriction, including without limitation
1869+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
1870+# and/or sell copies of the Software, and to permit persons to whom the
1871+# Software is furnished to do so, subject to the following conditions:
1872+#
1873+# The above copyright notice and this permission notice shall be included
1874+# in all copies or substantial portions of the Software.
1875+#
1876+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1877+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1878+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1879+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
1880+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1881+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1882+# OTHER DEALINGS IN THE SOFTWARE.
1883+#
1884+#---------------------------------------------
1885+
1886+manualpage()
1887+{
1888+cat << _MANUALPAGE
1889+Name
1890+
1891+xdg-email - command line tool for sending mail using the user's preferred
1892+e-mail composer
1893+
1894+Synopsis
1895+
1896+xdg-email [--utf8] [--cc address] [--bcc address] [--subject text] [--body text
1897+] [--attach file] [ mailto-uri | address(es) ]
1898+
1899+xdg-email { --help | --manual | --version }
1900+
1901+Description
1902+
1903+xdg-email opens the user's preferred e-mail composer in order to send a mail to
1904+address(es) or mailto-uri. RFC2368 defines mailto: URIs. xdg-email limits
1905+support to, cc, subject and body fields in mailto-uri, all other fields are
1906+silently ignored. address(es) must follow the syntax of RFC822. Multiple
1907+addresses may be provided as separate arguments.
1908+
1909+All information provided on the command line is used to prefill corresponding
1910+fields in the user's e-mail composer. The user will have the opportunity to
1911+change any of this information before actually sending the e-mail.
1912+
1913+xdg-email is for use inside a desktop session only. It is not recommended to
1914+use xdg-email as root.
1915+
1916+See http://portland.freedesktop.org/EmailConfig for information on how the user
1917+can change the e-mail composer that is used.
1918+
1919+Options
1920+
1921+--utf8
1922+ Indicates that all command line options that follow are in utf8. Without
1923+ this option, command line options are expected to be encoded according to
1924+ locale. If the locale already specifies utf8 this option has no effect.
1925+ This option does not affect mailto URIs that are passed on the command
1926+ line.
1927+--cc address
1928+ Specify a recipient to be copied on the e-mail.
1929+--bcc address
1930+ Specify a recipient to be blindly copied on the e-mail.
1931+--subject text
1932+ Specify a subject for the e-mail.
1933+--body text
1934+ Specify a body for the e-mail. Since the user will be able to make changes
1935+ before actually sending the e-mail, this can be used to provide the user
1936+ with a template for the e-mail. text may contain linebreaks.
1937+--attach file
1938+
1939+ Specify an attachment for the e-mail. file must point to an existing file.
1940+
1941+ Some e-mail applications require the file to remain present after xdg-email
1942+ returns.
1943+
1944+--help
1945+ Show command synopsis.
1946+--manual
1947+ Show this manualpage.
1948+--version
1949+ Show the xdg-utils version information.
1950+
1951+Environment Variables
1952+
1953+xdg-email honours the following environment variables:
1954+
1955+XDG_UTILS_DEBUG_LEVEL
1956+ Setting this environment variable to a non-zero numerical value makes
1957+ xdg-email do more verbose reporting on stderr. Setting a higher value
1958+ increases the verbosity.
1959+
1960+Exit Codes
1961+
1962+An exit code of 0 indicates success while a non-zero exit code indicates
1963+failure. The following failure codes can be returned:
1964+
1965+1
1966+ Error in command line syntax.
1967+2
1968+ One of the files passed on the command line did not exist.
1969+3
1970+ A required tool could not be found.
1971+4
1972+ The action failed.
1973+5
1974+ No permission to read one of the files passed on the command line.
1975+
1976+Configuration
1977+
1978+Visit http://portland.freedesktop.org/EmailConfig for information how to
1979+configure xdg-email to use the email client of your choice.
1980+
1981+Examples
1982+
1983+xdg-email 'Jeremy White <jwhite@example.com>'
1984+
1985+xdg-email --attach /tmp/logo.png \
1986+ --subject 'Logo contest' \
1987+ --body 'Attached you find the logo for the contest.' \
1988+ 'jwhite@example.com'
1989+
1990+xdg-email --subject 'Your password is about to expire' \
1991+ 'jwhite@example.com' 'bastian@example.com' 'whipple@example.com'
1992+
1993+_MANUALPAGE
1994+}
1995+
1996+usage()
1997+{
1998+cat << _USAGE
1999+xdg-email - command line tool for sending mail using the user's preferred
2000+e-mail composer
2001+
2002+Synopsis
2003+
2004+xdg-email [--utf8] [--cc address] [--bcc address] [--subject text] [--body text
2005+] [--attach file] [ mailto-uri | address(es) ]
2006+
2007+xdg-email { --help | --manual | --version }
2008+
2009+_USAGE
2010+}
2011+
2012+#@xdg-utils-common@
2013+
2014+#----------------------------------------------------------------------------
2015+# Common utility functions included in all XDG wrapper scripts
2016+#----------------------------------------------------------------------------
2017+
2018+DEBUG()
2019+{
2020+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
2021+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
2022+ shift
2023+ echo "$@" >&2
2024+}
2025+
2026+#-------------------------------------------------------------
2027+# Exit script on successfully completing the desired operation
2028+
2029+exit_success()
2030+{
2031+ if [ $# -gt 0 ]; then
2032+ echo "$@"
2033+ echo
2034+ fi
2035+
2036+ exit 0
2037+}
2038+
2039+
2040+#-----------------------------------------
2041+# Exit script on malformed arguments, not enough arguments
2042+# or missing required option.
2043+# prints usage information
2044+
2045+exit_failure_syntax()
2046+{
2047+ if [ $# -gt 0 ]; then
2048+ echo "xdg-email: $@" >&2
2049+ echo "Try 'xdg-email --help' for more information." >&2
2050+ else
2051+ usage
2052+ echo "Use 'man xdg-email' or 'xdg-email --manual' for additional info."
2053+ fi
2054+
2055+ exit 1
2056+}
2057+
2058+#-------------------------------------------------------------
2059+# Exit script on missing file specified on command line
2060+
2061+exit_failure_file_missing()
2062+{
2063+ if [ $# -gt 0 ]; then
2064+ echo "xdg-email: $@" >&2
2065+ fi
2066+
2067+ exit 2
2068+}
2069+
2070+#-------------------------------------------------------------
2071+# Exit script on failure to locate necessary tool applications
2072+
2073+exit_failure_operation_impossible()
2074+{
2075+ if [ $# -gt 0 ]; then
2076+ echo "xdg-email: $@" >&2
2077+ fi
2078+
2079+ exit 3
2080+}
2081+
2082+#-------------------------------------------------------------
2083+# Exit script on failure returned by a tool application
2084+
2085+exit_failure_operation_failed()
2086+{
2087+ if [ $# -gt 0 ]; then
2088+ echo "xdg-email: $@" >&2
2089+ fi
2090+
2091+ exit 4
2092+}
2093+
2094+#------------------------------------------------------------
2095+# Exit script on insufficient permission to read a specified file
2096+
2097+exit_failure_file_permission_read()
2098+{
2099+ if [ $# -gt 0 ]; then
2100+ echo "xdg-email: $@" >&2
2101+ fi
2102+
2103+ exit 5
2104+}
2105+
2106+#------------------------------------------------------------
2107+# Exit script on insufficient permission to write a specified file
2108+
2109+exit_failure_file_permission_write()
2110+{
2111+ if [ $# -gt 0 ]; then
2112+ echo "xdg-email: $@" >&2
2113+ fi
2114+
2115+ exit 6
2116+}
2117+
2118+check_input_file()
2119+{
2120+ if [ ! -e "$1" ]; then
2121+ exit_failure_file_missing "file '$1' does not exist"
2122+ fi
2123+ if [ ! -r "$1" ]; then
2124+ exit_failure_file_permission_read "no permission to read file '$1'"
2125+ fi
2126+}
2127+
2128+check_vendor_prefix()
2129+{
2130+ file_label="$2"
2131+ [ -n "$file_label" ] || file_label="filename"
2132+ file=`basename "$1"`
2133+ case "$file" in
2134+ [a-zA-Z]*-*)
2135+ return
2136+ ;;
2137+ esac
2138+
2139+ echo "xdg-email: $file_label '$file' does not have a proper vendor prefix" >&2
2140+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
2141+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
2142+ echo "Use --novendor to override or 'xdg-email --manual' for additional info." >&2
2143+ exit 1
2144+}
2145+
2146+check_output_file()
2147+{
2148+ # if the file exists, check if it is writeable
2149+ # if it does not exists, check if we are allowed to write on the directory
2150+ if [ -e "$1" ]; then
2151+ if [ ! -w "$1" ]; then
2152+ exit_failure_file_permission_write "no permission to write to file '$1'"
2153+ fi
2154+ else
2155+ DIR=`dirname "$1"`
2156+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
2157+ exit_failure_file_permission_write "no permission to create file '$1'"
2158+ fi
2159+ fi
2160+}
2161+
2162+#----------------------------------------
2163+# Checks for shared commands, e.g. --help
2164+
2165+check_common_commands()
2166+{
2167+ while [ $# -gt 0 ] ; do
2168+ parm="$1"
2169+ shift
2170+
2171+ case "$parm" in
2172+ --help)
2173+ usage
2174+ echo "Use 'man xdg-email' or 'xdg-email --manual' for additional info."
2175+ exit_success
2176+ ;;
2177+
2178+ --manual)
2179+ manualpage
2180+ exit_success
2181+ ;;
2182+
2183+ --version)
2184+ echo "xdg-email 1.0.2"
2185+ exit_success
2186+ ;;
2187+ esac
2188+ done
2189+}
2190+
2191+check_common_commands "$@"
2192+
2193+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
2194+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
2195+ # Be silent
2196+ xdg_redirect_output=" > /dev/null 2> /dev/null"
2197+else
2198+ # All output to stderr
2199+ xdg_redirect_output=" >&2"
2200+fi
2201+
2202+#--------------------------------------
2203+# Checks for known desktop environments
2204+# set variable DE to the desktop environments name, lowercase
2205+
2206+detectDE()
2207+{
2208+ if [ x"$MAILER" != x"" ]; then DE=envvar;
2209+ elif [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
2210+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
2211+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
2212+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
2213+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
2214+ elif [ -r ~/.muttrc ] && which mutt > /dev/null 2>&1; then
2215+ DE=envvar
2216+ MAILER="x-terminal-emulator -e mutt"
2217+ else DE=""
2218+ fi
2219+}
2220+
2221+#----------------------------------------------------------------------------
2222+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
2223+# It also always returns 1 in KDE 3.4 and earlier
2224+# Simply return 0 in such case
2225+
2226+kfmclient_fix_exit_code()
2227+{
2228+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
2229+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
2230+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
2231+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
2232+ test "$major" -gt 3 && return $1
2233+ test "$minor" -gt 5 && return $1
2234+ test "$release" -gt 4 && return $1
2235+ return 0
2236+}
2237+
2238+run_thunderbird()
2239+{
2240+ local THUNDERBIRD MAILTO NEWMAILTO TO CC BCC SUBJECT BODY ATTACH
2241+ THUNDERBIRD="$1"
2242+ MAILTO=$(echo "$2" | sed 's/^mailto://')
2243+ echo "$MAILTO" | grep -qs "^?"
2244+ if [ "$?" = "0" ] ; then
2245+ MAILTO=$(echo "$MAILTO" | sed 's/^?//')
2246+ else
2247+ MAILTO=$(echo "$MAILTO" | sed 's/^/to=/' | sed 's/?/\&/')
2248+ fi
2249+
2250+ MAILTO=$(echo "$MAILTO" | sed 's/&/\n/g')
2251+ TO=$(echo "$MAILTO" | grep '^to=' | sed 's/^to=//' | awk '{ printf "%s,",$0 }')
2252+ CC=$(echo "$MAILTO" | grep '^cc=' | sed 's/^cc=//' | awk '{ printf "%s,",$0 }')
2253+ BCC=$(echo "$MAILTO" | grep '^bcc=' | sed 's/^bcc=//' | awk '{ printf "%s,",$0 }')
2254+ SUBJECT=$(echo "$MAILTO" | grep '^subject=' | tail -n 1)
2255+ BODY=$(echo "$MAILTO" | grep '^body=' | tail -n 1)
2256+ ATTACH=$(echo "$MAILTO" | sed 's/^attach=/\n\nfile:\/\//g' | awk '/^file:/ { printf "%s,",$0 }' | sed 's/,$//')
2257+
2258+ if [ -z "$TO" ] ; then
2259+ NEWMAILTO=
2260+ else
2261+ NEWMAILTO="to='$TO'"
2262+ fi
2263+ if [ -n "$CC" ] ; then
2264+ NEWMAILTO="${NEWMAILTO},cc='$CC'"
2265+ fi
2266+ if [ -n "$BCC" ] ; then
2267+ NEWMAILTO="${NEWMAILTO},bcc='$BCC'"
2268+ fi
2269+ if [ -n "$SUBJECT" ] ; then
2270+ NEWMAILTO="${NEWMAILTO},$SUBJECT"
2271+ fi
2272+ if [ -n "$BODY" ] ; then
2273+ NEWMAILTO="${NEWMAILTO},$BODY"
2274+ fi
2275+
2276+ if [ -n "$ATTACH" ] ; then
2277+ NEWMAILTO="${NEWMAILTO},attachment='${ATTACH}'"
2278+ fi
2279+
2280+ NEWMAILTO=$(echo "$NEWMAILTO" | sed 's/^,//')
2281+ DEBUG 1 "Running $THUNDERBIRD -compose \"$NEWMAILTO\""
2282+ "$THUNDERBIRD" -compose "$NEWMAILTO"
2283+ if [ $? -eq 0 ]; then
2284+ exit_success
2285+ else
2286+ exit_failure_operation_failed
2287+ fi
2288+}
2289+
2290+open_kde()
2291+{
2292+ local client kde_email_profile_name
2293+ kde_email_profile_name=`kreadconfig --file emaildefaults --group Defaults --key Profile`
2294+ client=`kreadconfig --file emaildefaults --group PROFILE_"$kde_email_profile_name" --key EmailClient | cut -d ' ' -f 1`
2295+ echo $client | grep thunderbird > /dev/null 2>&1
2296+ if [ $? -eq 0 ] ; then
2297+ run_thunderbird "$client" "$1"
2298+ fi
2299+
2300+ if [ -f /etc/SuSE-release ] ; then
2301+ # Workaround for SUSE 10.0
2302+ [ -z "$client" ] && client="kmail"
2303+ if ! which "$client" > /dev/null 2> /dev/null; then
2304+ DEBUG 3 "KDE has $client configured as email client which isn't installed"
2305+ if which gnome-open > /dev/null 2> /dev/null && which evolution > /dev/null 2> /dev/null; then
2306+ DEBUG 3 "Try gnome-open instead"
2307+ open_gnome "$1"
2308+ fi
2309+ fi
2310+ fi
2311+ DEBUG 1 "Running kmailservice \"$1\""
2312+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
2313+ KMAILSERVICE=`kde4-config --locate kmailservice --path exe 2>/dev/null`
2314+ else
2315+ KMAILSERVICE=`which kmailservice 2>/dev/null`
2316+ fi
2317+ # KDE uses locale's encoding when decoding the URI, so set it to UTF-8
2318+ LC_ALL=C.UTF-8 $KMAILSERVICE "$1"
2319+ kfmclient_fix_exit_code $?
2320+
2321+ if [ $? -eq 0 ]; then
2322+ exit_success
2323+ else
2324+ exit_failure_operation_failed
2325+ fi
2326+}
2327+
2328+open_gnome()
2329+{
2330+ local client
2331+ client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -d ' ' -f 1` || ""
2332+ echo $client | grep thunderbird > /dev/null 2>&1
2333+ if [ $? -eq 0 ] ; then
2334+ run_thunderbird "$client" "$1"
2335+ fi
2336+
2337+ if gvfs-open --help 2>/dev/null 1>&2; then
2338+ DEBUG 1 "Running gvfs-open \"$1\""
2339+ gvfs-open "$1"
2340+ else
2341+ DEBUG 1 "Running gnome-open \"$1\""
2342+ gnome-open "$1"
2343+ fi
2344+
2345+ if [ $? -eq 0 ]; then
2346+ exit_success
2347+ else
2348+ exit_failure_operation_failed
2349+ fi
2350+}
2351+
2352+
2353+open_xfce()
2354+{
2355+ DEBUG 1 "Running exo-open \"$1\""
2356+ exo-open "$1"
2357+
2358+ if [ $? -eq 0 ]; then
2359+ exit_success
2360+ else
2361+ exit_failure_operation_failed
2362+ fi
2363+}
2364+
2365+open_envvar()
2366+{
2367+ local OLDIFS="$IFS"
2368+ IFS=:
2369+ for i in $MAILER; do
2370+ IFS="$OLDIFS"
2371+
2372+ eval "$i" '"$1"'
2373+
2374+ if [ $? -eq 0 ]; then
2375+ exit_success
2376+ fi
2377+ done
2378+
2379+ exit_failure_operation_failed
2380+}
2381+
2382+open_generic()
2383+{
2384+ IFS=":"
2385+ for browser in $BROWSER; do
2386+ if [ x"$browser" != x"" ]; then
2387+
2388+ browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
2389+ if [ $? -ne 0 ]; then browser_with_arg=$browser;
2390+ fi
2391+
2392+ if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1";
2393+ else $browser_with_arg;
2394+ fi
2395+
2396+ if [ $? -eq 0 ]; then exit_success;
2397+ fi
2398+ fi
2399+ done
2400+
2401+ exit_failure_operation_impossible "no method available for opening '$1'"
2402+}
2403+
2404+url_encode()
2405+{
2406+result=$(echo "$1" | $utf8 | awk '
2407+ BEGIN {
2408+ for ( i=1; i<=255; ++i ) ord [ sprintf ("%c", i) "" ] = i + 0
2409+ e = ""
2410+ linenr = 1
2411+ }
2412+ {
2413+ if ( linenr++ != 1 ) {
2414+ e = e "%0D%0A"
2415+ }
2416+ for ( i=1; i<=length ($0); ++i ) {
2417+ c = substr ($0, i, 1)
2418+ if ( ord [c] > 127 ) {
2419+ e = e "%" sprintf("%02X", ord [c])
2420+ } else if ( c ~ /[@a-zA-Z0-9.-\\\/]/ ) {
2421+ e = e c
2422+ } else {
2423+ e = e "%" sprintf("%02X", ord [c])
2424+ }
2425+ }
2426+ }
2427+ END {
2428+ print e
2429+ }
2430+')
2431+}
2432+
2433+options=
2434+mailto=
2435+utf8="iconv -t utf8"
2436+while [ $# -gt 0 ] ; do
2437+ parm="$1"
2438+ shift
2439+
2440+ case "$parm" in
2441+ --utf8)
2442+ utf8="cat"
2443+ ;;
2444+
2445+ --to)
2446+ if [ -z "$1" ] ; then
2447+ exit_failure_syntax "email address argument missing for --to"
2448+ fi
2449+ url_encode "$1"
2450+ options="${options}to=${result}&"
2451+ shift
2452+ ;;
2453+
2454+ --cc)
2455+ if [ -z "$1" ] ; then
2456+ exit_failure_syntax "email address argument missing for --cc"
2457+ fi
2458+ url_encode "$1"
2459+ options="${options}cc=${result}&"
2460+ shift
2461+ ;;
2462+
2463+ --bcc)
2464+ if [ -z "$1" ] ; then
2465+ exit_failure_syntax "email address argument missing for --bcc"
2466+ fi
2467+ url_encode "$1"
2468+ options="${options}bcc=${result}&"
2469+ shift
2470+ ;;
2471+
2472+ --subject)
2473+ if [ -z "$1" ] ; then
2474+ exit_failure_syntax "text argument missing for --subject option"
2475+ fi
2476+ url_encode "$1"
2477+ options="${options}subject=${result}&"
2478+ shift
2479+ ;;
2480+
2481+ --body)
2482+ if [ -z "$1" ] ; then
2483+ exit_failure_syntax "text argument missing for --body option"
2484+ fi
2485+ url_encode "$1"
2486+ options="${options}body=${result}&"
2487+ shift
2488+ ;;
2489+
2490+ --attach)
2491+ if [ -z "$1" ] ; then
2492+ exit_failure_syntax "file argument missing for --attach option"
2493+ fi
2494+ check_input_file "$1"
2495+ file=`readlink -f "$1"` # Normalize path
2496+ if [ -z "$file" -o ! -f "$file" ] ; then
2497+ exit_failure_file_missing "file '$1' does not exist"
2498+ fi
2499+
2500+ url_encode "$file"
2501+ options="${options}attach=${result}&"
2502+ shift
2503+ ;;
2504+
2505+ -*)
2506+ exit_failure_syntax "unexpected option '$parm'"
2507+ ;;
2508+
2509+ mailto:*)
2510+ mailto="$parm"
2511+ ;;
2512+
2513+ *@*)
2514+ url_encode "$parm"
2515+ if [ -z "${mailto}" ] ; then
2516+ mailto="mailto:"${result}"?"
2517+ else
2518+ options="${options}to=${result}&"
2519+ fi
2520+ ;;
2521+
2522+ *)
2523+ exit_failure_syntax "unexpected argument '$parm'"
2524+ ;;
2525+ esac
2526+done
2527+
2528+if [ -z "${mailto}" ] ; then
2529+ # TO address is optional
2530+ mailto="mailto:?"
2531+fi
2532+
2533+case $mailto in
2534+ *\?)
2535+ mailto="${mailto}${options}"
2536+ ;;
2537+
2538+ *\?*)
2539+ mailto="${mailto}&${options}"
2540+ ;;
2541+
2542+ *)
2543+ mailto="${mailto}?${options}"
2544+ ;;
2545+esac
2546+
2547+# Strip trailing ? and &
2548+mailto=`echo "${mailto}"| sed 's/[?&]$//'`
2549+
2550+# Shouldn't happen
2551+[ x"${mailto}" != x"" ] || exit_failure_syntax
2552+
2553+if which xdg-email-hook.sh > /dev/null 2> /dev/null; then
2554+ xdg-email-hook.sh "${mailto}"
2555+ if [ $? -eq 0 ]; then
2556+ exit_success
2557+ else
2558+ exit_failure_operation_failed
2559+ fi
2560+fi
2561+
2562+detectDE
2563+
2564+if [ x"$DE" = x"" ]; then
2565+ DE=generic
2566+fi
2567+
2568+# if BROWSER variable is not set, check some well known browsers instead
2569+if [ x"$BROWSER" = x"" ]; then
2570+ BROWSER=links2:links:lynx:w3m
2571+ if [ -n "$DISPLAY" ]; then
2572+ BROWSER=x-www-browser:firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
2573+ fi
2574+fi
2575+
2576+case "$DE" in
2577+ envvar)
2578+ open_envvar "${mailto}"
2579+ ;;
2580+
2581+ kde)
2582+ open_kde "${mailto}"
2583+ ;;
2584+
2585+ gnome)
2586+ open_gnome "${mailto}"
2587+ ;;
2588+
2589+ xfce)
2590+ open_xfce "${mailto}"
2591+ ;;
2592+
2593+ generic|lxde)
2594+ open_generic "${mailto}"
2595+ ;;
2596+
2597+ *)
2598+ exit_failure_operation_impossible "no method available for opening '${mailto}'"
2599+ ;;
2600+esac
2601
2602=== added file '.pc/bashisms.diff/scripts/xdg-icon-resource'
2603--- .pc/bashisms.diff/scripts/xdg-icon-resource 1970-01-01 00:00:00 +0000
2604+++ .pc/bashisms.diff/scripts/xdg-icon-resource 2014-06-16 08:53:37 +0000
2605@@ -0,0 +1,843 @@
2606+#!/bin/sh
2607+#---------------------------------------------
2608+# xdg-icon-resource
2609+#
2610+# Utility script to install icons on a Linux desktop.
2611+#
2612+# Refer to the usage() function below for usage.
2613+#
2614+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
2615+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
2616+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
2617+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
2618+#
2619+# LICENSE:
2620+#
2621+# Permission is hereby granted, free of charge, to any person obtaining a
2622+# copy of this software and associated documentation files (the "Software"),
2623+# to deal in the Software without restriction, including without limitation
2624+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
2625+# and/or sell copies of the Software, and to permit persons to whom the
2626+# Software is furnished to do so, subject to the following conditions:
2627+#
2628+# The above copyright notice and this permission notice shall be included
2629+# in all copies or substantial portions of the Software.
2630+#
2631+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2632+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2633+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
2634+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2635+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2636+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2637+# OTHER DEALINGS IN THE SOFTWARE.
2638+#
2639+#---------------------------------------------
2640+
2641+manualpage()
2642+{
2643+cat << _MANUALPAGE
2644+Name
2645+
2646+xdg-icon-resource - command line tool for (un)installing icon resources
2647+
2648+Synopsis
2649+
2650+xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
2651+context] [--mode mode] --size size icon-file [icon-name]
2652+
2653+xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
2654+[--mode mode] --size size icon-name
2655+
2656+xdg-icon-resource forceupdate [--theme theme] [--mode mode]
2657+
2658+xdg-icon-resource { --help | --manual | --version }
2659+
2660+Description
2661+
2662+The xdg-icon-resource program can be used to install icon resources into the
2663+desktop icon system in order to illustrate menu entries, to depict desktop
2664+icons or to graphically represent file types.
2665+
2666+The desktop icon system identifies icons by name. Depending on the required
2667+size, the choice of icon theme and the context in which the icon is used, the
2668+desktop icon system locates an appropriate icon resource to depict an icon.
2669+Icon resources can be XPM files or PNG files.
2670+
2671+The desktop icon system works according to the XDG Icon Theme Specification at
2672+http://www.freedesktop.org/Standards/icon-theme-spec
2673+
2674+Commands
2675+
2676+install
2677+ Installs the icon file indicated by icon-file to the desktop icon system
2678+ under the name icon-name. Icon names do not have an extension. If icon-name
2679+ is not provided the name is derived from icon-file. The icon file must have
2680+ .png or .xpm as extension. If a corresponding .icon file exists in the same
2681+ location as icon-file it will be installed as well.
2682+uninstall
2683+ Removes the icon indicated by icon-name from the desktop icon system. Note
2684+ that icon names do not have an extension.
2685+forceupdate
2686+ Force an update of the desktop icon system. This is only useful if the last
2687+ call to xdg-icon-resource included the --noupdate option.
2688+
2689+Options
2690+
2691+--noupdate
2692+ Postpone updating the desktop icon system. If multiple icons are added in
2693+ sequence this flag can be used to indicate that additional changes will
2694+ follow and that it is not necassery to update the desktop icon system right
2695+ away.
2696+--novendor
2697+
2698+ Normally, xdg-icon-resource checks to ensure that an icon file to be
2699+ installed in the apps context has a proper vendor prefix. This option can
2700+ be used to disable that check.
2701+
2702+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
2703+ with a dash ("-"). Companies and organizations are encouraged to use a word
2704+ or phrase, preferably the organizations name, for which they hold a
2705+ trademark as their vendor prefix. The purpose of the vendor prefix is to
2706+ prevent name conflicts.
2707+
2708+--theme theme
2709+ Installs or removes the icon file as part of theme. If no theme is
2710+ specified the icons will be installed as part of the default hicolor theme.
2711+ Applications may install icons under multiple themes but should at least
2712+ install icons for the default hicolor theme.
2713+--context context
2714+ Specifies the context for the icon. Icons to be used in the application
2715+ menu and as desktop icon should use apps as context which is the default
2716+ context. Icons to be used as file icons should use mimetypes as context.
2717+ Other common contexts are actions, devices, emblems, filesystems and stock.
2718+--size size
2719+ Specifies the size of the icon. All icons must be square. Common sizes for
2720+ icons in the apps context are: 16, 22, 32, 48, 64 and 128. Common sizes for
2721+ icons in the mimetypes context are: 16, 22, 32, 48, 64 and 128
2722+--mode mode
2723+
2724+ mode can be user or system. In user mode the file is (un)installed for the
2725+ current user only. In system mode the file is (un)installed for all users
2726+ on the system. Usually only root is allowed to install in system mode.
2727+
2728+ The default is to use system mode when called by root and to use user mode
2729+ when called by a non-root user.
2730+
2731+--help
2732+ Show command synopsis.
2733+--manual
2734+ Show this manualpage.
2735+--version
2736+ Show the xdg-utils version information.
2737+
2738+Environment Variables
2739+
2740+xdg-icon-resource honours the following environment variables:
2741+
2742+XDG_UTILS_DEBUG_LEVEL
2743+ Setting this environment variable to a non-zero numerical value makes
2744+ xdg-icon-resource do more verbose reporting on stderr. Setting a higher
2745+ value increases the verbosity.
2746+XDG_UTILS_INSTALL_MODE
2747+ This environment variable can be used by the user or administrator to
2748+ override the installation mode. Valid values are user and system.
2749+
2750+Exit Codes
2751+
2752+An exit code of 0 indicates success while a non-zero exit code indicates
2753+failure. The following failure codes can be returned:
2754+
2755+1
2756+ Error in command line syntax.
2757+2
2758+ One of the files passed on the command line did not exist.
2759+3
2760+ A required tool could not be found.
2761+4
2762+ The action failed.
2763+5
2764+ No permission to read one of the files passed on the command line.
2765+
2766+See Also
2767+
2768+xdg-desktop-icon(1), xdg-desktop-menu(1), xdg-mime(1)
2769+
2770+Examples
2771+
2772+To install an icon resource to depict a launcher for the application myfoobar,
2773+the company ShinyThings Inc. can use:
2774+
2775+xdg-icon-resource install --size 64 shinythings-myfoobar.png
2776+
2777+To install an icon for a new application/x-foobar file type one can use:
2778+
2779+xdg-icon-resource install --context mimetypes --size 48 ./mime-foobar-48.png application-x-foobar
2780+xdg-icon-resource install --context mimetypes --size 64 ./mime-foobar-64.png application-x-foobar
2781+
2782+This will install two icons with the name application-x-foobar but with
2783+different sizes.
2784+
2785+_MANUALPAGE
2786+}
2787+
2788+usage()
2789+{
2790+cat << _USAGE
2791+xdg-icon-resource - command line tool for (un)installing icon resources
2792+
2793+Synopsis
2794+
2795+xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
2796+context] [--mode mode] --size size icon-file [icon-name]
2797+
2798+xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
2799+[--mode mode] --size size icon-name
2800+
2801+xdg-icon-resource forceupdate [--theme theme] [--mode mode]
2802+
2803+xdg-icon-resource { --help | --manual | --version }
2804+
2805+_USAGE
2806+}
2807+
2808+#@xdg-utils-common@
2809+
2810+#----------------------------------------------------------------------------
2811+# Common utility functions included in all XDG wrapper scripts
2812+#----------------------------------------------------------------------------
2813+
2814+DEBUG()
2815+{
2816+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
2817+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
2818+ shift
2819+ echo "$@" >&2
2820+}
2821+
2822+#-------------------------------------------------------------
2823+# Exit script on successfully completing the desired operation
2824+
2825+exit_success()
2826+{
2827+ if [ $# -gt 0 ]; then
2828+ echo "$@"
2829+ echo
2830+ fi
2831+
2832+ exit 0
2833+}
2834+
2835+
2836+#-----------------------------------------
2837+# Exit script on malformed arguments, not enough arguments
2838+# or missing required option.
2839+# prints usage information
2840+
2841+exit_failure_syntax()
2842+{
2843+ if [ $# -gt 0 ]; then
2844+ echo "xdg-icon-resource: $@" >&2
2845+ echo "Try 'xdg-icon-resource --help' for more information." >&2
2846+ else
2847+ usage
2848+ echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for additional info."
2849+ fi
2850+
2851+ exit 1
2852+}
2853+
2854+#-------------------------------------------------------------
2855+# Exit script on missing file specified on command line
2856+
2857+exit_failure_file_missing()
2858+{
2859+ if [ $# -gt 0 ]; then
2860+ echo "xdg-icon-resource: $@" >&2
2861+ fi
2862+
2863+ exit 2
2864+}
2865+
2866+#-------------------------------------------------------------
2867+# Exit script on failure to locate necessary tool applications
2868+
2869+exit_failure_operation_impossible()
2870+{
2871+ if [ $# -gt 0 ]; then
2872+ echo "xdg-icon-resource: $@" >&2
2873+ fi
2874+
2875+ exit 3
2876+}
2877+
2878+#-------------------------------------------------------------
2879+# Exit script on failure returned by a tool application
2880+
2881+exit_failure_operation_failed()
2882+{
2883+ if [ $# -gt 0 ]; then
2884+ echo "xdg-icon-resource: $@" >&2
2885+ fi
2886+
2887+ exit 4
2888+}
2889+
2890+#------------------------------------------------------------
2891+# Exit script on insufficient permission to read a specified file
2892+
2893+exit_failure_file_permission_read()
2894+{
2895+ if [ $# -gt 0 ]; then
2896+ echo "xdg-icon-resource: $@" >&2
2897+ fi
2898+
2899+ exit 5
2900+}
2901+
2902+#------------------------------------------------------------
2903+# Exit script on insufficient permission to write a specified file
2904+
2905+exit_failure_file_permission_write()
2906+{
2907+ if [ $# -gt 0 ]; then
2908+ echo "xdg-icon-resource: $@" >&2
2909+ fi
2910+
2911+ exit 6
2912+}
2913+
2914+check_input_file()
2915+{
2916+ if [ ! -e "$1" ]; then
2917+ exit_failure_file_missing "file '$1' does not exist"
2918+ fi
2919+ if [ ! -r "$1" ]; then
2920+ exit_failure_file_permission_read "no permission to read file '$1'"
2921+ fi
2922+}
2923+
2924+check_vendor_prefix()
2925+{
2926+ file_label="$2"
2927+ [ -n "$file_label" ] || file_label="filename"
2928+ file=`basename "$1"`
2929+ case "$file" in
2930+ [a-zA-Z]*-*)
2931+ return
2932+ ;;
2933+ esac
2934+
2935+ echo "xdg-icon-resource: $file_label '$file' does not have a proper vendor prefix" >&2
2936+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
2937+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
2938+ echo "Use --novendor to override or 'xdg-icon-resource --manual' for additional info." >&2
2939+ exit 1
2940+}
2941+
2942+check_output_file()
2943+{
2944+ # if the file exists, check if it is writeable
2945+ # if it does not exists, check if we are allowed to write on the directory
2946+ if [ -e "$1" ]; then
2947+ if [ ! -w "$1" ]; then
2948+ exit_failure_file_permission_write "no permission to write to file '$1'"
2949+ fi
2950+ else
2951+ DIR=`dirname "$1"`
2952+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
2953+ exit_failure_file_permission_write "no permission to create file '$1'"
2954+ fi
2955+ fi
2956+}
2957+
2958+#----------------------------------------
2959+# Checks for shared commands, e.g. --help
2960+
2961+check_common_commands()
2962+{
2963+ while [ $# -gt 0 ] ; do
2964+ parm="$1"
2965+ shift
2966+
2967+ case "$parm" in
2968+ --help)
2969+ usage
2970+ echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for additional info."
2971+ exit_success
2972+ ;;
2973+
2974+ --manual)
2975+ manualpage
2976+ exit_success
2977+ ;;
2978+
2979+ --version)
2980+ echo "xdg-icon-resource 1.0.2"
2981+ exit_success
2982+ ;;
2983+ esac
2984+ done
2985+}
2986+
2987+check_common_commands "$@"
2988+
2989+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
2990+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
2991+ # Be silent
2992+ xdg_redirect_output=" > /dev/null 2> /dev/null"
2993+else
2994+ # All output to stderr
2995+ xdg_redirect_output=" >&2"
2996+fi
2997+
2998+#--------------------------------------
2999+# Checks for known desktop environments
3000+# set variable DE to the desktop environments name, lowercase
3001+
3002+detectDE()
3003+{
3004+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
3005+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
3006+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
3007+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
3008+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
3009+ else DE=""
3010+ fi
3011+}
3012+
3013+#----------------------------------------------------------------------------
3014+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
3015+# It also always returns 1 in KDE 3.4 and earlier
3016+# Simply return 0 in such case
3017+
3018+kfmclient_fix_exit_code()
3019+{
3020+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
3021+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
3022+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
3023+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
3024+ test "$major" -gt 3 && return $1
3025+ test "$minor" -gt 5 && return $1
3026+ test "$release" -gt 4 && return $1
3027+ return 0
3028+}
3029+
3030+# Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or
3031+# to "-" if not found.
3032+GTK_UPDATE_ICON_CACHE=
3033+find_gtk_update_icon_cache()
3034+{
3035+ [ -n "$GTK_UPDATE_ICON_CACHE" ] && return;
3036+
3037+ GTK_UPDATE_ICON_CACHE="-"
3038+ for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
3039+ DEBUG 3 "Checking $x for gtk-update-icon-cache"
3040+ if [ -x "$x/gtk-update-icon-cache" ] ; then
3041+ DEBUG 1 "Found $x/gtk-update-icon-cache"
3042+ GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache"
3043+ return
3044+ fi
3045+ done
3046+}
3047+
3048+# Start GNOME legacy workaround section
3049+need_dot_icon_path()
3050+{
3051+ # GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons
3052+ # The availability of gtk-update-icon-cache is used as indication
3053+ # of whether the system is using GTK 2.6 or later
3054+ find_gtk_update_icon_cache
3055+ [ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1;
3056+ return 0;
3057+}
3058+
3059+update_icon_database()
3060+{
3061+ # Touch me, I'm dirty
3062+ touch "$1/.xdg-icon-resource-dummy"
3063+ rm -f "$1/.xdg-icon-resource-dummy"
3064+
3065+ # Don't create a cache if there wan't one already
3066+ if [ -f "$1/icon-theme.cache" ] ; then
3067+ find_gtk_update_icon_cache
3068+ if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then
3069+ DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\""
3070+ eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output
3071+ return
3072+ fi
3073+ fi
3074+}
3075+
3076+[ x"$1" != x"" ] || exit_failure_syntax
3077+
3078+mode=
3079+action=
3080+update=yes
3081+size=
3082+theme=hicolor
3083+context=apps
3084+icon_file=
3085+icon_name=
3086+
3087+case $1 in
3088+ install)
3089+ action=install
3090+ ;;
3091+
3092+ uninstall)
3093+ action=uninstall
3094+ ;;
3095+
3096+ forceupdate)
3097+ action=forceupdate
3098+ ;;
3099+
3100+ *)
3101+ exit_failure_syntax "unknown command '$1'"
3102+ ;;
3103+esac
3104+
3105+shift
3106+
3107+vendor=true
3108+while [ $# -gt 0 ] ; do
3109+ parm="$1"
3110+ shift
3111+
3112+ case $parm in
3113+ --noupdate)
3114+ update=no
3115+ ;;
3116+
3117+ --mode)
3118+ if [ -z "$1" ] ; then
3119+ exit_failure_syntax "mode argument missing for --mode"
3120+ fi
3121+ case "$1" in
3122+ user)
3123+ mode="user"
3124+ ;;
3125+
3126+ system)
3127+ mode="system"
3128+ ;;
3129+
3130+ *)
3131+ exit_failure_syntax "unknown mode '$1'"
3132+ ;;
3133+ esac
3134+ shift
3135+ ;;
3136+
3137+ --theme)
3138+ if [ -z "$1" ] ; then
3139+ exit_failure_syntax "theme argument missing for --theme"
3140+ fi
3141+ theme="$1"
3142+ shift
3143+ ;;
3144+
3145+ --size)
3146+ if [ -z "$1" ] ; then
3147+ exit_failure_syntax "size argument missing for --size"
3148+ fi
3149+ if echo "$1" | grep '[^0-9]' > /dev/null 2> /dev/null; then
3150+ exit_failure_syntax "size argument must be numeric"
3151+ fi
3152+ size="$1"
3153+ shift
3154+ ;;
3155+
3156+ --context)
3157+ if [ -z "$1" ] ; then
3158+ exit_failure_syntax "context argument missing for --context"
3159+ fi
3160+ context="$1"
3161+ shift
3162+ ;;
3163+
3164+ --novendor)
3165+ vendor=false
3166+ ;;
3167+
3168+ -*)
3169+ exit_failure_syntax "unexpected option '$parm'"
3170+ ;;
3171+
3172+ *)
3173+ if [ -n "$icon_name" ] ; then
3174+ exit_failure_syntax "unexpected argument '$parm'"
3175+ elif [ -n "$icon_file" ] ; then
3176+ icon_name="$parm"
3177+ else
3178+ if [ "$action" = "install" ] ; then
3179+ check_input_file "$parm"
3180+ fi
3181+ icon_file="$parm"
3182+ fi
3183+ ;;
3184+ esac
3185+done
3186+
3187+# Shouldn't happen
3188+if [ -z "$action" ] ; then
3189+ exit_failure_syntax "command argument missing"
3190+fi
3191+
3192+# Shouldn't happen
3193+if [ -z "$context" ] ; then
3194+ exit_failure_syntax "context argument missing"
3195+fi
3196+
3197+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
3198+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
3199+ mode="system"
3200+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
3201+ mode="user"
3202+ fi
3203+fi
3204+
3205+if [ -z "$mode" ] ; then
3206+ if [ `whoami` = "root" ] ; then
3207+ mode="system"
3208+ else
3209+ mode="user"
3210+ fi
3211+fi
3212+
3213+xdg_dir_name="icons/$theme"
3214+
3215+xdg_user_dir="$XDG_DATA_HOME"
3216+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
3217+xdg_user_prefix="$xdg_user_dir/icons"
3218+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
3219+
3220+xdg_global_dir=
3221+xdg_global_prefix=
3222+xdg_system_dirs="$XDG_DATA_DIRS"
3223+[ -n "$xdg_system_dirs" ] || xdg_system_dirs="/usr/local/share/:/usr/share/"
3224+for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do
3225+ if [ -w $x/$xdg_dir_name ] ; then
3226+ xdg_global_prefix="$x/icons"
3227+ xdg_global_dir="$x/$xdg_dir_name"
3228+ break
3229+ fi
3230+done
3231+[ -w $xdg_global_dir ] || xdg_global_dir=
3232+
3233+dot_icon_dir=
3234+dot_base_dir=
3235+if [ x"$mode" = x"user" ] ; then
3236+ xdg_base_dir="$xdg_user_dir"
3237+ #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
3238+ if need_dot_icon_path ; then
3239+ dot_icon_dir="$HOME/.icons"
3240+ dot_base_dir="$dot_icon_dir/$theme"
3241+ fi
3242+else
3243+ xdg_base_dir="$xdg_global_dir"
3244+ if [ -z "$xdg_base_dir" ] ; then
3245+ exit_failure_operation_impossible "No writable system icon directory found."
3246+ fi
3247+fi
3248+
3249+if [ x"$action" = x"forceupdate" ] ; then
3250+ if [ -n "$icon_file" ] ; then
3251+ exit_failure_syntax "unexpected argument '$icon_file'"
3252+ fi
3253+ update_icon_database $xdg_base_dir
3254+ if [ -n "$dot_icon_dir" ] ; then
3255+ if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
3256+ update_icon_database $dot_base_dir
3257+ fi
3258+ fi
3259+ exit_success
3260+fi
3261+
3262+if [ -z "$icon_file" ] ; then
3263+ if [ x"$action" = x"install" ] ; then
3264+ exit_failure_syntax "icon-file argument missing"
3265+ else
3266+ exit_failure_syntax "icon-name argument missing"
3267+ fi
3268+fi
3269+
3270+xdg_size_name=
3271+extension=
3272+
3273+if [ -z "$size" ] ; then
3274+ exit_failure_syntax "the icon size must be specified with --size"
3275+fi
3276+xdg_size_name="${size}x${size}"
3277+
3278+if [ x"$action" = x"install" ] ; then
3279+ case $icon_file in
3280+ *.xpm)
3281+ extension="xpm"
3282+ ;;
3283+ *.png)
3284+ extension="png"
3285+ ;;
3286+ *)
3287+ exit_failure_syntax "icon file to install must be a *.png or *.xpm file"
3288+ ;;
3289+ esac
3290+fi
3291+
3292+if [ -n "$icon_name" ] ; then
3293+ case $icon_name in
3294+ *.png)
3295+ exit_failure_syntax "icon name should not include an extension"
3296+ ;;
3297+ *.xpm)
3298+ exit_failure_syntax "icon name should not include an extension"
3299+ ;;
3300+ esac
3301+fi
3302+
3303+# Start KDE legacy workaround section
3304+need_kde_icon_path()
3305+{
3306+ local path
3307+ path=`readlink -f "$1" 2> /dev/null` # Normalize path
3308+ DEBUG 2 "need_kde_icon_path $path"
3309+ if [ -z "$path" ] ; then
3310+ DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no xdg icon dir)"
3311+ return 1; # Not needed
3312+ fi
3313+
3314+ # if kde-config not found... return 0
3315+ kde_icon_dirs=`kde${KDE_SESSION_VERSION}-config --path icon 2> /dev/null |sed 's/:/ /g'`
3316+ DEBUG 3 "kde_icon_dirs: $kde_icon_dirs"
3317+ if [ -z "$kde_icon_dirs" ] ; then
3318+ DEBUG 3 "no result from kde${KDE_SESSION_VERSION}-config --path icon"
3319+ DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no kde icon path)"
3320+ return 1; # Not needed
3321+ fi
3322+ needed=0 # Needed
3323+ for y in $kde_icon_dirs ; do
3324+ x=`readlink -f "$y"` # Normalize path
3325+ DEBUG 3 "Normalize $y --> $x"
3326+ if [ -n "$x" ] ; then
3327+ if [ "$x" = "$path" ] ; then
3328+ needed=1 # Not needed
3329+ fi
3330+ if [ -w "$x" ] ; then
3331+ kde_global_prefix="$x"
3332+ # Take last writable dir
3333+ fi
3334+ fi
3335+ done
3336+ DEBUG 2 "kde_global_prefix: $kde_global_prefix"
3337+ [ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed)"
3338+ [ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)"
3339+ return $needed
3340+}
3341+
3342+kde_dir=
3343+if [ x"$mode" = x"user" ] ; then
3344+ xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
3345+ #KDE 3.x doesn't support XDG_DATA_HOME for icons
3346+ #Check if xdg_dir prefix is listed by kde-config --path icon
3347+ #If not, install additional symlink to kdedir
3348+ if need_kde_icon_path "$xdg_user_prefix" ; then
3349+ kde_user_icon_dir=`kde${KDE_SESSION_VERSION}-config --path icon | cut -d ':' -f 1`
3350+ kde_user_dir="$kde_user_icon_dir/$theme"
3351+ kde_dir="$kde_user_dir/$xdg_size_name/$context"
3352+ fi
3353+ #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
3354+ if [ -n "$dot_icon_dir" ] ; then
3355+ if [ -L "$dot_icon_dir" ] ; then
3356+ # Don't do anything
3357+ dot_icon_dir=
3358+ elif [ ! -d "$dot_icon_dir/" ] ; then
3359+ # Symlink if it doesn't exist
3360+ eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_output
3361+ dot_icon_dir=
3362+ else
3363+ dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context"
3364+ fi
3365+ fi
3366+ my_umask=077
3367+else
3368+ xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
3369+ #KDE 3.x doesn't support XDG_DATA_DIRS for icons
3370+ #Check if xdg_dir prefix is listed by kde-config --path icon
3371+ #If not, install additional symlink to kdedir
3372+ if need_kde_icon_path "$xdg_global_prefix" ; then
3373+ kde_global_dir="$kde_global_prefix/$theme"
3374+ kde_dir="$kde_global_dir/$xdg_size_name/$context"
3375+ fi
3376+ my_umask=022
3377+fi
3378+# End KDE legacy workaround section
3379+
3380+# Start GNOME legacy workaround section
3381+need_gnome_mime=
3382+[ $context = "mimetypes" ] && need_gnome_mime=true
3383+# End GNOME legacy workaround section
3384+
3385+[ -n "$icon_name" ] || icon_name=`basename "$icon_file" | sed 's/\.[a-z][a-z][a-z]$//'`
3386+
3387+if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then
3388+ check_vendor_prefix "$icon_name" "icon name"
3389+fi
3390+
3391+icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'`
3392+icon_icon_name="$icon_name.icon"
3393+
3394+DEBUG 1 "$action icon in $xdg_dir"
3395+[ $action = "install" -a -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir"
3396+[ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)"
3397+[ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNOME 2.x support)"
3398+[ $action = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)"
3399+
3400+case $action in
3401+ install)
3402+ save_umask=`umask`
3403+ umask $my_umask
3404+
3405+ for icon_dir in $xdg_dir $dot_icon_dir; do
3406+ mkdir -p $icon_dir
3407+ eval 'cp "$icon_file" "$icon_dir/$icon_name.$extension"'$xdg_redirect_output
3408+ if [ -f "$icon_icon_file" ] ; then
3409+ eval 'cp "$icon_icon_file" "$icon_dir/$icon_icon_name"'$xdg_redirect_output
3410+ fi
3411+ if [ -n "$need_gnome_mime" ] ; then
3412+ eval 'ln -s "$icon_name.$extension" "$icon_dir/gnome-mime-$icon_name.$extension"'$xdg_redirect_output
3413+ fi
3414+ done
3415+ if [ -n "$kde_dir" ] ; then
3416+ mkdir -p $kde_dir
3417+ eval 'ln -s "$xdg_dir/$icon_name.$extension" "$kde_dir/$icon_name.$extension"'$xdg_redirect_output
3418+ fi
3419+
3420+ umask $save_umask
3421+ ;;
3422+
3423+ uninstall)
3424+ for icon_dir in $xdg_dir $dot_icon_dir; do
3425+ rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png"
3426+ rm -f "$icon_dir/$icon_icon_name"
3427+ if [ -n "$need_gnome_mime" ] ; then
3428+ rm -f "$icon_dir/gnome-mime-$icon_name.xpm"
3429+ rm -f "$icon_dir/gnome-mime-$icon_name.png"
3430+ fi
3431+ done
3432+ if [ -n "$kde_dir" ] ; then
3433+ rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png"
3434+ fi
3435+
3436+ ;;
3437+esac
3438+
3439+if [ x"$update" = x"yes" ] ; then
3440+ update_icon_database "$xdg_base_dir"
3441+ if [ -n "$dot_icon_dir" ] ; then
3442+ if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
3443+ update_icon_database $dot_base_dir
3444+ fi
3445+ fi
3446+fi
3447+
3448+exit_success
3449
3450=== added file '.pc/bashisms.diff/scripts/xdg-mime'
3451--- .pc/bashisms.diff/scripts/xdg-mime 1970-01-01 00:00:00 +0000
3452+++ .pc/bashisms.diff/scripts/xdg-mime 2014-06-16 08:53:37 +0000
3453@@ -0,0 +1,1225 @@
3454+#!/bin/sh
3455+#---------------------------------------------
3456+# xdg-mime
3457+#
3458+# Utility script to manipulate MIME related information
3459+# on XDG compliant systems.
3460+#
3461+# Refer to the usage() function below for usage.
3462+#
3463+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
3464+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
3465+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
3466+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
3467+#
3468+# LICENSE:
3469+#
3470+# Permission is hereby granted, free of charge, to any person obtaining a
3471+# copy of this software and associated documentation files (the "Software"),
3472+# to deal in the Software without restriction, including without limitation
3473+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
3474+# and/or sell copies of the Software, and to permit persons to whom the
3475+# Software is furnished to do so, subject to the following conditions:
3476+#
3477+# The above copyright notice and this permission notice shall be included
3478+# in all copies or substantial portions of the Software.
3479+#
3480+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
3481+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3482+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
3483+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
3484+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
3485+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3486+# OTHER DEALINGS IN THE SOFTWARE.
3487+#
3488+#---------------------------------------------
3489+
3490+manualpage()
3491+{
3492+cat << _MANUALPAGE
3493+Name
3494+
3495+xdg-mime - command line tool for querying information about file type handling
3496+and adding descriptions for new file types
3497+
3498+Synopsis
3499+
3500+xdg-mime query { filetype | default } ...
3501+
3502+xdg-mime default application mimetype(s)
3503+
3504+xdg-mime install [--mode mode] [--novendor] mimetypes-file
3505+
3506+xdg-mime uninstall [--mode mode] mimetypes-file
3507+
3508+xdg-mime { --help | --manual | --version }
3509+
3510+Description
3511+
3512+The xdg-mime program can be used to query information about file types and to
3513+add descriptions for new file types.
3514+
3515+Commands
3516+
3517+query
3518+
3519+ Returns information related to file types.
3520+
3521+ The query option is for use inside a desktop session only. It is not
3522+ recommended to use xdg-mime query as root.
3523+
3524+ The following queries are supported:
3525+
3526+ query filetype FILE: Returns the file type of FILE in the form of a MIME
3527+ type.
3528+
3529+ query default mimetype: Returns the default application that the desktop
3530+ environment uses for opening files of type mimetype. The default
3531+ application is identified by its *.desktop file.
3532+
3533+default
3534+
3535+ Ask the desktop environment to make application the default application for
3536+ opening files of type mimetype. An application can be made the default for
3537+ several file types by specifying multiple mimetypes.
3538+
3539+ application is the desktop file id of the application and has the form
3540+ vendor-name.desktop application must already be installed in the desktop
3541+ menu before it can be made the default handler. The aplication's desktop
3542+ file must list support for all the MIME types that it wishes to be the
3543+ default handler for.
3544+
3545+ Requests to make an application a default handler may be subject to system
3546+ policy or approval by the end-user. xdg-mime query can be used to verify
3547+ whether an application is the actual default handler for a specific file
3548+ type.
3549+
3550+ The default option is for use inside a desktop session only. It is not
3551+ recommended to use xdg-mime default as root.
3552+
3553+install
3554+ Adds the file type descriptions provided in mimetypes-file to the desktop
3555+ environment. mimetypes-file must be a XML file that follows the
3556+ freedesktop.org Shared MIME-info Database specification and that has a
3557+ mime-info element as its document root. For each new file type one or more
3558+ icons with name type-subtype must be installed with the xdg-icon-resource
3559+ command in the mimetypes context. For example the filetype application/
3560+ vnd.oasis.opendocument.text requires an icon named
3561+ application-vnd.oasis.opendocument.text to be installed (unless the file
3562+ type recommends another icon name).
3563+uninstall
3564+ Removes the file type descriptions provided in mimetypes-file and
3565+ previously added with xdg-mime install from the desktop environment.
3566+ mimetypes-file must be a XML file that follows the freedesktop.org Shared
3567+ MIME-info Database specification and that has a mime-info element as its
3568+ document root.
3569+
3570+Options
3571+
3572+--mode mode
3573+
3574+ mode can be user or system. In user mode the file is (un)installed for the
3575+ current user only. In system mode the file is (un)installed for all users
3576+ on the system. Usually only root is allowed to install in system mode.
3577+
3578+ The default is to use system mode when called by root and to use user mode
3579+ when called by a non-root user.
3580+
3581+--novendor
3582+
3583+ Normally, xdg-mime checks to ensure that the mimetypes-file to be installed
3584+ has a proper vendor prefix. This option can be used to disable that check.
3585+
3586+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
3587+ with a dash ("-"). Companies and organizations are encouraged to use a word
3588+ or phrase, preferably the organizations name, for which they hold a
3589+ trademark as their vendor prefix. The purpose of the vendor prefix is to
3590+ prevent name conflicts.
3591+
3592+--help
3593+ Show command synopsis.
3594+--manual
3595+ Show this manualpage.
3596+--version
3597+ Show the xdg-utils version information.
3598+
3599+Environment Variables
3600+
3601+xdg-mime honours the following environment variables:
3602+
3603+XDG_UTILS_DEBUG_LEVEL
3604+ Setting this environment variable to a non-zero numerical value makes
3605+ xdg-mime do more verbose reporting on stderr. Setting a higher value
3606+ increases the verbosity.
3607+XDG_UTILS_INSTALL_MODE
3608+ This environment variable can be used by the user or administrator to
3609+ override the installation mode. Valid values are user and system.
3610+
3611+Exit Codes
3612+
3613+An exit code of 0 indicates success while a non-zero exit code indicates
3614+failure. The following failure codes can be returned:
3615+
3616+1
3617+ Error in command line syntax.
3618+2
3619+ One of the files passed on the command line did not exist.
3620+3
3621+ A required tool could not be found.
3622+4
3623+ The action failed.
3624+5
3625+ No permission to read one of the files passed on the command line.
3626+
3627+See Also
3628+
3629+xdg-icon-resource(1), xdg-desktop-menu(1)
3630+
3631+Examples
3632+
3633+xdg-mime query filetype /tmp/foobar.png
3634+
3635+Prints the MIME type of the file /tmp/foobar.png, in this case image/png
3636+
3637+xdg-mime query default image/png
3638+
3639+Prints the .desktop filename of the application which is registered to open PNG
3640+files.
3641+
3642+xdg-mime install shinythings-shiny.xml
3643+
3644+Adds a file type description for "shiny"-files. "shinythings-" is used as the
3645+vendor prefix. The file type description could look as folows.
3646+
3647+shinythings-shiny.xml:
3648+
3649+<?xml version="1.0"?>
3650+<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
3651+ <mime-type type="text/x-shiny">
3652+ <comment>Shiny new file type</comment>
3653+ <glob pattern="*.shiny"/>
3654+ <glob pattern="*.shi"/>
3655+ </mime-type>
3656+</mime-info>
3657+
3658+An icon for this new file type must also be installed, for example with:
3659+
3660+xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
3661+
3662+_MANUALPAGE
3663+}
3664+
3665+usage()
3666+{
3667+cat << _USAGE
3668+xdg-mime - command line tool for querying information about file type handling
3669+and adding descriptions for new file types
3670+
3671+Synopsis
3672+
3673+xdg-mime query { filetype | default } ...
3674+
3675+xdg-mime default application mimetype(s)
3676+
3677+xdg-mime install [--mode mode] [--novendor] mimetypes-file
3678+
3679+xdg-mime uninstall [--mode mode] mimetypes-file
3680+
3681+xdg-mime { --help | --manual | --version }
3682+
3683+_USAGE
3684+}
3685+
3686+#@xdg-utils-common@
3687+
3688+#----------------------------------------------------------------------------
3689+# Common utility functions included in all XDG wrapper scripts
3690+#----------------------------------------------------------------------------
3691+
3692+DEBUG()
3693+{
3694+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
3695+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
3696+ shift
3697+ echo "$@" >&2
3698+}
3699+
3700+#-------------------------------------------------------------
3701+# Exit script on successfully completing the desired operation
3702+
3703+exit_success()
3704+{
3705+ if [ $# -gt 0 ]; then
3706+ echo "$@"
3707+ echo
3708+ fi
3709+
3710+ exit 0
3711+}
3712+
3713+
3714+#-----------------------------------------
3715+# Exit script on malformed arguments, not enough arguments
3716+# or missing required option.
3717+# prints usage information
3718+
3719+exit_failure_syntax()
3720+{
3721+ if [ $# -gt 0 ]; then
3722+ echo "xdg-mime: $@" >&2
3723+ echo "Try 'xdg-mime --help' for more information." >&2
3724+ else
3725+ usage
3726+ echo "Use 'man xdg-mime' or 'xdg-mime --manual' for additional info."
3727+ fi
3728+
3729+ exit 1
3730+}
3731+
3732+#-------------------------------------------------------------
3733+# Exit script on missing file specified on command line
3734+
3735+exit_failure_file_missing()
3736+{
3737+ if [ $# -gt 0 ]; then
3738+ echo "xdg-mime: $@" >&2
3739+ fi
3740+
3741+ exit 2
3742+}
3743+
3744+#-------------------------------------------------------------
3745+# Exit script on failure to locate necessary tool applications
3746+
3747+exit_failure_operation_impossible()
3748+{
3749+ if [ $# -gt 0 ]; then
3750+ echo "xdg-mime: $@" >&2
3751+ fi
3752+
3753+ exit 3
3754+}
3755+
3756+#-------------------------------------------------------------
3757+# Exit script on failure returned by a tool application
3758+
3759+exit_failure_operation_failed()
3760+{
3761+ if [ $# -gt 0 ]; then
3762+ echo "xdg-mime: $@" >&2
3763+ fi
3764+
3765+ exit 4
3766+}
3767+
3768+#------------------------------------------------------------
3769+# Exit script on insufficient permission to read a specified file
3770+
3771+exit_failure_file_permission_read()
3772+{
3773+ if [ $# -gt 0 ]; then
3774+ echo "xdg-mime: $@" >&2
3775+ fi
3776+
3777+ exit 5
3778+}
3779+
3780+#------------------------------------------------------------
3781+# Exit script on insufficient permission to write a specified file
3782+
3783+exit_failure_file_permission_write()
3784+{
3785+ if [ $# -gt 0 ]; then
3786+ echo "xdg-mime: $@" >&2
3787+ fi
3788+
3789+ exit 6
3790+}
3791+
3792+check_input_file()
3793+{
3794+ if [ ! -e "$1" ]; then
3795+ exit_failure_file_missing "file '$1' does not exist"
3796+ fi
3797+ if [ ! -r "$1" ]; then
3798+ exit_failure_file_permission_read "no permission to read file '$1'"
3799+ fi
3800+}
3801+
3802+check_vendor_prefix()
3803+{
3804+ file_label="$2"
3805+ [ -n "$file_label" ] || file_label="filename"
3806+ file=`basename "$1"`
3807+ case "$file" in
3808+ [a-zA-Z]*-*)
3809+ return
3810+ ;;
3811+ esac
3812+
3813+ echo "xdg-mime: $file_label '$file' does not have a proper vendor prefix" >&2
3814+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
3815+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
3816+ echo "Use --novendor to override or 'xdg-mime --manual' for additional info." >&2
3817+ exit 1
3818+}
3819+
3820+check_output_file()
3821+{
3822+ # if the file exists, check if it is writeable
3823+ # if it does not exists, check if we are allowed to write on the directory
3824+ if [ -e "$1" ]; then
3825+ if [ ! -w "$1" ]; then
3826+ exit_failure_file_permission_write "no permission to write to file '$1'"
3827+ fi
3828+ else
3829+ DIR=`dirname "$1"`
3830+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
3831+ exit_failure_file_permission_write "no permission to create file '$1'"
3832+ fi
3833+ fi
3834+}
3835+
3836+#----------------------------------------
3837+# Checks for shared commands, e.g. --help
3838+
3839+check_common_commands()
3840+{
3841+ while [ $# -gt 0 ] ; do
3842+ parm="$1"
3843+ shift
3844+
3845+ case "$parm" in
3846+ --help)
3847+ usage
3848+ echo "Use 'man xdg-mime' or 'xdg-mime --manual' for additional info."
3849+ exit_success
3850+ ;;
3851+
3852+ --manual)
3853+ manualpage
3854+ exit_success
3855+ ;;
3856+
3857+ --version)
3858+ echo "xdg-mime 1.0.2"
3859+ exit_success
3860+ ;;
3861+ esac
3862+ done
3863+}
3864+
3865+check_common_commands "$@"
3866+
3867+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
3868+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
3869+ # Be silent
3870+ xdg_redirect_output=" > /dev/null 2> /dev/null"
3871+else
3872+ # All output to stderr
3873+ xdg_redirect_output=" >&2"
3874+fi
3875+
3876+#--------------------------------------
3877+# Checks for known desktop environments
3878+# set variable DE to the desktop environments name, lowercase
3879+
3880+detectDE()
3881+{
3882+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
3883+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
3884+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
3885+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
3886+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
3887+ else DE=""
3888+ fi
3889+}
3890+
3891+#----------------------------------------------------------------------------
3892+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
3893+# It also always returns 1 in KDE 3.4 and earlier
3894+# Simply return 0 in such case
3895+
3896+kfmclient_fix_exit_code()
3897+{
3898+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
3899+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
3900+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
3901+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
3902+ test "$major" -gt 3 && return $1
3903+ test "$minor" -gt 5 && return $1
3904+ test "$release" -gt 4 && return $1
3905+ return 0
3906+}
3907+
3908+update_mime_database()
3909+{
3910+ if [ x"$mode" = x"user" -a -n "$DISPLAY" ] ; then
3911+ detectDE
3912+ if [ x"$DE" = x"kde" ] ; then
3913+ DEBUG 1 "Running kbuildsycoca"
3914+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
3915+ eval 'kbuildsycoca4'$xdg_redirect_output
3916+ else
3917+ eval 'kbuildsycoca'$xdg_redirect_output
3918+ fi
3919+ fi
3920+ fi
3921+ for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
3922+ if [ -x $x/update-mime-database ] ; then
3923+ DEBUG 1 "Running $x/update-mime-database $1"
3924+ eval '$x/update-mime-database $1'$xdg_redirect_output
3925+ return
3926+ fi
3927+ done
3928+}
3929+
3930+info_kde()
3931+{
3932+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
3933+ DEBUG 1 "Running kmimetypefinder \"$1\""
3934+ KMIMETYPEFINDER=`which kmimetypefinder 2>/dev/null`
3935+ $KMIMETYPEFINDER "$1" 2>/dev/null | head -n 1
3936+ else
3937+ DEBUG 1 "Running kfile \"$1\""
3938+ KFILE=`which kfile 2>/dev/null`
3939+ $KFILE "$1" 2> /dev/null | head -n 1 | cut -d "(" -f 2 | cut -d ")" -f 1
3940+ fi
3941+
3942+ if [ $? -eq 0 ]; then
3943+ exit_success
3944+ else
3945+ exit_failure_operation_failed
3946+ fi
3947+}
3948+
3949+info_gnome()
3950+{
3951+ if gvfs-info --help 2>/dev/null 1>&2; then
3952+ DEBUG 1 "Running gvfs-info \"$1\""
3953+ gvfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4
3954+ elif gnomevfs-info --help 2>/dev/null 1>&2; then
3955+ DEBUG 1 "Running gnomevfs-info \"$1\""
3956+ gnomevfs-info --slow-mime "$1" 2> /dev/null | grep "^MIME" | cut -d ":" -f 2 | sed s/"^ "//
3957+ elif mimetype --version >/dev/null 2>&1; then
3958+ DEBUG 1 "Running mimetype -b \"$1\""
3959+ mimetype -b "$1"
3960+ else
3961+ DEBUG 1 "Running file -i \"$1\""
3962+ /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "//
3963+ fi
3964+
3965+ if [ $? -eq 0 ]; then
3966+ exit_success
3967+ else
3968+ exit_failure_operation_failed
3969+ fi
3970+}
3971+
3972+info_generic()
3973+{
3974+ if mimetype --version >/dev/null 2>&1; then
3975+ DEBUG 1 "Running mimetype -b \"$1\""
3976+ mimetype -b "$1"
3977+ else
3978+ DEBUG 1 "Running file -i \"$1\""
3979+ /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "//
3980+ fi
3981+
3982+ if [ $? -eq 0 ]; then
3983+ exit_success
3984+ else
3985+ exit_failure_operation_failed
3986+ fi
3987+}
3988+
3989+make_default_kde()
3990+{
3991+ # $1 is vendor-name.desktop
3992+ # $2 is mime/type
3993+ #
3994+ # On KDE 3, add to $KDE_CONFIG_PATH/profilerc:
3995+ # [$2 - 1]
3996+ # Application=$1
3997+ #
3998+ # Remove all [$2 - *] sections, or even better,
3999+ # renumber [$2 - *] sections and remove duplicate
4000+ #
4001+ # On KDE 4, add $2=$1 to $XDG_DATA_APPS/mimeapps.list
4002+ #
4003+ # Example file:
4004+ #
4005+ # [Added Associations]
4006+ # text/plain=kde4-kate.desktop;kde4-kwrite.desktop;
4007+ #
4008+ # [Removed Associations]
4009+ # text/plain=gnome-gedit.desktop;gnu-emacs.desktop;
4010+ vendor="$1"
4011+ mimetype="$2"
4012+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
4013+ default_dir=`kde4-config --path xdgdata-apps 2> /dev/null | cut -d ':' -f 1`
4014+ default_file="$default_dir/mimeapps.list"
4015+ else
4016+ default_dir=`kde-config --path config 2> /dev/null | cut -d ':' -f 1`
4017+ default_file="$default_dir/profilerc"
4018+ fi
4019+ if [ -z "$default_dir" ]; then
4020+ DEBUG 2 "make_default_kde: No kde runtime detected"
4021+ return
4022+ fi
4023+ DEBUG 2 "make_default_kde $vendor $mimetype"
4024+ DEBUG 1 "Updating $default_file"
4025+ mkdir -p "$default_dir"
4026+ [ -f $default_file ] || touch $default_file
4027+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
4028+ [ -f $default_file ] || touch $default_file
4029+ awk -v application="$vendor" -v mimetype="$mimetype" '
4030+ BEGIN {
4031+ prefix=mimetype "="
4032+ associations=0
4033+ found=0
4034+ blanks=0
4035+ }
4036+ {
4037+ suppress=0
4038+ if (index($0, "[Added Associations]") == 1) {
4039+ associations=1
4040+ } else if (index($0, "[") == 1) {
4041+ if (associations && !found) {
4042+ print prefix application
4043+ found=1
4044+ }
4045+ associations=0
4046+ } else if ($0 == "") {
4047+ blanks++
4048+ suppress=1
4049+ } else if (associations && index($0, prefix) == 1) {
4050+ value=substr($0, length(prefix) + 1, length)
4051+ split(value, apps, ";")
4052+ value=application ";"
4053+ count=0
4054+ for (i in apps) {
4055+ count++
4056+ }
4057+ for (i=0; i < count; i++) {
4058+ if (apps[i] != application && apps[i] != "") {
4059+ value=value apps[i] ";"
4060+ }
4061+ }
4062+ $0=prefix value
4063+ found=1
4064+ }
4065+ if (!suppress) {
4066+ while (blanks > 0) {
4067+ print ""
4068+ blanks--
4069+ }
4070+ print $0
4071+ }
4072+ }
4073+ END {
4074+ if (!found) {
4075+ if (!associations) {
4076+ print "[Added Associations]"
4077+ }
4078+ print prefix application
4079+ }
4080+ while (blanks > 0) {
4081+ print ""
4082+ blanks--
4083+ }
4084+ }
4085+' $default_file > ${default_file}.new && mv ${default_file}.new $default_file
4086+ eval 'kbuildsycoca4'$xdg_redirect_output
4087+ else
4088+ awk -v application="$vendor" -v mimetype="$mimetype" '
4089+ BEGIN {
4090+ header_start="[" mimetype " - "
4091+ suppress=0
4092+ }
4093+ {
4094+ if (index($0, header_start) == 1 )
4095+ suppress=1
4096+ else
4097+ if (/^\[/) { suppress=0 }
4098+
4099+ if (!suppress) {
4100+ print $0
4101+ }
4102+ }
4103+ END {
4104+ print ""
4105+ print "[" mimetype " - 1]"
4106+ print "Application=" application
4107+ print "AllowAsDefault=true"
4108+ print "GenericServiceType=Application"
4109+ print "Preference=1"
4110+ print "ServiceType=" mimetype
4111+ }
4112+' $default_file > ${default_file}.new && mv ${default_file}.new $default_file
4113+ fi
4114+}
4115+
4116+make_default_generic()
4117+{
4118+ # $1 is vendor-name.desktop
4119+ # $2 is mime/type
4120+ # Add $2=$1 to XDG_DATA_HOME/applications/defaults.list
4121+ xdg_user_dir="$XDG_DATA_HOME"
4122+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
4123+ default_file="$xdg_user_dir/applications/defaults.list"
4124+ DEBUG 2 "make_default_generic $1 $2"
4125+ DEBUG 1 "Updating $default_file"
4126+ grep -v "$2=" $default_file > ${default_file}.new 2> /dev/null
4127+ if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then
4128+ echo "[Default Applications]" >> ${default_file}.new
4129+ fi
4130+ echo $2=$1 >> ${default_file}.new
4131+ mv ${default_file}.new $default_file
4132+}
4133+
4134+defapp_generic()
4135+{
4136+ MIME="$1"
4137+ xdg_user_dir="$XDG_DATA_HOME"
4138+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
4139+ xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
4140+ xdg_system_dirs="$XDG_DATA_DIRS"
4141+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
4142+
4143+ for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
4144+ DEBUG 2 "Checking $x/applications/defaults.list"
4145+ trader_result=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2 | cut -d ';' -f 1`
4146+ if [ -n "$trader_result" ] ; then
4147+ echo $trader_result
4148+ exit_success
4149+ fi
4150+ done
4151+ exit_success
4152+}
4153+
4154+defapp_kde()
4155+{
4156+ MIME="$1"
4157+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
4158+ KTRADER=`which ktraderclient 2> /dev/null`
4159+ MIMETYPE="--mimetype"
4160+ SERVICETYPE="--servicetype"
4161+ else
4162+ KTRADER=`which ktradertest 2> /dev/null`
4163+ fi
4164+ if [ -n "$KTRADER" ] ; then
4165+ DEBUG 1 "Running KDE trader query \"$MIME\" mimetype and \"Application\" servicetype"
4166+ trader_result=`$KTRADER $MIMETYPE "$MIME" $SERVICETYPE Application 2>/dev/null \
4167+ | grep DesktopEntryPath | head -n 1 | cut -d ':' -f 2 | cut -d \' -f 2`
4168+ if [ -n "$trader_result" ] ; then
4169+ basename "$trader_result"
4170+ exit_success
4171+ else
4172+ exit_failure_operation_failed
4173+ fi
4174+ else
4175+ defapp_generic "$1"
4176+ fi
4177+}
4178+
4179+[ x"$1" != x"" ] || exit_failure_syntax
4180+
4181+mode=
4182+action=
4183+filename=
4184+mimetype=
4185+
4186+case $1 in
4187+ install)
4188+ action=install
4189+ ;;
4190+
4191+ uninstall)
4192+ action=uninstall
4193+ ;;
4194+
4195+ query)
4196+ shift
4197+
4198+ if [ -z "$1" ] ; then
4199+ exit_failure_syntax "query type argument missing"
4200+ fi
4201+
4202+ case $1 in
4203+ filetype)
4204+ action=info
4205+
4206+ filename="$2"
4207+ if [ -z "$filename" ] ; then
4208+ exit_failure_syntax "FILE argument missing"
4209+ fi
4210+ case $filename in
4211+ -*)
4212+ exit_failure_syntax "unexpected option '$filename'"
4213+ ;;
4214+ esac
4215+ check_input_file "$filename"
4216+ filename=$(readlink -f -- "$filename")
4217+ ;;
4218+
4219+ default)
4220+ action=defapp
4221+ mimetype="$2"
4222+ if [ -z "$mimetype" ] ; then
4223+ exit_failure_syntax "mimetype argument missing"
4224+ fi
4225+ case $mimetype in
4226+ -*)
4227+ exit_failure_syntax "unexpected option '$mimetype'"
4228+ ;;
4229+
4230+ */*)
4231+ # Ok
4232+ ;;
4233+
4234+ *)
4235+ exit_failure_syntax "mimetype '$mimetype' is not in the form 'minor/major'"
4236+ ;;
4237+ esac
4238+ ;;
4239+
4240+ *)
4241+ exit_failure_syntax "unknown query type '$1'"
4242+ ;;
4243+ esac
4244+ ;;
4245+
4246+ default)
4247+ action=makedefault
4248+ shift
4249+
4250+ if [ -z "$1" ] ; then
4251+ exit_failure_syntax "application argument missing"
4252+ fi
4253+ case $1 in
4254+ -*)
4255+ exit_failure_syntax "unexpected option '$1'"
4256+ ;;
4257+
4258+ *.desktop)
4259+ filename="$1"
4260+ ;;
4261+
4262+ *)
4263+ exit_failure_syntax "malformed argument '$1', expected *.desktop"
4264+ ;;
4265+ esac
4266+ ;;
4267+
4268+ *)
4269+ exit_failure_syntax "unknown command '$1'"
4270+ ;;
4271+esac
4272+
4273+shift
4274+
4275+
4276+if [ "$action" = "makedefault" ]; then
4277+ if [ -z "$1" ] ; then
4278+ exit_failure_syntax "mimetype argument missing"
4279+ fi
4280+
4281+ while [ $# -gt 0 ] ; do
4282+ case $1 in
4283+ -*)
4284+ exit_failure_syntax "unexpected option '$1'"
4285+ ;;
4286+ esac
4287+ mimetype="$1"
4288+ shift
4289+
4290+ make_default_kde "$filename" "$mimetype"
4291+ make_default_generic "$filename" "$mimetype"
4292+ done
4293+ exit_success
4294+fi
4295+
4296+if [ "$action" = "info" ]; then
4297+ detectDE
4298+
4299+ if [ x"$DE" = x"" ]; then
4300+ if [ -x /usr/bin/file ]; then
4301+ DE=generic
4302+ fi
4303+ fi
4304+
4305+ case "$DE" in
4306+ kde)
4307+ info_kde "$filename"
4308+ ;;
4309+
4310+ gnome)
4311+ info_gnome "$filename"
4312+ ;;
4313+
4314+ *)
4315+ info_generic "$filename"
4316+ ;;
4317+ esac
4318+ exit_failure_operation_impossible "no method available for quering MIME type of '$filename'"
4319+fi
4320+
4321+if [ "$action" = "defapp" ]; then
4322+ detectDE
4323+
4324+ case "$DE" in
4325+ kde)
4326+ defapp_kde "$mimetype"
4327+ ;;
4328+
4329+ *)
4330+ defapp_generic "$mimetype"
4331+ ;;
4332+ esac
4333+ exit_failure_operation_impossible "no method available for quering default application for '$mimetype'"
4334+fi
4335+
4336+vendor=true
4337+while [ $# -gt 0 ] ; do
4338+ parm="$1"
4339+ shift
4340+
4341+ case $parm in
4342+ --mode)
4343+ if [ -z "$1" ] ; then
4344+ exit_failure_syntax "mode argument missing for --mode"
4345+ fi
4346+ case "$1" in
4347+ user)
4348+ mode="user"
4349+ ;;
4350+
4351+ system)
4352+ mode="system"
4353+ ;;
4354+
4355+ *)
4356+ exit_failure_syntax "unknown mode '$1'"
4357+ ;;
4358+ esac
4359+ shift
4360+ ;;
4361+
4362+ --novendor)
4363+ vendor=false
4364+ ;;
4365+
4366+ -*)
4367+ exit_failure_syntax "unexpected option '$parm'"
4368+ ;;
4369+
4370+ *)
4371+ if [ -n "$filename" ] ; then
4372+ exit_failure_syntax "unexpected argument '$parm'"
4373+ fi
4374+
4375+ filename="$parm"
4376+ check_input_file "$filename"
4377+ ;;
4378+ esac
4379+done
4380+
4381+if [ -z "$action" ] ; then
4382+ exit_failure_syntax "command argument missing"
4383+fi
4384+
4385+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
4386+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
4387+ mode="system"
4388+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
4389+ mode="user"
4390+ fi
4391+fi
4392+
4393+if [ -z "$mode" ] ; then
4394+ if [ `whoami` = "root" ] ; then
4395+ mode="system"
4396+ else
4397+ mode="user"
4398+ fi
4399+fi
4400+
4401+if [ -z "$filename" ] ; then
4402+ exit_failure_syntax "mimetypes-file argument missing"
4403+fi
4404+
4405+if [ "$vendor" = "true" -a "$action" = "install" ] ; then
4406+ check_vendor_prefix "$filename"
4407+fi
4408+
4409+xdg_base_dir=
4410+xdg_dir_name=mime/packages/
4411+
4412+xdg_user_dir="$XDG_DATA_HOME"
4413+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
4414+[ x"$mode" = x"user" ] && xdg_base_dir="$xdg_user_dir/mime"
4415+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
4416+
4417+xdg_system_dirs="$XDG_DATA_DIRS"
4418+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
4419+for x in `echo $xdg_system_dirs | sed 's/:/ /g'`; do
4420+ if [ -w $x/$xdg_dir_name ] ; then
4421+ [ x"$mode" = x"system" ] && xdg_base_dir="$x/mime"
4422+ xdg_global_dir="$x/$xdg_dir_name"
4423+ break
4424+ fi
4425+done
4426+[ -w $xdg_global_dir ] || xdg_global_dir=
4427+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
4428+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
4429+
4430+# Find KDE3 mimelnk directory
4431+kde_user_dir=
4432+kde_global_dir=
4433+kde_global_dirs=`kde${KDE_SESSION_VERSION}-config --path mime 2> /dev/null`
4434+DEBUG 3 "kde_global_dirs: $kde_global_dirs"
4435+first=
4436+for x in `echo $kde_global_dirs | sed 's/:/ /g'` ; do
4437+ if [ -z "$first" ] ; then
4438+ first=false
4439+ kde_user_dir="$x"
4440+ elif [ -w $x ] ; then
4441+ kde_global_dir="$x"
4442+ fi
4443+done
4444+DEBUG 3 "kde_user_dir: $kde_user_dir"
4445+DEBUG 3 "kde_global_dir: $kde_global_dir"
4446+
4447+# TODO: Gnome legacy support
4448+# See http://forums.fedoraforum.org/showthread.php?t=26875
4449+gnome_user_dir="$HOME/.gnome/apps"
4450+gnome_global_dir=/usr/share/gnome/apps
4451+[ -w $gnome_global_dir ] || gnome_global_dir=
4452+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
4453+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
4454+
4455+if [ x"$mode" = x"user" ] ; then
4456+ xdg_dir="$xdg_user_dir"
4457+ kde_dir="$kde_user_dir"
4458+ gnome_dir="$gnome_user_dir"
4459+ my_umask=077
4460+else
4461+ xdg_dir="$xdg_global_dir"
4462+ kde_dir="$kde_global_dir"
4463+ gnome_dir="$gnome_global_dir"
4464+ my_umask=022
4465+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
4466+ exit_failure_operation_impossible "No writable system mimetype directory found."
4467+ fi
4468+fi
4469+
4470+# echo "[xdg|$xdg_user_dir|$xdg_global_dir]"
4471+# echo "[kde|$kde_user_dir|$kde_global_dir]"
4472+# echo "[gnome|$gnome_user_dir|$gnome_global_dir]"
4473+# echo "[using|$xdg_dir|$kde_dir|$gnome_dir]"
4474+
4475+basefile=`basename "$filename"`
4476+#[ -z $vendor ] || basefile="$vendor-$basefile"
4477+
4478+mimetypes=
4479+if [ -n "$kde_dir" ] ; then
4480+ DEBUG 2 "KDE3 mimelnk directory found, extracting mimetypes from XML file"
4481+
4482+ mimetypes=`awk < "$filename" '
4483+# Strip XML comments
4484+BEGIN {
4485+ suppress=0
4486+}
4487+{
4488+ do
4489+ if (suppress) {
4490+ if (match($0,/-->/)) {
4491+ $0=substr($0,RSTART+RLENGTH)
4492+ suppress=0
4493+ }
4494+ else {
4495+ break
4496+ }
4497+ }
4498+ else {
4499+ if (match($0,/<!--/)) {
4500+ if (RSTART>1) print substr($0,0,RSTART)
4501+ $0=substr($0,RSTART+RLENGTH)
4502+ suppress=1
4503+ }
4504+ else {
4505+ if ($0) print $0
4506+ break
4507+ }
4508+ }
4509+ while(1)
4510+}
4511+' | awk '
4512+# List MIME types listed in <mime-type> tags
4513+BEGIN {
4514+ RS="<"
4515+}
4516+/^mime-info/, /^\/mime-info/ {
4517+ if (match($0,/^mime-type/)) {
4518+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
4519+ print substr($0,RSTART+6,RLENGTH-6)
4520+ }
4521+ }
4522+}'`
4523+fi
4524+
4525+DEBUG 1 "$action mimetype in $xdg_dir"
4526+
4527+case $action in
4528+ install)
4529+ save_umask=`umask`
4530+ umask $my_umask
4531+
4532+ for x in $xdg_dir ; do
4533+ mkdir -p $x
4534+ eval 'cp $filename $x/$basefile'$xdg_redirect_output
4535+ done
4536+
4537+ if [ -n "$mimetypes" ] ; then
4538+ # No quotes around $mimetypes
4539+ for x in $mimetypes ; do
4540+ DEBUG 1 "Installing $kde_dir/$x.desktop (KDE 3.x support)"
4541+ mkdir -p `dirname $kde_dir/$x.desktop`
4542+ awk < "$filename" '
4543+# Strip XML comments
4544+BEGIN {
4545+ suppress=0
4546+}
4547+{
4548+ do
4549+ if (suppress) {
4550+ if (match($0,/-->/)) {
4551+ $0=substr($0,RSTART+RLENGTH)
4552+ suppress=0
4553+ }
4554+ else {
4555+ break
4556+ }
4557+ }
4558+ else {
4559+ if (match($0,/<!--/)) {
4560+ if (RSTART>1) print substr($0,0,RSTART)
4561+ $0=substr($0,RSTART+RLENGTH)
4562+ suppress=1
4563+ }
4564+ else {
4565+ if ($0) print $0
4566+ break
4567+ }
4568+ }
4569+ while(1)
4570+}
4571+' | awk > $kde_dir/$x.desktop '
4572+# Extract mimetype $x from the XML file $filename
4573+# Note that bash requires us to escape a single quote as '"'"'
4574+BEGIN {
4575+ the_type=ARGV[1]
4576+ the_source=ARGV[2]
4577+ ARGC=1
4578+ RS="<"
4579+ found=0
4580+ glob_patterns=""
4581+}
4582+/^mime-info/, /^\/mime-info/ {
4583+ if (match($0,/^mime-type/)) {
4584+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
4585+ if (substr($0,RSTART+6,RLENGTH-6) == the_type) {
4586+ found=1
4587+ print "[Desktop Entry]"
4588+ print "# Installed by xdg-mime from " the_source
4589+ print "Type=MimeType"
4590+ print "MimeType=" the_type
4591+ the_icon=the_type
4592+ sub("/", "-", the_icon)
4593+ print "Icon=" the_icon
4594+ }
4595+ }
4596+ }
4597+ else if (found) {
4598+ if (match($0,/^\/mime-type/)) {
4599+ if (glob_patterns)
4600+ print "Patterns=" glob_patterns
4601+ exit 0
4602+ }
4603+
4604+ if (match($0,/^sub-class-of/)) {
4605+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
4606+ print "X-KDE-IsAlso=" substr($0,RSTART+6,RLENGTH-6)
4607+ }
4608+ else {
4609+ print "Error: '"'"'type'"'"' argument missing in " RS $0
4610+ exit 1
4611+ }
4612+ }
4613+ if (match($0,/^glob/)) {
4614+ if (match($0,/pattern="[^"]*/) || match($0,/pattern='"'"'[^'"'"']*/)) {
4615+ glob_patterns = glob_patterns substr($0,RSTART+9,RLENGTH-9) ";"
4616+ }
4617+ else {
4618+ print "Error: '"'"'pattern'"'"' argument missing in " RS $0
4619+ exit 1
4620+ }
4621+ }
4622+ if (match($0,/^comment/)) {
4623+ if (match($0,/xml:lang="[^"]*/) || match($0,/xml:lang='"'"'[^'"'"']*/)) {
4624+ lang=substr($0,RSTART+10,RLENGTH-10)
4625+ }
4626+ else {
4627+ lang=""
4628+ }
4629+ if (match($0,/>/)) {
4630+ comment=substr($0,RSTART+1)
4631+ sub("&lt;", "<", comment)
4632+ sub("&gt;", ">", comment)
4633+ sub("&amp;", "\\&", comment)
4634+ if (lang)
4635+ print "Comment[" lang "]=" comment
4636+ else
4637+ print "Comment=" comment
4638+ }
4639+ }
4640+ }
4641+}
4642+END {
4643+ if (!found) {
4644+ print "Error: Mimetype '"'"'" the_type "'"'"' not found"
4645+ exit 1
4646+ }
4647+}
4648+' $x $basefile
4649+ if [ "$?" = "1" ] ; then
4650+ grep -A 10 "^Error:" $kde_dir/$x.desktop >&2
4651+ rm $kde_dir/$x.desktop
4652+ exit 1
4653+ fi
4654+ done
4655+ fi
4656+
4657+ umask $save_umask
4658+ ;;
4659+
4660+ uninstall)
4661+ for x in $xdg_dir ; do
4662+ rm -f $x/$basefile
4663+ done
4664+
4665+ # No quotes around $mimetypes
4666+ for x in $mimetypes ; do
4667+ if grep '^# Installed by xdg-mime' $kde_dir/$x.desktop >/dev/null 2>&1; then
4668+ DEBUG 1 "Removing $kde_dir/$x.desktop (KDE 3.x support)"
4669+ rm -f $kde_dir/$x.desktop
4670+ fi
4671+ done
4672+ ;;
4673+esac
4674+
4675+update_mime_database $xdg_base_dir
4676+
4677+exit_success
4678+
4679
4680=== added file '.pc/bashisms.diff/scripts/xdg-open'
4681--- .pc/bashisms.diff/scripts/xdg-open 1970-01-01 00:00:00 +0000
4682+++ .pc/bashisms.diff/scripts/xdg-open 2014-06-16 08:53:37 +0000
4683@@ -0,0 +1,557 @@
4684+#!/bin/sh
4685+#---------------------------------------------
4686+# xdg-open
4687+#
4688+# Utility script to open a URL in the registered default application.
4689+#
4690+# Refer to the usage() function below for usage.
4691+#
4692+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
4693+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
4694+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
4695+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
4696+#
4697+# LICENSE:
4698+#
4699+# Permission is hereby granted, free of charge, to any person obtaining a
4700+# copy of this software and associated documentation files (the "Software"),
4701+# to deal in the Software without restriction, including without limitation
4702+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
4703+# and/or sell copies of the Software, and to permit persons to whom the
4704+# Software is furnished to do so, subject to the following conditions:
4705+#
4706+# The above copyright notice and this permission notice shall be included
4707+# in all copies or substantial portions of the Software.
4708+#
4709+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4710+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4711+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
4712+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
4713+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
4714+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
4715+# OTHER DEALINGS IN THE SOFTWARE.
4716+#
4717+#---------------------------------------------
4718+
4719+manualpage()
4720+{
4721+cat << _MANUALPAGE
4722+Name
4723+
4724+xdg-open - opens a file or URL in the user's preferred application
4725+
4726+Synopsis
4727+
4728+xdg-open { file | URL }
4729+
4730+xdg-open { --help | --manual | --version }
4731+
4732+Description
4733+
4734+xdg-open opens a file or URL in the user's preferred application. If a URL is
4735+provided the URL will be opened in the user's preferred web browser. If a file
4736+is provided the file will be opened in the preferred application for files of
4737+that type. xdg-open supports file, ftp, http and https URLs.
4738+
4739+xdg-open is for use inside a desktop session only. It is not recommended to use
4740+xdg-open as root.
4741+
4742+Options
4743+
4744+--help
4745+ Show command synopsis.
4746+--manual
4747+ Show this manualpage.
4748+--version
4749+ Show the xdg-utils version information.
4750+
4751+Exit Codes
4752+
4753+An exit code of 0 indicates success while a non-zero exit code indicates
4754+failure. The following failure codes can be returned:
4755+
4756+1
4757+ Error in command line syntax.
4758+2
4759+ One of the files passed on the command line did not exist.
4760+3
4761+ A required tool could not be found.
4762+4
4763+ The action failed.
4764+
4765+Examples
4766+
4767+xdg-open 'http://www.freedesktop.org/'
4768+
4769+Opens the Freedesktop.org website in the user's default browser
4770+
4771+xdg-open /tmp/foobar.png
4772+
4773+Opens the PNG image file /tmp/foobar.png in the user's default image viewing
4774+application.
4775+
4776+_MANUALPAGE
4777+}
4778+
4779+usage()
4780+{
4781+cat << _USAGE
4782+xdg-open - opens a file or URL in the user's preferred application
4783+
4784+Synopsis
4785+
4786+xdg-open { file | URL }
4787+
4788+xdg-open { --help | --manual | --version }
4789+
4790+_USAGE
4791+}
4792+
4793+#@xdg-utils-common@
4794+
4795+#----------------------------------------------------------------------------
4796+# Common utility functions included in all XDG wrapper scripts
4797+#----------------------------------------------------------------------------
4798+
4799+DEBUG()
4800+{
4801+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
4802+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
4803+ shift
4804+ echo "$@" >&2
4805+}
4806+
4807+#-------------------------------------------------------------
4808+# Exit script on successfully completing the desired operation
4809+
4810+exit_success()
4811+{
4812+ if [ $# -gt 0 ]; then
4813+ echo "$@"
4814+ echo
4815+ fi
4816+
4817+ exit 0
4818+}
4819+
4820+
4821+#-----------------------------------------
4822+# Exit script on malformed arguments, not enough arguments
4823+# or missing required option.
4824+# prints usage information
4825+
4826+exit_failure_syntax()
4827+{
4828+ if [ $# -gt 0 ]; then
4829+ echo "xdg-open: $@" >&2
4830+ echo "Try 'xdg-open --help' for more information." >&2
4831+ else
4832+ usage
4833+ echo "Use 'man xdg-open' or 'xdg-open --manual' for additional info."
4834+ fi
4835+
4836+ exit 1
4837+}
4838+
4839+#-------------------------------------------------------------
4840+# Exit script on missing file specified on command line
4841+
4842+exit_failure_file_missing()
4843+{
4844+ if [ $# -gt 0 ]; then
4845+ echo "xdg-open: $@" >&2
4846+ fi
4847+
4848+ exit 2
4849+}
4850+
4851+#-------------------------------------------------------------
4852+# Exit script on failure to locate necessary tool applications
4853+
4854+exit_failure_operation_impossible()
4855+{
4856+ if [ $# -gt 0 ]; then
4857+ echo "xdg-open: $@" >&2
4858+ fi
4859+
4860+ exit 3
4861+}
4862+
4863+#-------------------------------------------------------------
4864+# Exit script on failure returned by a tool application
4865+
4866+exit_failure_operation_failed()
4867+{
4868+ if [ $# -gt 0 ]; then
4869+ echo "xdg-open: $@" >&2
4870+ fi
4871+
4872+ exit 4
4873+}
4874+
4875+#------------------------------------------------------------
4876+# Exit script on insufficient permission to read a specified file
4877+
4878+exit_failure_file_permission_read()
4879+{
4880+ if [ $# -gt 0 ]; then
4881+ echo "xdg-open: $@" >&2
4882+ fi
4883+
4884+ exit 5
4885+}
4886+
4887+#------------------------------------------------------------
4888+# Exit script on insufficient permission to write a specified file
4889+
4890+exit_failure_file_permission_write()
4891+{
4892+ if [ $# -gt 0 ]; then
4893+ echo "xdg-open: $@" >&2
4894+ fi
4895+
4896+ exit 6
4897+}
4898+
4899+check_input_file()
4900+{
4901+ if [ ! -e "$1" ]; then
4902+ exit_failure_file_missing "file '$1' does not exist"
4903+ fi
4904+ if [ ! -r "$1" ]; then
4905+ exit_failure_file_permission_read "no permission to read file '$1'"
4906+ fi
4907+}
4908+
4909+check_vendor_prefix()
4910+{
4911+ file_label="$2"
4912+ [ -n "$file_label" ] || file_label="filename"
4913+ file=`basename "$1"`
4914+ case "$file" in
4915+ [a-zA-Z]*-*)
4916+ return
4917+ ;;
4918+ esac
4919+
4920+ echo "xdg-open: $file_label '$file' does not have a proper vendor prefix" >&2
4921+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
4922+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
4923+ echo "Use --novendor to override or 'xdg-open --manual' for additional info." >&2
4924+ exit 1
4925+}
4926+
4927+check_output_file()
4928+{
4929+ # if the file exists, check if it is writeable
4930+ # if it does not exists, check if we are allowed to write on the directory
4931+ if [ -e "$1" ]; then
4932+ if [ ! -w "$1" ]; then
4933+ exit_failure_file_permission_write "no permission to write to file '$1'"
4934+ fi
4935+ else
4936+ DIR=`dirname "$1"`
4937+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
4938+ exit_failure_file_permission_write "no permission to create file '$1'"
4939+ fi
4940+ fi
4941+}
4942+
4943+#----------------------------------------
4944+# Checks for shared commands, e.g. --help
4945+
4946+check_common_commands()
4947+{
4948+ while [ $# -gt 0 ] ; do
4949+ parm="$1"
4950+ shift
4951+
4952+ case "$parm" in
4953+ --help)
4954+ usage
4955+ echo "Use 'man xdg-open' or 'xdg-open --manual' for additional info."
4956+ exit_success
4957+ ;;
4958+
4959+ --manual)
4960+ manualpage
4961+ exit_success
4962+ ;;
4963+
4964+ --version)
4965+ echo "xdg-open 1.0.2"
4966+ exit_success
4967+ ;;
4968+ esac
4969+ done
4970+}
4971+
4972+check_common_commands "$@"
4973+
4974+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
4975+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
4976+ # Be silent
4977+ xdg_redirect_output=" > /dev/null 2> /dev/null"
4978+else
4979+ # All output to stderr
4980+ xdg_redirect_output=" >&2"
4981+fi
4982+
4983+#--------------------------------------
4984+# Checks for known desktop environments
4985+# set variable DE to the desktop environments name, lowercase
4986+
4987+detectDE()
4988+{
4989+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
4990+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
4991+ elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
4992+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
4993+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
4994+ else DE=""
4995+ fi
4996+}
4997+
4998+#----------------------------------------------------------------------------
4999+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
5000+# It also always returns 1 in KDE 3.4 and earlier
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: