summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-06 21:19:37 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-06 21:19:37 -0800
commitb962314a59ab2d558bb44fdbf87f3ac685147254 (patch)
tree9a193d0070191b6b61c867b04236fea39eff7a64
downloadxdg-utils-b962314a59ab2d558bb44fdbf87f3ac685147254.tar.gz
xdg-utils-b962314a59ab2d558bb44fdbf87f3ac685147254.tar.bz2
xdg-utils-b962314a59ab2d558bb44fdbf87f3ac685147254.zip
Imported Upstream version 20120310upstream/20120310upstream
-rw-r--r--.gitignore3
-rw-r--r--ChangeLog384
-rw-r--r--LICENSE18
-rw-r--r--Makefile.in39
-rw-r--r--README100
-rw-r--r--RELEASE_NOTES64
-rw-r--r--TODO25
-rwxr-xr-xconfigure2320
-rw-r--r--configure.ac13
-rw-r--r--install-sh251
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/HACKING17
-rw-r--r--scripts/Makefile.in116
-rw-r--r--scripts/README19
-rw-r--r--scripts/desc/xdg-copy.xml153
-rw-r--r--scripts/desc/xdg-desktop-icon.xml364
-rw-r--r--scripts/desc/xdg-desktop-menu.xml685
-rw-r--r--scripts/desc/xdg-email.xml281
-rw-r--r--scripts/desc/xdg-file-dialog.xml222
-rw-r--r--scripts/desc/xdg-icon-resource.xml372
-rw-r--r--scripts/desc/xdg-mime.xml373
-rw-r--r--scripts/desc/xdg-open.xml156
-rw-r--r--scripts/desc/xdg-screensaver.xml227
-rw-r--r--scripts/desc/xdg-settings.xml197
-rw-r--r--scripts/desc/xdg-su.xml166
-rw-r--r--scripts/desc/xdg-terminal.xml137
-rw-r--r--scripts/generate-help-script.awk110
-rw-r--r--scripts/html/.gitignore0
-rw-r--r--scripts/html/index.html19
-rw-r--r--scripts/html/index.html.post3
-rw-r--r--scripts/html/index.html.pre7
-rw-r--r--scripts/html/xdg-desktop-icon.html133
-rw-r--r--scripts/html/xdg-desktop-menu.html334
-rw-r--r--scripts/html/xdg-email.html89
-rw-r--r--scripts/html/xdg-icon-resource.html128
-rw-r--r--scripts/html/xdg-mime.html145
-rw-r--r--scripts/html/xdg-open.html38
-rw-r--r--scripts/html/xdg-screensaver.html63
-rw-r--r--scripts/html/xdg-settings.html59
-rw-r--r--scripts/man/.gitignore0
-rw-r--r--scripts/man/xdg-desktop-icon.1241
-rw-r--r--scripts/man/xdg-desktop-menu.1448
-rw-r--r--scripts/man/xdg-email.1199
-rw-r--r--scripts/man/xdg-icon-resource.1244
-rw-r--r--scripts/man/xdg-mime.1286
-rw-r--r--scripts/man/xdg-open.1124
-rw-r--r--scripts/man/xdg-screensaver.1154
-rw-r--r--scripts/man/xdg-settings.1154
-rwxr-xr-xscripts/xdg-copy303
-rw-r--r--scripts/xdg-copy.in106
-rwxr-xr-xscripts/xdg-desktop-icon562
-rw-r--r--scripts/xdg-desktop-icon.in160
-rwxr-xr-xscripts/xdg-desktop-menu1227
-rw-r--r--scripts/xdg-desktop-menu.in628
-rwxr-xr-xscripts/xdg-email727
-rw-r--r--scripts/xdg-email.in411
-rwxr-xr-xscripts/xdg-file-dialog603
-rw-r--r--scripts/xdg-file-dialog.in365
-rwxr-xr-xscripts/xdg-icon-resource844
-rw-r--r--scripts/xdg-icon-resource.in450
-rwxr-xr-xscripts/xdg-mime1216
-rw-r--r--scripts/xdg-mime.in918
-rwxr-xr-xscripts/xdg-open558
-rw-r--r--scripts/xdg-open.in348
-rwxr-xr-xscripts/xdg-screensaver938
-rw-r--r--scripts/xdg-screensaver.in627
-rwxr-xr-xscripts/xdg-settings1078
-rw-r--r--scripts/xdg-settings.in752
-rwxr-xr-xscripts/xdg-su438
-rw-r--r--scripts/xdg-su.in161
-rwxr-xr-xscripts/xdg-terminal484
-rw-r--r--scripts/xdg-terminal.in200
-rw-r--r--scripts/xdg-utils-common.in330
-rw-r--r--scripts/xsl/README23
-rw-r--r--scripts/xsl/refentry2htmlindex.xsl20
-rw-r--r--scripts/xsl/sharedmime-list.xsl13
-rw-r--r--scripts/xsl/sharedmime2mimelnk.xsl32
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.in45
-rw-r--r--tests/NOTES8
-rw-r--r--tests/README124
-rw-r--r--tests/TODO23
-rw-r--r--tests/debug/README5
-rwxr-xr-xtests/debug/t.extraout17
-rwxr-xr-xtests/debug/t.failoverride17
-rwxr-xr-xtests/debug/t.interactive20
-rwxr-xr-xtests/debug/t.nodisplay35
-rwxr-xr-xtests/debug/t.var_bleed55
-rwxr-xr-xtests/doc_gen.pl164
-rwxr-xr-xtests/generic/t.bogus_arg25
-rwxr-xr-xtests/generic/t.help25
-rwxr-xr-xtests/generic/t.manual25
-rwxr-xr-xtests/generic/t.no_arg25
-rwxr-xr-xtests/generic/t.version26
-rw-r--r--tests/icons/red-128.pngbin0 -> 2687 bytes
-rw-r--r--tests/icons/red-128.xcfbin0 -> 4034 bytes
-rw-r--r--tests/icons/red-16.pngbin0 -> 476 bytes
-rw-r--r--tests/icons/red-16.xcfbin0 -> 1539 bytes
-rw-r--r--tests/icons/red-22.pngbin0 -> 608 bytes
-rw-r--r--tests/icons/red-22.xcfbin0 -> 1655 bytes
-rw-r--r--tests/icons/red-24.pngbin0 -> 602 bytes
-rw-r--r--tests/icons/red-24.xcfbin0 -> 1715 bytes
-rw-r--r--tests/icons/red-32.pngbin0 -> 889 bytes
-rw-r--r--tests/icons/red-32.xcfbin0 -> 1974 bytes
-rw-r--r--tests/icons/red-48.pngbin0 -> 1361 bytes
-rw-r--r--tests/icons/red-48.xcfbin0 -> 2734 bytes
-rw-r--r--tests/icons/red-64.pngbin0 -> 1570 bytes
-rw-r--r--tests/icons/red-64.xcfbin0 -> 3079 bytes
-rw-r--r--tests/icons/red-SVG.svg6
-rw-r--r--tests/icons/red-template.xcfbin0 -> 3607 bytes
-rwxr-xr-xtests/include/desktop_environment56
-rwxr-xr-xtests/include/linux_distro209
-rwxr-xr-xtests/include/listargs10
-rwxr-xr-xtests/include/system_info23
-rw-r--r--tests/include/tempfile.sh47
-rw-r--r--tests/include/testassertions.sh379
-rw-r--r--tests/include/testcontrol.sh121
-rw-r--r--tests/include/testfuncs.sh138
-rwxr-xr-xtests/spec/test_specification.odtbin0 -> 26774 bytes
-rwxr-xr-xtests/spec/test_specification.pdfbin0 -> 148260 bytes
-rwxr-xr-xtests/testrun226
-rwxr-xr-xtests/tet_run36
-rw-r--r--tests/xdg-desktop-icon/data/desktop_icon_install.desktop9
-rwxr-xr-xtests/xdg-desktop-icon/t.00-apply_generic13
-rwxr-xr-xtests/xdg-desktop-icon/t.01-notexist_file_uninstall37
-rwxr-xr-xtests/xdg-desktop-icon/t.02-plain_file_install43
-rwxr-xr-xtests/xdg-desktop-icon/t.03-plain_file_uninstall40
-rwxr-xr-xtests/xdg-desktop-icon/t.04-desktop_icon_install53
-rwxr-xr-xtests/xdg-desktop-icon/t.05-desktop_icon_uninstall44
-rw-r--r--tests/xdg-desktop-menu/data/menu_install.directory3
-rwxr-xr-xtests/xdg-desktop-menu/data/menu_item_category.desktop6
-rw-r--r--tests/xdg-desktop-menu/data/menu_item_dummy.desktop5
-rw-r--r--tests/xdg-desktop-menu/data/menu_item_dummy2.desktop5
-rw-r--r--tests/xdg-desktop-menu/data/menu_item_test.desktop5
-rwxr-xr-xtests/xdg-desktop-menu/data/shinythings_example/install-webmirror.sh34
-rwxr-xr-xtests/xdg-desktop-menu/data/shinythings_example/webmirror-admin.desktop9
-rwxr-xr-xtests/xdg-desktop-menu/data/shinythings_example/webmirror.desktop10
-rwxr-xr-xtests/xdg-desktop-menu/data/shinythings_example/webmirror.directory7
-rwxr-xr-xtests/xdg-desktop-menu/data/shinythings_example/webmirror.menu13
-rwxr-xr-xtests/xdg-desktop-menu/t.00-apply_generic13
-rwxr-xr-xtests/xdg-desktop-menu/t.01-menu_user_forceupdate24
-rwxr-xr-xtests/xdg-desktop-menu/t.02-menu_system_as_nonroot40
-rwxr-xr-xtests/xdg-desktop-menu/t.03-menu_system_forceupdate25
-rwxr-xr-xtests/xdg-desktop-menu/t.10-simple_menu_item_user_install60
-rwxr-xr-xtests/xdg-desktop-menu/t.12-menu_user_install68
-rwxr-xr-xtests/xdg-desktop-menu/t.13-menu_user_uninstall61
-rwxr-xr-xtests/xdg-desktop-menu/t.14-menu_install_category53
-rwxr-xr-xtests/xdg-desktop-menu/t.15-menu_advanced_install87
-rwxr-xr-xtests/xdg-desktop-menu/t.20-simple_menu_item_system_install61
-rwxr-xr-xtests/xdg-desktop-menu/t.22-menu_system_install67
-rwxr-xr-xtests/xdg-desktop-menu/t.23-menu_system_uninstall67
-rwxr-xr-xtests/xdg-email/t.00-apply_generic12
-rwxr-xr-xtests/xdg-email/t.10-email_basic31
-rwxr-xr-xtests/xdg-email/t.12-email_cc_args43
-rwxr-xr-xtests/xdg-email/t.13-email_multi_address43
-rwxr-xr-xtests/xdg-email/t.21-email_uri_multi_address36
-rwxr-xr-xtests/xdg-email/t.22-email_mix_args_uri36
-rwxr-xr-xtests/xdg-email/t.30-email_attach38
-rwxr-xr-xtests/xdg-email/t.31-email_attach_full_path38
-rwxr-xr-xtests/xdg-email/t.32-email_missing_attach34
-rwxr-xr-xtests/xdg-icon-resource/t.apply_generic13
-rwxr-xr-xtests/xdg-icon-resource/t.icon_duplicate_install42
-rwxr-xr-xtests/xdg-icon-resource/t.icon_nonexist_uninstall38
-rwxr-xr-xtests/xdg-icon-resource/t.icon_system_as_nonroot42
-rwxr-xr-xtests/xdg-icon-resource/t.icon_system_install44
-rwxr-xr-xtests/xdg-icon-resource/t.icon_system_uninstall40
-rwxr-xr-xtests/xdg-icon-resource/t.icon_user_install40
-rwxr-xr-xtests/xdg-icon-resource/t.icon_user_uninstall39
-rw-r--r--tests/xdg-mime/data/test2mime.xml11
-rw-r--r--tests/xdg-mime/data/testmime.xml7
-rwxr-xr-xtests/xdg-mime/t.00-apply_generic13
-rwxr-xr-xtests/xdg-mime/t.01-query_text_plain34
-rwxr-xr-xtests/xdg-mime/t.02-query_missing_file30
-rwxr-xr-xtests/xdg-mime/t.03-system_as_nonroot50
-rwxr-xr-xtests/xdg-mime/t.10-user_mime_install52
-rwxr-xr-xtests/xdg-mime/t.11-user_mime_uninstall51
-rwxr-xr-xtests/xdg-mime/t.12-user_install_missing_file28
-rwxr-xr-xtests/xdg-mime/t.13-notexist_mime_uninstall44
-rwxr-xr-xtests/xdg-mime/t.14-user_mime_install2in161
-rwxr-xr-xtests/xdg-mime/t.15-user_mime_uninstall2in166
-rwxr-xr-xtests/xdg-mime/t.20-system_mime_install47
-rwxr-xr-xtests/xdg-mime/t.21-system_mime_uninstall53
-rwxr-xr-xtests/xdg-mime/t.22-system_install_missing_file31
-rwxr-xr-xtests/xdg-mime/t.23-double_mime_install48
-rwxr-xr-xtests/xdg-open/t.00-apply_generic14
-rwxr-xr-xtests/xdg-open/t.01-open_basic35
-rwxr-xr-xtests/xdg-open/t.02-open_dir30
-rwxr-xr-xtests/xdg-open/t.03-open_url30
-rwxr-xr-xtests/xdg-open/t.04-open_html34
-rwxr-xr-xtests/xdg-open/t.05-open_abs_path_html34
-rwxr-xr-xtests/xdg-screensaver/t.00-apply_generic13
-rwxr-xr-xtests/xdg-screensaver/t.01-screensave_status32
-rwxr-xr-xtests/xdg-screensaver/t.02-screensave_suspend_basic40
-rwxr-xr-xtests/xdg-screensaver/t.03-screensave_resume_basic43
-rwxr-xr-xtests/xdg-screensaver/t.10-screensave_activate43
-rwxr-xr-xtests/xdg-screensaver/t.11-screensave_reset41
-rwxr-xr-xtests/xdg-screensaver/t.12-screensave_lock44
-rwxr-xr-xtests/xdg-su/t.00-apply_generic13
-rwxr-xr-xtests/xdg-su/t.01-su_basic_asroot29
-rwxr-xr-xtests/xdg-su/t.02-su_basic34
-rwxr-xr-xtests/xdg-su/t.03-su_badpass30
-rwxr-xr-xtests/xdg-su/t.04-su_no_carg24
-rwxr-xr-xtests/xdg-su/t.05-su_no_cflag25
-rw-r--r--tests/xdg-utils-usecases/data/icon_file.xml7
-rw-r--r--tests/xdg-utils-usecases/data/icon_test.desktop10
-rw-r--r--tests/xdg-utils-usecases/data/menu_install.directory4
-rw-r--r--tests/xdg-utils-usecases/data/menu_item_dummy.desktop5
-rw-r--r--tests/xdg-utils-usecases/data/mime_launch.desktop7
-rwxr-xr-xtests/xdg-utils-usecases/data/mime_launch.sh2
-rw-r--r--tests/xdg-utils-usecases/data/mime_launch.xml7
-rw-r--r--tests/xdg-utils-usecases/data/testfilebin0 -> 1024 bytes
-rwxr-xr-xtests/xdg-utils-usecases/t.01-default_mime_launch77
-rwxr-xr-xtests/xdg-utils-usecases/t.10-file_icon85
-rwxr-xr-xtests/xdg-utils-usecases/t.11-desktop_file_icon68
-rwxr-xr-xtests/xdg-utils-usecases/t.14-desktop_menu_icon66
215 files changed, 29217 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..16b8c45
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+Makefile
+config.log
+config.status
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e961e2a
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,384 @@
+=== xdg-utils 1.1.x ===
+
+2012-03-10 Rex Dieter <rdieter@fedoraproject.org>
+ * allow DESKTOP_SESSION='Xfce Session' to match xfce
+
+2012-03-02 Rex Dieter <rdieter@fedoraproject.org>
+ * "unknown DE" improvements (BR45295)
+ * xdg-terminal incompatible with TERM=screen and TERM=rxvt-unicode (BR44357)
+ * xdg-terminal doesn't handle TERM values like TERM=linux (BR44358)
+ * add lubuntu support (BR44775)
+ * xdg-open replaces "&" with "%U" in URLs (BR46002)
+
+2011-12-09 Rex Dieter <rdieter@fedoraproject.org>
+ * initial DE=mate support (mostly just xdg-open so far)
+
+2011-12-07 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-screensaver: gnome-screensaver detection broken (BR43575)
+ * xdg-open: fix spurious 'x-www-browser: command not found' (RH755553)
+
+2011-09-30 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open: use x-scheme-handler/ instead of uri/ (BR35700)
+
+2011-09-28 Rex Dieter <rdieter@fedoraproject.org>
+ * Documentation spelling fixes (BR41193). Thanks to Ville Skyttä
+ * Fix external links in docs, use <ulink> for them (BR41194). Thanks to
+ Ville Skyttä
+ * Avoid some unnecessary stat calls (BR41195). Thanks to Ville Skyttä
+ * xdg-open: improve debugging output (BR40959)
+ * xdg-open: look up default applications by URI scheme (BR35700)
+ * xdg-settings: support registering default scheme handler (merge from
+ chromium folks)
+
+2011-08-29 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open cant open some valid urls if URL doesnt match existing
+ filename (BR34915). Thanks to Leho Kraav.
+
+2011-08-27 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-terminal fails to open terminal on generic desktop (BR40418)
+
+2011-08-12 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-email fails with unicode strings if using gawk (BR13139)
+ * xdg-email: Thunderbird 5 needs unescaped addresses (BR40041)
+
+2011-08-11 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-terminal : remove remaining '==' bash'isms (BR38959)
+
+2011-07-19 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-utils-common.in: support $XDG_CURRENT_DESKTOP
+
+2011-07-13 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-mime : use 'file --mime-type' instead of 'file -i' (BR39166)
+
+2011-05-10 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-mime : handle home dirs with spaces, mimeapps.list not existing. Thanks to Mike Mammarella.
+
+2011-05-05 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-utils-common.in : add missing ;;
+
+2011-05-04 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-utils-common.in : move a couple of utility functions here (from
+ xdg-settings), needed for xdg-email
+ * xdg-utils-common.in : binary_to_desktop_file, handle vendor dirs
+
+2011-04-20 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-desktop-icon does not work when user desktop dir has spaces (BR36417)
+
+2011-04-14 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open does not detect xfce (BR25941)
+ * xdg-open's list of fallback browsers excludes seamonkey (BR33699)
+ * text BROWSER=+elinks
+ * xdg-open is sensitive to default grep options (BR34164)
+ * xdg-{open,email} should try x-www-browser (BR33095)
+ * xdg-email outputs errors with localized KDE4 (BR32924)
+ * xdg-email runs kmailservice with incorrect locale (BR33106)
+ * spurious capture of which in KMIMETYPEFINDER (BR31444)
+
+2011-04-12 Rex Dieter <rdieter@fedoraproject.org>
+ * suppress 'which gnome-default-applications-properties' output. Thanks to Mike Mammarella.
+
+2011-04-08 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-mime: add mimeapps.list support. Thanks to Chris Coulson.
+
+2011-03-31 Rex Dieter <rdieter@fedoraproject.org>
+ * Don't overwrite a /usr/share/applications/defaults.list symlink (BR35794)
+ * Use D-Bus API for GNOME screensaver (BR29860)
+ * Initial support for DE=Darwin, Default for $BROWSER under Mac OS (BR35500)
+
+2011-03-28 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open cannot detect xfce 4.8 correctly (BR33321)
+ * xdg-mime's info_generic doesn't normalize symlinks (BR33097)
+ * mimetype support for xdg-mime (generic) (BR33094)
+ * open_generic_xdg_mime is broken when a .desktop file
+ Exec has arguments (BR30453)
+
+2011-02-01 Rex Dieter <rdieter@fedoraproject.org>
+ * add support for GNOME 3.x
+
+2011-01-09 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-email: call kfmclient_fix_exit_code() under KDE 3 only.
+ Thanks to Luc Menut. (BR32924)
+ * xdg-utils-common: set C.UTF-8 locale to make sure the version parsing is
+ done as expected. Under some locales the KDE version string doesn't start
+ with "KDE".
+ * xdg-terminal: Fix failure because the which std output is wrongly
+ redirected to /dev/null in terminal_kde(). Thanks to Luc Menut.
+ (BR32927)
+
+=== xdg-utils 1.1.0-rc1 ===
+
+2010-12-31 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-mime: correct install text to use type/subtype.
+ Thanks to Christopher Yeleighton. (BR31441)
+ * xdg-open: declare file variable as local. (BR32487)
+ * xdg-open: decode file:// urls. Thanks to Henning Garus.
+ * xdg-screensaver: support X server blanking. Thanks to Ben Hutchings.
+
+2010-11-18 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-utils-common: fixup kfmclient_fix_exit_code() for newer kde-config
+ output
+ * xdg-mime: fix typo in manpage
+ * xdg-email: Thunderbird is not detected with localized (BR31740)
+
+2010-10-28 Rex Dieter <rdieter@fedoraproject.org>
+ * add lxde support (BR26058)
+
+2010-09-25 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-settings: Only run KDE browser fallback when necessary. Otherwise,
+ in some circumstances, read_kde_browser incorrectly prints the result
+ twice. Thanks to David Benjamin.
+
+2010-09-24 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-email: Fix e-mail attachements support with Thunderbird3 (BR13435)
+
+2010-09-24 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-mime: update the required section "[Added Associations]"
+ Thanks to Mike Mammarella:
+
+2010-09-24 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-email: Fix missing backslash in awk script so that it works with
+ mawk.
+
+2010-09-24 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-desktop-icon: set the execute bit to desktop file.
+ Thanks to Damjan Jovanovic. (BR28394)
+
+2010-07-09 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-screensaver: consider gnome-screensaver a separate DE (BR20027)
+
+2010-07-09 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-mime : use 'gnomevfs-info --slow-mime' (BR 13939)
+
+2010-07-09 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-desktop-icon : use localized desktop folder name (BR19011)
+
+2010-07-09 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open : use mimeopen -L (follow symlinks)
+
+2010-07-09 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open.1 : add FILES, SEE ALSO sections
+
+2010-05-16 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-open: Spaces in filename (BR27959)
+
+2010-04-22 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-email and xdg-open: perform BROWSER check in any case.
+ Thanks to Andrea Florio. (BR27551)
+
+2010-04-22 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-email: try console mode browsers and update the browser list.
+
+2010-02-28 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-utils-common: fix the comment of exit_failure_file_permission_write
+ function. (BR12821)
+
+2010-02-28 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-open: fix regression in open_generic as xdg-mime doesn't handle
+ URLs (mimeopen and run-mailcap as well). Move xdg-mime call into
+ a new function (open_generic_xdg_mime). Check input file before
+ trying to open them with non-browsers.
+
+2010-02-28 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-open: fix failure if $BROWSER has arguments. (BR14374)
+ Thanks to Johannes Wegener.
+
+2010-02-28 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-open: try console mode browsers and update the browser list.
+ Thanks to Ville Skyttä and Pablo Castellano. (BR14361)
+
+2010-02-24 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-screensaver: use dbus-send instead of qdbus for freedesktop
+ screensaver.
+
+2010-02-23 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-mime: improve MIME string check when using gnomevfs-info. (BR12818)
+
+2010-02-23 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-mime: report error on failure.
+
+2010-02-21 Fathi Boudra <fabo@freedesktop.org>
+ * xdg-open: in open_generic, use xdg-mime to lookup mime type and
+ association before the alternatives methods (mimeopen and run-mailcap).
+ (BR23280)
+
+2010-02-20 Fathi Boudra <fabo@freedesktop.org>
+ * Add gvfs-copy and gvfs-info support. (BR15828)
+
+2010-01-27 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-settings: Add %s to the command in the Gnome url handlers (BR26284)
+
+2010-01-18 Rex Dieter <rdieter@fedoraproject.org>
+ * xdg-screensaver resume activates the screensaver on KDE4 (BR26085)
+
+2009-10-16 Rex Dieter <rdieter@fedoraproject.org>
+ * prefer gvfs-open over gnome-open
+ * DE=gnome, if org.gnome.SessionManager exists on dbus
+
+2009-10-12 Fathi Boudra <fabo@freedesktop.org>
+ * Fix xdg-email --attach failure with Evolution. (BR23007)
+ Thanks to Dwayne Bailey <dwayne@translate.org.za>
+
+2009-10-12 Fathi Boudra <fabo@freedesktop.org>
+ * Add an extra check in xdg-open and call kfmclient openURL as a fallback
+ on KDE 4. Thanks to Nicolas Lécureil <neoclust@mandriva.org>
+
+2009-10-12 Fathi Boudra <fabo@freedesktop.org>
+ * Add email attachments support to Thunderbird from xdg-email. (BR13435)
+ Thanks to Lei Zhang <thestig@google.com>
+
+2009-10-12 Fathi Boudra <fabo@freedesktop.org>
+ * Fix xdg-open to handle URL with '#' symbol. (BR23319, BR24375)
+
+2009-10-12 Fathi Boudra <fabo@freedesktop.org>
+ * Remove bash requirement to xdg-open and xdg-email. (BR20015)
+
+2009-10-12 Fathi Boudra <fabo@freedesktop.org>
+ * Update xdg-settings - Thanks to Mike Mammarella:
+ This fixes some issues where user-generated icons would be detected as
+ the official .desktop file for a binary, rather than the actual version.
+ (It resolves forward and compares binaries rather than resolving backward
+ to a .desktop file from a binary)
+
+2009-09-28 Rex Dieter <rdieter@fedoraproject.org>
+ * Use kde-open, if available (ie, KDE 4)
+
+2009-09-13 Rex Dieter <rdieter@fedoraproject.org>
+ * detect_de: suppress xprop stderr.
+
+2009-08-25 Rex Dieter <rdieter@fedoraproject.org>
+ * fix build for missing manpages (eg. xdg-settings)
+
+2009-08-25 Fathi Boudra <fabo@freedesktop.org>
+ * Fix hardcoded KDE home directory. Use kde(4)-config to get path.
+
+2009-08-25 Fathi Boudra <fabo@freedesktop.org>
+ * Apply patch from Mike Mammarella <mdm@chromium.org> to fix 2 issues:
+ - skip invisible desktop files when looking up the default web browser in
+ GNOME. (http://codereview.chromium.org/159738)
+ - check for localized settings by hand in xdg-settings if kreadconfig
+ fails. (http://codereview.chromium.org/160376)
+
+2009-08-10 Fathi Boudra <fabo@freedesktop.org>
+ * Replace kfmclient by kioclient usage under KDE 4.
+ Thanks to Nicolas Lécureil <neoclust@mandriva.org>
+
+2009-08-03 Fathi Boudra <fabo@freedesktop.org>
+ * Remove fixup_mandriva_categories() function. It is not needed anymore
+ since a year. Thanks to Nicolas Lécureil <neoclust@mandriva.org>
+
+2009-07-29 Fathi Boudra <fabo@freedesktop.org>
+ * Merge xdg-settings utility: a script to get various settings from
+ the desktop environment. Thanks to Dan Kegel and Google Inc.
+
+2009-07-29 Fathi Boudra <fabo@freedesktop.org>
+ * Fix hardcoded path in make_default_kde() in xdg-mime unde KDE 3.
+ Add initial KDE 4 support to the function.
+
+2009-07-28 Fathi Boudra <fabo@freedesktop.org>
+ * Use kbuildsycoca4 under KDE 4 and kbuildsycoca under KDE 3.
+
+2009-07-28 Fathi Boudra <fabo@freedesktop.org>
+ * Use kmimetypefinder under KDE 4 and kfile under KDE 3.
+
+2009-07-28 Fathi Boudra <fabo@freedesktop.org>
+ * Add KDE 4 support to xdg-mime. kdetradertest was replaced by
+ ktraderclient under KDE 4. (BR22975)
+
+2009-07-27 Fathi Boudra <fabo@freedesktop.org>
+ * Remove -u option from su. It doesn't have it.
+
+2009-07-27 Fathi Boudra <fabo@freedesktop.org>
+ * Add KDE 4 support to xdg-email (BR17268)
+
+2009-07-26 Fathi Boudra <fabo@freedesktop.org>
+ * Sleep for 50s instead of 59s to avoid to froze the seesion (BR19414)
+
+2009-07-26 Fathi Boudra <fabo@freedesktop.org>
+ * Fix a race condition in xdg-screensaver (BR19382)
+
+2009-07-26 Fathi Boudra <fabo@freedesktop.org>
+ * Fix basename usage when filename contains spaces (BR18567)
+
+2009-07-26 Fathi Boudra <fabo@freedesktop.org>
+ * Fix bashisms used in xdg-mime and xdg-screensaver (BR15827)
+
+2008-08-11 Rex Dieter <rdieter@fedoraproject.org>
+ * initial support for KDE 4
+ * Add dbus commands to xdg-screensaver for KDE 4 (BR17537)
+
+2008-01-24 Kevin Krammer <kevin.krammer@gmx.at>
+ * Fixing security issue in xdg-email and xdg-open at replacing
+ parameter in $BROWSER
+
+2007-06-27 Waldo Bastian <waldo.bastian@intel.com>
+ * Fix xdg-mime query filetype on XFCE (BR11383)
+
+=== xdg-utils 1.0.2 ====
+
+=== xdg-utils 1.0.1 ====
+
+2006-11-03 Waldo Bastian <waldo.bastian@intel.com>
+ * Fixed spurious output on stdout by xdg-desktop-menu
+ * Cleaned up shell syntax for xdg-screensaver and xdg-icon-resource
+ (fixes Ubuntu 6.10)
+
+2006-10-29 Kevin Krammer <kevin.krammer@gmx.at>
+ * Fixed non-ascii mailto URI handling of xdg-emial on non-UTF8 locales
+ under KDE
+
+=== xdg-utils 1.0 ====
+
+2006-05-10 Bryce Harrington <bryce@osdl.org>
+ * Created xdg-screensaver
+
+2006-04-24 Kevin Krammer <kevin.krammer@gmx.at>
+ * Applied patch provided by Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de>
+ to improve the compatability of the Makefile
+ * Added --title option to xdg-file-dialog
+ * Applied another path by Benedikt to let xdg-file-dialog use
+ zenity on GNOME and XFCE
+ * Added a documentation extraction AWK script created by Benedikt which replaces
+ the sed code and adds extraction of examples additionally to the usage info.
+ * Added printing of examples to the --help command.
+
+2006-04-14 Kevin Krammer <kevin.krammer@gmx.at>
+ * Added documentation for --version to all xml files
+ * Added script for file selection task, e.g. using the native file dialog
+ to get a file or directory name
+
+2006-04-11 Kevin Krammer <kevin.krammer@gmx.at>
+ * Applied exit functions to the other scripts
+ * Added a function to check for common commands like --help or --version
+ and always perform the same reaction
+
+2006-04-10 Kevin Krammer <kevin.krammer@gmx.at>
+ * Added common exit functions to improve return value consistency.
+ Currently only used in xdg-mime to gather feedback
+
+2006-04-08 Kevin Krammer <kevin.krammer@gmx.at>
+ * In case of $BROWSER being not avialable or empty, try a fixed list of well
+ known browsers instead
+
+2006-04-06 Kevin Krammer <kevin.krammer@gmx.at>
+ * Fixed "detection" of generic case in xdg-mime, xdg-open and xdg-su as
+ discovered by Hagai Kariti <hobbithk@gmail.com>
+ * Fixed tailoring of file and gnomevf-info output by using "sed" to remove a leading
+ whitespace instead of "cut"
+
+2006-04-05 Kevin Krammer <kevin.krammer@gmx.at>
+ * Applied patch by Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de> which
+ adds detection for XFCE, XFCE paths for xdg-open and xdg-email and
+ which fixes the script for non-bash shells.
+
+2006-03-31 Waldo Bastian <waldo.bastian@intel.com>
+ * Generate usage instructions from the same XML that is used for manpages
+ * Included licence text in scripts
+ * Added xdg-desktop script
+ * Added documentation (DocBook, HTML, manpages)
+ * Have Makefile generate manpages
+ * Included fix for xdg-su provided by Jeremy White <jwhite@codeweavers.com>
+ * Added "release" target to Makefile for generating releases
+ * Added support for .directory and .menu files to xdg-menu
+
+2006-03-21 Kevin Krammer <kevin.krammer@gmx.at>
+ * Imported the current state into freedesktop.org CVS for easier shared development
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..1edf08c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,18 @@
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..37a025b
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,39 @@
+SUBDIRS = scripts tests
+
+all: $(SUBDIRS)
+install: $(SUBDIRS:%=%/__install__)
+uninstall: $(SUBDIRS:%=%/__uninstall__)
+test: dummy
+ cd tests && $(MAKE) test
+clean: $(SUBDIRS:%=%/__clean__)
+distclean: clean $(SUBDIRS:%=%/__distclean__)
+ rm -f config.* Makefile
+ rm -rf autom4te.cache
+
+release: $(SUBDIRS:%=%/__release__) distclean
+ rm -f *~
+
+help:
+ @echo "Usage: make [install|uninstall|release]"
+
+.PHONY: all install uninstall clean distclean dummy
+dummy:
+
+$(SUBDIRS): dummy
+ @cd $@ && $(MAKE)
+
+$(SUBDIRS:%=%/__uninstall__): dummy
+ cd `dirname $@` && $(MAKE) uninstall
+
+$(SUBDIRS:%=%/__install__): dummy
+ cd `dirname $@` && $(MAKE) install
+
+$(SUBDIRS:%=%/__clean__): dummy
+ cd `dirname $@` && $(MAKE) clean
+
+$(SUBDIRS:%=%/__release__): dummy
+ cd `dirname $@` && $(MAKE) release
+
+$(SUBDIRS:%=%/__distclean__): dummy
+ cd `dirname $@` && $(MAKE) distclean
+
diff --git a/README b/README
new file mode 100644
index 0000000..e680e47
--- /dev/null
+++ b/README
@@ -0,0 +1,100 @@
+xdg-utils
+---------
+
+ The xdg-utils package is a set of simple scripts that provide
+basic desktop integration functions for any Free Desktop, such as Linux.
+
+ They are intended to provide a set of defacto standards. This
+means that:
+ * Third party software developers can rely on these xdg-utils
+ for all of their simple integration needs.
+
+ * Developers of desktop environments can make sure that their
+ environments are well supported
+
+ If a desktop developer wants to be certain that their environment
+ functions with all third party software, then can simply
+ make sure that these utilities work properly in their environment.
+
+ This will hopefully mean that 'third tier' window managers
+ such as XFCE and Blackbox can reach full parity with Gnome and KDE
+ in terms of third party ISV support.
+
+ * Distribution vendors can provide custom versions of these utilities
+
+ If a distribution vendor wishes to have unusual systems,
+ they can provide custom scripts, and the third party software
+ should still continue to work.
+
+
+OVERVIEW:
+---------
+
+ The following tools are included in xdg-utils 1.0:
+
+xdg-desktop-menu Install desktop menu items
+xdg-desktop-icon Install icons to the desktop
+xdg-icon-resource Install icon resources
+xdg-mime Query information about file type handling and
+ install descriptions for new file types
+xdg-open Open a file or URL in the user's preferred application
+xdg-email Send mail using the user's preferred e-mail composer
+xdg-screensaver Control the screensaver
+
+
+BUILD:
+------
+
+ Building is not required, all tools are located in the
+scripts/ subdirectory and are ready to be used.
+
+ You can optionally choose to install the scripts
+to a target directory. To do this, you could issue
+the following commands:
+ ./configure [--prefix=<your-place-here>]
+ make install
+that would cause the scripts to be installed to
+ <your-place-here>/bin
+
+
+USE:
+----
+
+ Although we expect that these scripts will generally come as part
+of the operating system, we recommend that you package the scripts
+that your application needs along with your product as a fallback. For
+this purpose please obtain the original version of the xdg-utils from
+http://portland.freedesktop.org. The xdg-utils scripts that are
+distributed by operating systems vendors may have been tuned for their
+particular operating system and may not work on the same broad variety
+of operating systems as the original version.
+
+ We recommend that you place these scripts in a directory, and
+then add that directory to the end of the PATH. So, let's say that
+you're writing your post installation script, and you want to create
+a menu on any xdg-util compliant environment. Let's further assume
+that you've just installed to $INSTALL_DIR, and that your menu
+desktop file is in $INSTALL_DIR/desktop/icon.desktop. Finally, let's
+say that you've included the xdg-utils package in your installation
+in $INSTALL_DIR/xdg-utils.
+
+ Then a simple post install script could look like this:
+
+ export PATH=$PATH:$INSTALL_DIR/xdg-utils
+ xdg-desktop-menu install $INSTALL_DIR/mycompany-myapp.desktop
+
+ And now your product has a menu on any XDG compliant desktop!
+
+Note that we strongly recommend using this method - that is,
+putting your copy of the xdg-utils at the end of the path,
+and then invoking them without a specific path name.
+
+That will allow your users and their system providers to
+use custom versions of the xdg-utils to adjust for system specific
+differences.
+
+If you wish to absolutely force the issue and only use the versions
+you shipped, you could instead hard code the path to the version
+you bundle with your application. We strongly recommend against
+this, as it will make your product obsolete more quickly than is
+necessary.
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
new file mode 100644
index 0000000..f2df578
--- /dev/null
+++ b/RELEASE_NOTES
@@ -0,0 +1,64 @@
+Release notes for xdg-utils 1.0.2
+=================================
+
+This release fixes:
+* SVG icons are not supported but documentation still mentioned SVG
+* xdg-email can now be used without any e-mail address
+* Don't use mktemp without arguments, it breaks on systems with certain
+ older versions of mktemp (xdg-desktop-menu, xdg-screensaver)
+
+Release notes for xdg-utils 1.0.1
+=================================
+
+This release fixes:
+* Several shell syntax issues causing failures on Ubuntu 6.10
+* Spurious output on stdout when running xdg-desktop-menu
+* Non-ascii mailto URI handling of xdg-emial on non-UTF8 locales under KDE
+
+Release notes for xdg-utils 1.0
+===============================
+
+xdg-utils 1.0 has been tested under the Gnome and KDE desktop environments
+on Debian, Fedora, Kubuntu, Mandriva, Redhat RHEL4, SUSE, Ubuntu and Xandros
+based Linux systems. These release notes reflect test findings. Despite
+extensive testing it should be pointed out that xdg-utils is provided AS IS
+without warranty of any kind. See the LICENSE file for details.
+
+* general:
+ - When installing applications or file types for the current user only
+ (user mode) it may be necessary to restart the session in order for
+ the panel and filemanager to show the correct icons. This problem
+ typically occurs when the installation process required new
+ (hidden) directories to be created under the user's home directory.
+
+* xdg-mime:
+ - xdg-mime query filetype may fail under Gnome on certain Debian
+ systems that do not have gnomevfs-info installed by default.
+
+* xdg-desktop-menu:
+ - On Redhat RHEL 4 systems running Gnome, new submenus will not appear
+ until the session is restarted. For testing purposes the command
+ "killall gnome-panel" can be used instead of restarting the session.
+ It is not recommended to use this as part of installation scripts
+ though.
+
+ - KDE based desktops may require several seconds to update the
+ application menu after installing new items. The user may need to
+ close the applications menu first before new items will show up.
+
+ - On SUSE systems, desktop entries that list any of the standard
+ menu Categories are often being placed in a "More Programs" submenu
+ which makes them somewhat hard to find.
+
+* xdg-screensaver:
+ - Screensaver locking does not work on KDE under SUSE 10.0
+
+* xdg-email:
+ - Please refer to http://portland.freedesktop.org/wiki/EmailConfig
+ for additional information on setting up the default E-mail client.
+
+ - With current versions of Mozilla Thunderbird it is not possible to
+ specify attachments. In order to send an attachment, the user will
+ need to attach the file manually.
+
+ - Older versions of KMail do not support multiple To or CC recipients.
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..854bae4
--- /dev/null
+++ b/TODO
@@ -0,0 +1,25 @@
+xdg-icon-resource
+* Add pre-XDG Base Dir gnome-support
+* Add "query theme"
+* Add "query lookup"
+
+xdg-email
+* revisit decision to disable &attach= in mailto URLs
+
+xdg-screensaver
+* Return error when WindowID doesn't exist
+* support dbus org.freedesktop.ScreenSaver methods
+
+General
+* Support XDG_DATA_INSTALL
+* Support XDG_INSTALL_HOOK
+* Use "FILE" as argument everywhere instead of "file"
+* Add xdg-autostart
+
+xdg-su:
+* The summary is incorrect, it suggests that it can only run things as
+root which is incorrect according to the main body of the document.
+* The -c option is listed in the synopsis, but not in options.
+* It would be useful if it was possible to distinguish between a failure
+because of a bad password or some other failure.
+* use sudo style syntax, drop -c option
diff --git a/configure b/configure
new file mode 100755
index 0000000..32dfc62
--- /dev/null
+++ b/configure
@@ -0,0 +1,2320 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59 for xdg-utils 1.
+#
+# Report bugs to <portland@lists.freedesktop.org>.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME='xdg-utils'
+PACKAGE_TARNAME='xdg-utils'
+PACKAGE_VERSION='1'
+PACKAGE_STRING='xdg-utils 1'
+PACKAGE_BUGREPORT='portland@lists.freedesktop.org'
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA XMLTO LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures xdg-utils 1 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of xdg-utils 1:";;
+ esac
+ cat <<\_ACEOF
+
+Report bugs to <portland@lists.freedesktop.org>.
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd $ac_popdir
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+xdg-utils configure 1
+generated by GNU Autoconf 2.59
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by xdg-utils $as_me 1, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.make <<\_ACEOF
+all:
+ @echo 'ac_maketemp="$(MAKE)"'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ SET_MAKE=
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+done
+
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL=$ac_install_sh
+ fi
+fi
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+# Extract the first word of "xmlto", so it can be a program name with args.
+set dummy xmlto; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_XMLTO+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $XMLTO in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_XMLTO="$XMLTO" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_XMLTO="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_XMLTO" && ac_cv_path_XMLTO="/usr/bin/xmlto"
+ ;;
+esac
+fi
+XMLTO=$ac_cv_path_XMLTO
+
+if test -n "$XMLTO"; then
+ echo "$as_me:$LINENO: result: $XMLTO" >&5
+echo "${ECHO_T}$XMLTO" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+ ac_config_files="$ac_config_files Makefile scripts/Makefile tests/Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then we branch to the quote section. Otherwise,
+# look for a macro that doesn't take arguments.
+cat >confdef2opt.sed <<\_ACEOF
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g
+t quote
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g
+t quote
+d
+: quote
+s,[ `~#$^&*(){}\\|;'"<>?],\\&,g
+s,\[,\\&,g
+s,\],\\&,g
+s,\$,$$,g
+p
+_ACEOF
+# We use echo to avoid assuming a particular line-breaking character.
+# The extra dot is to prevent the shell from consuming trailing
+# line-breaks from the sub-command output. A line-break within
+# single-quotes doesn't work because, if this script is created in a
+# platform that uses two characters for line-breaks (e.g., DOS), tr
+# would break.
+ac_LF_and_DOT=`echo; echo .`
+DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
+rm -f confdef2opt.sed
+
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by xdg-utils $as_me 1, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Report bugs to <bug-autoconf@gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+xdg-utils config.status 1
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "scripts/Makefile" ) CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
+ "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@XMLTO@,$XMLTO,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..29cadb0
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,13 @@
+AC_PREREQ(2.50)
+AC_INIT(xdg-utils, 1, portland@lists.freedesktop.org)
+
+AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+AC_PATH_PROG(XMLTO, xmlto, /usr/bin/xmlto)
+
+AC_CONFIG_FILES([
+ Makefile
+ scripts/Makefile
+ tests/Makefile
+])
+AC_OUTPUT
diff --git a/install-sh b/install-sh
new file mode 100644
index 0000000..e9de238
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/scripts/.gitignore b/scripts/.gitignore
new file mode 100644
index 0000000..f3c7a7c
--- /dev/null
+++ b/scripts/.gitignore
@@ -0,0 +1 @@
+Makefile
diff --git a/scripts/HACKING b/scripts/HACKING
new file mode 100644
index 0000000..ab1da9a
--- /dev/null
+++ b/scripts/HACKING
@@ -0,0 +1,17 @@
+Note that the actual scripts are generated from xdg-*.in,
+xdg-utils-common.in and desc/xdg-*.xml which contains the
+command line descriptions. These are the files that you
+want to edit. To add a new script, you must also provide
+a desc/xdg-*.xml file.
+
+DO NOT MAKE CHANGES TO THE GENERATED SCRIPTS THEMSELVES!
+
+Use 'make scripts-clean' to delete all generated files and use
+'make scripts' to re-generate them.
+
+The manual files in man/ and html/ are also generated from the
+desc/xdg-*.xml files.
+
+Use 'make scripts html man' to update all generated files
+
+Use 'make release' to remove everything but the generated files.
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
new file mode 100644
index 0000000..2c7d2ac
--- /dev/null
+++ b/scripts/Makefile.in
@@ -0,0 +1,116 @@
+MKDIR = mkdir -p
+RMDIR = rmdir
+INSTALL = @INSTALL@ $(INSTALL_FLAGS)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
+INSTALL_LIBRARY = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
+INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
+XMLTO = @XMLTO@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+
+SCRIPTS = \
+ xdg-desktop-menu \
+ xdg-desktop-icon \
+ xdg-mime \
+ xdg-icon-resource \
+ xdg-open \
+ xdg-email \
+ xdg-screensaver \
+ xdg-settings
+# xdg-su
+# xdg-copy \
+# xdg-file-dialog
+# xdg-terminal
+
+MANPAGES= $(SCRIPTS:%=man/%.1)
+WEBPAGES= $(SCRIPTS:%=%.html)
+XMLFILES= $(SCRIPTS:%=desc/%.xml)
+
+all:
+
+html: index.html $(WEBPAGES)
+
+scripts: README $(SCRIPTS)
+
+man: $(MANPAGES)
+
+release: scripts html man
+ rm -f xdg-*.in *~ HACKING generate-help-script.awk
+ rm -rf desc/
+ rm -rf xsl/
+ rm -f xdg-file-dialog xdg-su xdg-copy xdg-terminal
+
+distclean: clean
+ rm -f Makefile
+
+clean:
+
+scripts-clean:
+ rm -f $(SCRIPTS) README man/xdg-*.1 html/xdg-*.html
+
+README: $(SCRIPTS)
+ echo > $@
+ @for x in $(SCRIPTS) ; do \
+ sh ./$$x --help | grep -B 100 Synopsis | sed -e '$$d' >> $@ ; \
+ done
+
+install:
+ $(MKDIR) $(DESTDIR)$(bindir)
+ for x in $(SCRIPTS) ; do \
+ $(INSTALL_SCRIPT) $$x $(DESTDIR)$(bindir) ; \
+ done
+ $(MKDIR) $(DESTDIR)$(mandir)
+ $(MKDIR) $(DESTDIR)$(mandir)/man1
+ for x in $(MANPAGES) ; do \
+ if [ -f $$x ]; then \
+ $(INSTALL_DATA) $$x $(DESTDIR)$(mandir)/man1 ; \
+ fi ; \
+ done
+
+uninstall:
+ for x in $(MANPAGES) ; do \
+ rm -f $(DESTDIR)$(mandir)/man1/`basename $$x` ; \
+ done
+ -$(RMDIR) $(DESTDIR)$(mandir)/man1
+ -$(RMDIR) $(DESTDIR)$(mandir)
+ for x in $(SCRIPTS) ; do \
+ rm -f $(DESTDIR)$(bindir)/$$x ; \
+ done
+ -$(RMDIR) $(DESTDIR)$(bindir)
+
+%: %.in %.txt
+ awk -f generate-help-script.awk $@.in | sed -e 's/@NAME@/'$@'/g' > $@
+ chmod a+x $@
+
+xdg-desktop-menu: xdg-desktop-menu.in xdg-utils-common.in
+xdg-desktop-icon: xdg-desktop-icon.in xdg-utils-common.in
+xdg-email: xdg-email.in xdg-utils-common.in
+xdg-mime: xdg-mime.in xdg-utils-common.in
+xdg-open: xdg-open.in xdg-utils-common.in
+xdg-screensaver: xdg-screensaver.in xdg-utils-common.in
+xdg-settings: xdg-settings.in xdg-utils-common.in
+xdg-icon-resource: xdg-icon-resource.in xdg-utils-common.in
+
+xdg-su: xdg-su.in xdg-utils-common.in
+xdg-copy: xdg-copy.in xdg-utils-common.in
+xdg-file-dialog: xdg-file-dialog.in xdg-utils-common.in
+xdg-terminal: xdg-terminal.in xdg-utils-common.in
+
+man/%.1: desc/%.xml
+ (cd man;$(XMLTO) man ../$<)
+
+index.html: $(XMLFILES)
+ (cat html/index.html.pre; \
+ xsltproc xsl/refentry2htmlindex.xsl $(XMLFILES); \
+ cat html/index.html.post ) > html/index.html
+
+%.html: desc/%.xml
+ (cd html;$(XMLTO) html-nochunks ../$<)
+
+%.txt: desc/%.xml
+ $(XMLTO) txt $<
+
diff --git a/scripts/README b/scripts/README
new file mode 100644
index 0000000..d1ebd29
--- /dev/null
+++ b/scripts/README
@@ -0,0 +1,19 @@
+
+xdg-desktop-menu - command line tool for (un)installing desktop menu items
+
+xdg-desktop-icon - command line tool for (un)installing icons to the desktop
+
+xdg-mime - command line tool for querying information about file type handling
+and adding descriptions for new file types
+
+xdg-icon-resource - command line tool for (un)installing icon resources
+
+xdg-open - opens a file or URL in the user's preferred application
+
+xdg-email - command line tool for sending mail using the user's preferred
+e-mail composer
+
+xdg-screensaver - command line tool for controlling the screensaver
+
+xdg-settings - get various settings from the desktop environment
+
diff --git a/scripts/desc/xdg-copy.xml b/scripts/desc/xdg-copy.xml
new file mode 100644
index 0000000..e3f5493
--- /dev/null
+++ b/scripts/desc/xdg-copy.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-copy">
+ <refentryinfo>
+ <title>xdg-copy Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>This is release 0.5 of the xdg-copy Manual.</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-copy</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-copy</refname>
+ <refpurpose>command line tool for copying files between desktop URIs</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-copy</command>
+ <arg choice="plain"><option><replaceable>source</replaceable></option></arg>
+ <arg choice="plain"><option><replaceable>destination</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-copy</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-copy copies <replaceable>source</replaceable> to
+ <replaceable>destination</replaceable> and provides visual feedback to
+ the user during the operation. Both <replaceable>source</replaceable>
+ and <replaceable>destination</replaceable> can either be a file or
+ URL. Supported URL types are file, ftp, http and https. Additional
+ URL types may be supported depending on the desktop environment.
+ </para>
+ <para>
+ xdg-copy is for use inside a desktop session only.
+ It is not recommended to use xdg-copy as root.
+ </para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-copy "http://portland.freedesktop.org/png/freedesktop-logo.png" .
+</programlisting>
+ </para>
+ <para>
+<programlisting>
+xdg-copy "/tmp/foobar.png" "/home/user/foobar-copy.png"
+</programlisting>
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-desktop-icon.xml b/scripts/desc/xdg-desktop-icon.xml
new file mode 100644
index 0000000..a886d5c
--- /dev/null
+++ b/scripts/desc/xdg-desktop-icon.xml
@@ -0,0 +1,364 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-desktop-icon">
+ <refentryinfo>
+ <title>xdg-desktop-icon Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-desktop-icon</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-desktop-icon</refname>
+ <refpurpose>command line tool for (un)installing icons to the desktop</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-desktop-icon</command>
+ <arg choice="plain">install</arg>
+ <arg><option>--novendor</option></arg>
+ <arg choice="plain"><replaceable>FILE</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-desktop-icon</command>
+ <arg choice="plain">uninstall</arg>
+ <arg choice="plain"><replaceable>FILE</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-desktop-icon</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ The xdg-desktop-icon program can be used to install an application launcher
+ or other file on the desktop of the current user.
+ </para>
+ <para>
+ An application launcher is represented by a *.desktop file.
+ Desktop files are defined by the freedesktop.org Desktop Entry
+ Specification. The most important aspects of *.desktop files
+ are summarized below.
+ </para>
+ </refsect1>
+ <refsect1 id="commands">
+ <title>Commands</title>
+ <variablelist>
+ <varlistentry>
+ <term>install</term>
+ <listitem>
+ <simpara>
+ Installs <replaceable>FILE</replaceable> to the desktop of the current user.
+ <replaceable>FILE</replaceable> can be a *.desktop file or any
+ other type of file.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>uninstall</term>
+ <listitem>
+ <simpara>
+ Removes <replaceable>FILE</replaceable> from the desktop
+ of the current user.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--novendor</option></term>
+ <listitem>
+ <simpara>
+ Normally, xdg-desktop-icon checks to ensure that a *.desktop file
+ to be installed has a vendor prefix. This option can be
+ used to disable that check.
+ </simpara>
+ <simpara>
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="desktopfiles">
+ <title>Desktop Files</title>
+ <para>
+ An application launcher can be added to the desktop by installing a
+ *.desktop file. A *.desktop file consists of a
+ <emphasis>[Desktop Entry]</emphasis> header followed by several
+ <replaceable>Key</replaceable>=<replaceable>Value</replaceable> lines.
+ </para>
+ <para>
+ A *.desktop file can provide a name and description for an application
+ in several different languages. This is done by adding a language
+ code as used by LC_MESSAGES in square brackets behind the
+ <replaceable>Key</replaceable>. This way one can specify different
+ values for the same <replaceable>Key</replaceable> depending on the
+ currently selected language.
+ </para>
+ <para>
+ The following keys are often used:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>Value=1.0</term>
+ <listitem>
+ <simpara>
+ This is a mandatory field to indicate that the *.desktop file
+ follows the 1.0 version of the specification.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Type=Application</term>
+ <listitem>
+ <simpara>
+ This is a mandatory field that indicates that the *.desktop file
+ describes an application launcher.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Name=<replaceable>Application Name</replaceable></term>
+ <listitem>
+ <simpara>
+ The name of the application.
+ For example <emphasis>Mozilla</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>GenericName=<replaceable>Generic Name</replaceable></term>
+ <listitem>
+ <simpara>
+ A generic description of the application.
+ For example <emphasis>Web Browser</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Comment=<replaceable>Comment</replaceable></term>
+ <listitem>
+ <simpara>
+ Optional field to specify a tooltip for the application.
+ For example <emphasis>Visit websites on the Internet</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Icon=<replaceable>Icon File</replaceable></term>
+ <listitem>
+ <simpara>
+ The icon to use for the application. This can either be
+ an absolute path to an image file or an icon-name.
+ If an icon-name is provided an image lookup by name is done
+ in the user's current icon theme. The <command>xdg-icon-resource</command>
+ command can be used to install image files into icon themes.
+ The advantage of using an icon-name instead of an absolute
+ path is that with an icon-name the application icon can be
+ provided in several different sizes as well as in several
+ differently themed styles.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Exec=<replaceable>Command Line</replaceable></term>
+ <listitem>
+ <simpara>
+ The command line to start the application. If the application
+ can open files the %f placeholder should be specified. When
+ a file is dropped on the application launcher the %f is replaced
+ with the file path of the dropped file. If multiple files
+ can be specified on the command line the %F placeholder should
+ be used instead of %f. If the application is able to open URLs
+ in addition to local files then %u or %U can be used instead
+ of %f or %F.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ For a complete overview of the *.desktop file format please
+ visit <ulink url="http://www.freedesktop.org/wiki/Specifications/desktop-entry-spec"/>
+ </para>
+ </refsect1>
+ <refsect1 id="env_vars">
+ <title>Environment Variables</title>
+ <para>
+ xdg-desktop-icon honours the following environment variables:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>XDG_UTILS_DEBUG_LEVEL</term>
+ <listitem>
+ <simpara>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-desktop-icon do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>5</option></term>
+ <listitem>
+ <simpara>
+ No permission to read one of the files passed on the command
+ line.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="seealso">
+ <title>See Also</title>
+ <para><citerefentry><refentrytitle>xdg-icon-resource</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+ The company ShinyThings Inc. has developed an application named
+ "WebMirror" and would like to add a launcher for for on the desktop.
+ The company will use "shinythings" as its vendor id.
+ In order to add the application to the desktop there needs to be a
+ .desktop file for the application:
+<programlisting>
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+</programlisting>
+ </para>
+ <para>Now the xdg-desktop-icon tool can be used to add the webmirror.desktop file
+ to the desktop:
+<programlisting>
+xdg-desktop-icon install ./shinythings-webmirror.desktop
+</programlisting>
+ </para>
+ <para>To add a README file to the desktop as well, the following command can be used:
+<programlisting>
+xdg-desktop-icon install ./shinythings-README
+</programlisting>
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-desktop-menu.xml b/scripts/desc/xdg-desktop-menu.xml
new file mode 100644
index 0000000..e7bda35
--- /dev/null
+++ b/scripts/desc/xdg-desktop-menu.xml
@@ -0,0 +1,685 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-desktop-menu">
+ <refentryinfo>
+ <title>xdg-desktop-menu Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-desktop-menu</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-desktop-menu</refname>
+ <refpurpose>command line tool for (un)installing desktop menu items</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-desktop-menu</command>
+ <arg choice="plain">install</arg>
+ <arg><option>--noupdate</option></arg>
+ <arg><option>--novendor</option></arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ <arg choice="plain"><replaceable>directory-file(s)</replaceable></arg>
+ <arg choice="plain"><replaceable>desktop-file(s)</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-desktop-menu</command>
+ <arg choice="plain">uninstall</arg>
+ <arg><option>--noupdate</option></arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ <arg choice="plain"><replaceable>directory-file(s)</replaceable></arg>
+ <arg choice="plain"><replaceable>desktop-file(s)</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-desktop-menu</command>
+ <arg choice="plain">forceupdate</arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-desktop-menu</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ The xdg-desktop-menu program can be used to install new menu entries
+ to the desktop's application menu.
+ </para>
+ <para>
+ The application menu works according to the
+ XDG Desktop Menu Specification at
+ <ulink url="http://www.freedesktop.org/wiki/Specifications/menu-spec"/>
+ </para>
+ </refsect1>
+ <refsect1 id="commands">
+ <title>Commands</title>
+ <variablelist>
+ <varlistentry>
+ <term>install</term>
+ <listitem>
+ <simpara>
+ Install one or more applications in a submenu of
+ the desktop menu system.
+ </simpara>
+ <simpara><replaceable>desktop-file</replaceable>:
+ A desktop file represents a single menu entry in the menu.
+ Desktop files are defined by the freedesktop.org Desktop Entry
+ Specification. The most important aspects of *.desktop
+ files are summarized below.
+ </simpara>
+ <simpara>
+ Menu entries can be added to the menu system in two different
+ ways. They can either be added to a predefined submenu in the
+ menu system based on one or more category keywords, or they can
+ be added to a new submenu.
+ </simpara>
+ <simpara>
+ To add a menu entry to a predefined submenu the desktop file
+ that represents the menu entry must have a Categories= entry
+ that lists one or more keywords. The menu item will be included
+ in an appropriate submenu based on the included keywords.
+ </simpara>
+ <simpara>
+ To add menu items to a new submenu the desktop-files must be
+ preceded by a directory-file that describes the submenu.
+ If multiple desktop-files are specified, all entries will
+ be added to the same menu. If entries are installed to a menu
+ that has been created with a previous call to
+ <command>xdg-desktop-menu</command> the entries will be
+ installed in addition to any already existing entries.
+ </simpara>
+ <simpara><replaceable>directory-file</replaceable>:
+ The *.directory file indicated by
+ <replaceable>directory-file</replaceable> represents a submenu.
+ The directory file provides the name and icon for a submenu. The
+ name of the directory file is used to identify the submenu.
+ </simpara>
+ <simpara>
+ If multiple directory files are provided each file will
+ represent a submenu within the menu that precedes it, creating
+ a nested menu hierarchy (sub-sub-menus).
+ The menu entries themselves will be added to the last submenu.
+ </simpara>
+ <simpara>
+ Directory files follow the syntax defined by the freedesktop.org
+ Desktop Entry Specification.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>uninstall</term>
+ <listitem>
+ <simpara>
+ Remove applications or submenus from the desktop menu system
+ previously installed with <command>xdg-desktop-menu install</command>.
+ </simpara>
+ <simpara>
+ A submenu and the associated directory file is only removed
+ when the submenu no longer contains any menu entries.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>forceupdate</term>
+ <listitem>
+ <simpara>
+ Force an update of the menu system.
+ </simpara>
+ <simpara>
+ This command is only useful if the last call to
+ xdg-desktop-menu included the <option>--noupdate</option> option.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--noupdate</option></term>
+ <listitem>
+ <simpara>
+ Postpone updating the menu system. If multiple updates to the
+ menu system are made in sequence this flag can be used to
+ indicate that additional changes will follow and that it is not
+ necessary to update the menu system right away.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--novendor</option></term>
+ <listitem>
+ <simpara>
+ Normally, xdg-desktop-menu checks to ensure that any *.directory
+ and *.desktop files to be installed has a vendor prefix.
+ This option can be used to disable that check.
+ </simpara>
+ <simpara>
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--mode</option> <replaceable>mode</replaceable></term>
+ <listitem>
+ <simpara><replaceable>mode</replaceable> can be
+ <emphasis>user</emphasis> or <emphasis>system</emphasis>.
+ In user mode the file is (un)installed for the current user
+ only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in
+ system mode.
+ </simpara>
+ <simpara>
+ The default is to use system mode when called by root
+ and to use user mode when called by a non-root user.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="desktopfiles">
+ <title>Desktop Files</title>
+ <para>
+ An application item in the application menu is represented by a
+ *.desktop file. A *.desktop file consists of a
+ <emphasis>[Desktop Entry]</emphasis> header followed by several
+ <replaceable>Key</replaceable>=<replaceable>Value</replaceable> lines.
+ </para>
+ <para>
+ A *.desktop file can provide a name and description for an application
+ in several different languages. This is done by adding a language
+ code as used by LC_MESSAGES in square brackets behind the
+ <replaceable>Key</replaceable>. This way one can specify different
+ values for the same <replaceable>Key</replaceable> depending on the
+ currently selected language.
+ </para>
+ <para>
+ The following keys are often used:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>Value=1.0</term>
+ <listitem>
+ <simpara>
+ This is a mandatory field to indicate that the *.desktop file
+ follows the 1.0 version of the specification.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Type=Application</term>
+ <listitem>
+ <simpara>
+ This is a mandatory field that indicates that the *.desktop file
+ describes an application launcher.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Name=<replaceable>Application Name</replaceable></term>
+ <listitem>
+ <simpara>
+ The name of the application.
+ For example <emphasis>Mozilla</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>GenericName=<replaceable>Generic Name</replaceable></term>
+ <listitem>
+ <simpara>
+ A generic description of the application.
+ For example <emphasis>Web Browser</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Comment=<replaceable>Comment</replaceable></term>
+ <listitem>
+ <simpara>
+ Optional field to specify a tooltip for the application.
+ For example <emphasis>Visit websites on the Internet</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Icon=<replaceable>Icon File</replaceable></term>
+ <listitem>
+ <simpara>
+ The icon to use for the application. This can either be
+ an absolute path to an image file or an icon-name.
+ If an icon-name is provided an image lookup by name is done
+ in the user's current icon theme. The <command>xdg-icon-resource</command>
+ command can be used to install image files into icon themes.
+ The advantage of using an icon-name instead of an absolute
+ path is that with an icon-name the application icon can be
+ provided in several different sizes as well as in several
+ differently themed styles.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Exec=<replaceable>Command Line</replaceable></term>
+ <listitem>
+ <simpara>
+ The command line to start the application. If the application
+ can open files the %f placeholder should be specified. When
+ a file is dropped on the application launcher the %f is replaced
+ with the file path of the dropped file. If multiple files
+ can be specified on the command line the %F placeholder should
+ be used instead of %f. If the application is able to open URLs
+ in addition to local files then %u or %U can be used instead
+ of %f or %F.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Categories=<replaceable>Categories</replaceable></term>
+ <listitem>
+ <simpara>
+ A list of categories separated by semi-colons. A category is
+ a keyword that describes and classifies the application.
+ By default applications are organized in the application menu
+ based on category. When menu entries are explicitly assigned
+ to a new submenu it is not necessary to list any categories.
+ </simpara>
+ <simpara>
+ When using categories it is recommended to include
+ one of the following categories:
+ AudioVideo, Development, Education, Game, Graphics, Network,
+ Office, Settings, System, Utility.
+ </simpara>
+ <simpara>
+ See Appendix A of the XDG Desktop Menu Specification
+ for information about additional categories:
+ <ulink url="http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry"/>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>MimeType=<replaceable>Mimetypes</replaceable></term>
+ <listitem>
+ <simpara>
+ A list of mimetypes separated by semi-colons. This field is
+ used to indicate which file types the application is able to
+ open.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ For a complete overview of the *.desktop file format please
+ visit <ulink url="http://www.freedesktop.org/wiki/Specifications/desktop-entry-spec"/>
+ </para>
+ </refsect1>
+ <refsect1 id="directoryfiles">
+ <title>Directory Files</title>
+ <para>
+ The appearance of submenu in the application menu is
+ provided by a *.directory file. In particular it provides the title
+ of the submenu and a possible icon. A *.directory file consists of a
+ <emphasis>[Desktop Entry]</emphasis> header followed by several
+ <replaceable>Key</replaceable>=<replaceable>Value</replaceable> lines.
+ </para>
+ <para>
+ A *.directory file can provide a title (name) for the submenu
+ in several different languages. This is done by adding a language
+ code as used by LC_MESSAGES in square brackets behind the
+ <replaceable>Key</replaceable>. This way one can specify different
+ values for the same <replaceable>Key</replaceable> depending on the
+ currently selected language.
+ </para>
+ <para>
+ The following keys are relevant for submenus:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>Value=1.0</term>
+ <listitem>
+ <simpara>
+ This is a mandatory field to indicate that the *.directory file
+ follows the 1.0 version of the Desktop Entry specification.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Type=Directory</term>
+ <listitem>
+ <simpara>
+ This is a mandatory field that indicates that the *.directory file
+ describes a submenu.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Name=<replaceable>Menu Name</replaceable></term>
+ <listitem>
+ <simpara>
+ The title of submenu.
+ For example <emphasis>Mozilla</emphasis>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Comment=<replaceable>Comment</replaceable></term>
+ <listitem>
+ <simpara>
+ Optional field to specify a tooltip for the submenu.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>Icon=<replaceable>Icon File</replaceable></term>
+ <listitem>
+ <simpara>
+ The icon to use for the submenu. This can either be
+ an absolute path to an image file or an icon-name.
+ If an icon-name is provided an image lookup by name is done
+ in the user's current icon theme.
+ The <command>xdg-icon-resource</command>
+ command can be used to install image files into icon themes.
+ The advantage of using an icon-name instead of an absolute
+ path is that with an icon-name the submenu icon can be
+ provided in several different sizes as well as in several
+ differently themed styles.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="env_vars">
+ <title>Environment Variables</title>
+ <para>
+ xdg-desktop-menu honours the following environment variables:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>XDG_UTILS_DEBUG_LEVEL</term>
+ <listitem>
+ <simpara>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-desktop-menu do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>XDG_UTILS_INSTALL_MODE</term>
+ <listitem>
+ <simpara>
+ This environment variable can be used by the user or
+ administrator to override the installation mode.
+ Valid values are <emphasis>user</emphasis> and
+ <emphasis>system</emphasis>.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>5</option></term>
+ <listitem>
+ <simpara>
+ No permission to read one of the files passed on the command
+ line.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="seealso">
+ <title>See Also</title>
+ <para><citerefentry><refentrytitle>xdg-desktop-icon</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>,
+ <citerefentry><refentrytitle>xdg-icon-resource</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>,
+ <citerefentry><refentrytitle>xdg-mime</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+
+ <para>
+ The company ShinyThings Inc. has developed an application named
+ "WebMirror" and would like to add it to the application menu.
+ The company will use "shinythings" as its vendor id.
+ In order to add the application to the menu there needs to be a
+ .desktop file with a suitable <emphasis>Categories</emphasis> entry:
+<programlisting>
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+ Categories=Network;WebDevelopment;
+</programlisting>
+ </para>
+ <para>Now the xdg-desktop-menu tool can be used to add the
+ shinythings-webmirror.desktop file to the desktop application menu:
+<programlisting>
+xdg-desktop-menu install ./shinythings-webmirror.desktop
+</programlisting>
+ </para>
+ <para>
+ Note that for the purpose of this example the menu items are available
+ in two languages, English and Dutch.
+ The language code for Dutch is nl.
+ </para>
+ <para>
+ In the next example the company ShinyThings Inc. will add its own
+ submenu to the desktop application menu consisting of a
+ "WebMirror" menu item and a "WebMirror Admin Tool" menu item.
+ </para>
+ <para>
+ First the company needs to create two .desktop files that describe
+ the two menu items. Since the items are to be added to a new submenu
+ it is not necessary to include a Categories= line:
+<programlisting>
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+
+shinythings-webmirror-admin.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror-admintool
+ Icon=shinythings-webmirror-admintool
+
+ Name=WebMirror Admin Tool
+ Name[nl]=WebSpiegel Administratie Tool
+</programlisting>
+ </para>
+ <para>
+ In addition a .directory file needs to be created to provide a title and icon
+ for the sub-menu itself:
+<programlisting>
+shinythings-webmirror.directory:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+
+ Icon=shinythings-webmirror-menu
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+</programlisting>
+ </para>
+ <para>
+ These file can now be installed with:
+<programlisting>
+xdg-desktop-menu install ./shinythings-webmirror.directory \
+ ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop
+</programlisting>
+ </para>
+ <para>
+ The menu entries could also be installed one by one:
+<programlisting>
+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
+ ./shinythings-webmirror.desktop
+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
+ ./shinythings-webmirror-admin.desktop
+xdg-desktop-menu forceupdate
+</programlisting>
+ </para>
+ <para>
+ Although the result is the same it is slightly more efficient to
+ install all files at the same time.
+ </para>
+ <para>
+ The *.desktop and *.directory files reference icons with the names
+ webmirror, webmirror-admin and webmirror-menu which should also be
+ installed. In this example the icons are installed in two different
+ sizes, once with a size of 22x22 pixels and once with a size
+ of 64x64 pixels:
+<programlisting>
+xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror
+xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu
+xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin
+xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror
+xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu
+xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin
+</programlisting>
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-email.xml b/scripts/desc/xdg-email.xml
new file mode 100644
index 0000000..a141906
--- /dev/null
+++ b/scripts/desc/xdg-email.xml
@@ -0,0 +1,281 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-email">
+ <refentryinfo>
+ <title>xdg-email Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-email</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-email</refname>
+ <refpurpose>command line tool for sending mail using the user's preferred e-mail composer</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-email</command>
+ <arg><option>--utf8</option></arg>
+ <arg><option>--cc</option> <replaceable>address</replaceable></arg>
+ <arg><option>--bcc</option> <replaceable>address</replaceable></arg>
+ <arg><option>--subject</option> <replaceable>text</replaceable></arg>
+ <arg><option>--body</option> <replaceable>text</replaceable></arg>
+ <arg><option>--attach</option> <replaceable>file</replaceable></arg>
+ <group choice="opt">
+ <arg choice="plain"><replaceable>mailto-uri</replaceable></arg>
+ <arg choice="plain"><replaceable>address(es)</replaceable></arg>
+ </group>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-email</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-email opens the user's preferred e-mail composer in order to send
+ a mail to <replaceable>address(es)</replaceable> or
+ <replaceable>mailto-uri</replaceable>. RFC2368 defines mailto:
+ URIs. xdg-email limits support to, cc, subject and body fields in
+ <replaceable>mailto-uri</replaceable>, all other fields are silently
+ ignored. <replaceable>address(es)</replaceable> must follow the
+ syntax of RFC822. Multiple addresses may be provided as
+ separate arguments.
+ </para>
+ <para>
+ All information provided on the command line is used to
+ prefill corresponding fields in the user's e-mail composer. The user
+ will have the opportunity to change any of this information before
+ actually sending the e-mail.
+ </para>
+ <para>
+ xdg-email is for use inside a desktop session only.
+ It is not recommended to use xdg-email as root.
+ </para>
+ <para>
+ See <ulink url="http://portland.freedesktop.org/wiki/EmailConfig"/> for information on
+ how the user can change the e-mail composer that is used.
+ </para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--utf8</option></term>
+ <listitem>
+ <simpara>
+ Indicates that all command line options that follow are in utf8.
+ Without this option, command line options are expected to be
+ encoded according to locale.
+ If the locale already specifies utf8 this option has no effect.
+ This option does not affect mailto URIs that are passed on the
+ command line.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--cc</option> <replaceable>address</replaceable></term>
+ <listitem>
+ <simpara>
+ Specify a recipient to be copied on the e-mail.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--bcc</option> <replaceable>address</replaceable></term>
+ <listitem>
+ <simpara>
+ Specify a recipient to be blindly copied on the e-mail.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--subject</option> <replaceable>text</replaceable></term>
+ <listitem>
+ <simpara>
+ Specify a subject for the e-mail.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--body</option> <replaceable>text</replaceable></term>
+ <listitem>
+ <simpara>
+ Specify a body for the e-mail. Since the user will be able to
+ make changes before actually sending the e-mail, this can be
+ used to provide the user with a template for the e-mail.
+ <replaceable>text</replaceable> may contain linebreaks.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--attach</option> <replaceable>file</replaceable></term>
+ <listitem>
+ <simpara>
+ Specify an attachment for the e-mail. <replaceable>file</replaceable>
+ must point to an existing file.
+ </simpara>
+ <simpara>
+ Some e-mail applications require the file to remain present
+ after xdg-email returns.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="env_vars">
+ <title>Environment Variables</title>
+ <para>
+ xdg-email honours the following environment variables:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>XDG_UTILS_DEBUG_LEVEL</term>
+ <listitem>
+ <simpara>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-email do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>5</option></term>
+ <listitem>
+ <simpara>
+ No permission to read one of the files passed on the command
+ line.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="configuration">
+ <title>Configuration</title>
+ <para>Visit <ulink url="http://portland.freedesktop.org/wiki/EmailConfig"/> for information
+ how to configure xdg-email to use the email client of your choice.
+ </para>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-email 'Jeremy White &lt;jwhite@example.com&gt;'
+</programlisting>
+ </para>
+ <para>
+<programlisting>
+xdg-email --attach /tmp/logo.png \
+ --subject 'Logo contest' \
+ --body 'Attached you find the logo for the contest.' \
+ 'jwhite@example.com'
+</programlisting>
+ </para>
+ <para>
+<programlisting>
+xdg-email --subject 'Your password is about to expire' \
+ 'jwhite@example.com' 'bastian@example.com' 'whipple@example.com'
+</programlisting>
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-file-dialog.xml b/scripts/desc/xdg-file-dialog.xml
new file mode 100644
index 0000000..3ca5cdd
--- /dev/null
+++ b/scripts/desc/xdg-file-dialog.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-file-dialog">
+ <refentryinfo>
+ <title>xdg-file-dialog Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <releaseinfo>This is release 0.5 of the xdg-mime Manual.</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-file-dialog</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-file-dialog</refname>
+ <refpurpose>command line tool for providing file and directory selection dialogs</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-file-dialog</command>
+ <arg choice="plain">openfilename</arg>
+ <arg><option>--title <replaceable>TITLE</replaceable></option></arg>
+ <arg><replaceable>FILENAME</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-file-dialog</command>
+ <arg choice="plain">openfilenamelist</arg>
+ <arg><option>--title <replaceable>TITLE</replaceable></option></arg>
+ <arg><replaceable>FILENAME</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-file-dialog</command>
+ <arg choice="plain">savefilename</arg>
+ <arg><option>--title <replaceable>TITLE</replaceable></option></arg>
+ <arg><replaceable>FILENAME</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-file-dialog</command>
+ <arg choice="plain">directory</arg>
+ <arg><option>--title <replaceable>TITLE</replaceable></option></arg>
+ <arg><replaceable>DIRNAME</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-file-dialog</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ The xdg-file-dialog program can be used to let the native file selection dialog
+ handle file and directory input.
+ </para>
+ <para>
+ xdg-file-dialog is for use inside a desktop session only.
+ It is not recommended to use xdg-file-dialog as root.
+ </para>
+ </refsect1>
+ <refsect1 id="commands">
+ <title>Commands</title>
+ <variablelist>
+ <varlistentry>
+ <term>openfilename</term>
+ <listitem>
+ <simpara>
+ Returns the filename with path for a file to read from.
+ <replaceable>FILENAME</replaceable> can optionally be used to
+ specify path and filename of a preselection.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>openfilenamelist</term>
+ <listitem>
+ <simpara>
+ Returns one or more filenames with path for files to read from,
+ each on a new line. <replaceable>FILENAME</replaceable> can optionally
+ be used to specify path and filename of a preselection.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>savefilename</term>
+ <listitem>
+ <simpara>
+ Returns the filename with path for file to write to.
+ <replaceable>FILENAME</replaceable> can optionally be used to
+ specify path and filename of a preselection.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>directory</term>
+ <listitem>
+ <simpara>
+ Returns the path for an existing directory.
+ <replaceable>DIRNAME</replaceable> can optionally be used to
+ specify a path of a preselection.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--title</option> <replaceable>TITLE</replaceable></term>
+ <listitem>
+ <simpara>
+ Sets the dialog's title (caption) to the specified text.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-file-dialog savefilename /tmp/foobar.png
+</programlisting>
+ Asks for a save file name starting in directory /tmp and suggesting foobar.png as the filename
+ </para>
+ <para>
+<programlisting>
+xdg-file-dialog directory --title "Select a target folder" /tmp
+</programlisting>
+ Asks for a directory name starting in directory /tmp using the text "Select a target folder" as the dialog's title/caption.
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-icon-resource.xml b/scripts/desc/xdg-icon-resource.xml
new file mode 100644
index 0000000..aa09fde
--- /dev/null
+++ b/scripts/desc/xdg-icon-resource.xml
@@ -0,0 +1,372 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-icon-resource">
+ <refentryinfo>
+ <title>xdg-icon-resource Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-icon-resource</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-icon-resource</refname>
+ <refpurpose>command line tool for (un)installing icon resources</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-icon-resource</command>
+ <arg choice="plain">install</arg>
+ <arg><option>--noupdate</option></arg>
+ <arg><option>--novendor</option></arg>
+ <arg><option>--theme <replaceable>theme</replaceable></option></arg>
+ <arg><option>--context <replaceable>context</replaceable></option></arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ <arg choice="plain"><option>--size <replaceable>size</replaceable></option></arg>
+ <arg choice="plain"><replaceable>icon-file</replaceable></arg>
+ <arg><replaceable>icon-name</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-icon-resource</command>
+ <arg choice="plain">uninstall</arg>
+ <arg><option>--noupdate</option></arg>
+ <arg><option>--theme <replaceable>theme</replaceable></option></arg>
+ <arg><option>--context <replaceable>context</replaceable></option></arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ <arg choice="plain"><option>--size <replaceable>size</replaceable></option></arg>
+ <arg choice="plain"><replaceable>icon-name</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-icon-resource</command>
+ <arg choice="plain">forceupdate</arg>
+ <arg><option>--theme <replaceable>theme</replaceable></option></arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-icon-resource</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ The xdg-icon-resource program can be used to install icon resources
+ into the desktop icon system in order to illustrate menu entries,
+ to depict desktop icons or to graphically represent file types.
+ </para>
+ <para>
+ The desktop icon system identifies icons by name. Depending on the
+ required size, the choice of icon theme and the context in which the
+ icon is used, the desktop icon system locates an appropriate
+ icon resource to depict an icon. Icon resources can be XPM files or
+ PNG files.
+ </para>
+ <para>
+ The desktop icon system works according to the
+ XDG Icon Theme Specification at
+ <ulink url="http://www.freedesktop.org/wiki/Specifications/icon-theme-spec"/>
+ </para>
+ </refsect1>
+ <refsect1 id="commands">
+ <title>Commands</title>
+ <variablelist>
+ <varlistentry>
+ <term>install</term>
+ <listitem>
+ <simpara>
+ Installs the icon file indicated by <replaceable>icon-file</replaceable>
+ to the desktop icon system under the name
+ <replaceable>icon-name</replaceable>.
+ Icon names do not have an extension.
+ If <replaceable>icon-name</replaceable> is not provided the name is
+ derived from <replaceable>icon-file</replaceable>.
+ The icon file must have
+ <emphasis>.png</emphasis> or <emphasis>.xpm</emphasis>
+ as extension. If a corresponding <emphasis>.icon</emphasis>
+ file exists in the same location as <replaceable>icon-file</replaceable>
+ it will be installed as well.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>uninstall</term>
+ <listitem>
+ <simpara>
+ Removes the icon indicated by <replaceable>icon-name</replaceable>
+ from the desktop icon system. Note that icon names do not have
+ an extension.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>forceupdate</term>
+ <listitem>
+ <simpara>
+ Force an update of the desktop icon system. This is only useful if
+ the last call to xdg-icon-resource included the <option>--noupdate</option> option.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--noupdate</option></term>
+ <listitem>
+ <simpara>
+ Postpone updating the desktop icon system. If multiple icons are
+ added in sequence this flag can be used to indicate that
+ additional changes will follow and that it is not
+ necessary to update the desktop icon system right away.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--novendor</option></term>
+ <listitem>
+ <simpara>
+ Normally, xdg-icon-resource checks to ensure that an icon file
+ to be installed in the <emphasis>apps</emphasis> context has
+ a proper vendor prefix. This option can be used to disable
+ that check.
+ </simpara>
+ <simpara>
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--theme</option> <replaceable>theme</replaceable></term>
+ <listitem>
+ <simpara>
+ Installs or removes the icon file as part of
+ <replaceable>theme</replaceable>. If no theme is specified the
+ icons will be installed as part of the default <emphasis>hicolor</emphasis> theme.
+ Applications may install icons under multiple themes but should
+ at least install icons for the default <emphasis>hicolor</emphasis> theme.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--context</option> <replaceable>context</replaceable></term>
+ <listitem>
+ <simpara>
+ Specifies the context for the icon. Icons to be used in the
+ application menu and as desktop icon should use
+ <emphasis>apps</emphasis> as context which is the default
+ context. Icons to be used as file icons should use
+ <emphasis>mimetypes</emphasis> as context.
+ Other common contexts are <emphasis>actions</emphasis>,
+ <emphasis>devices</emphasis>, <emphasis>emblems</emphasis>,
+ <emphasis>filesystems</emphasis> and <emphasis>stock</emphasis>.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--size</option> <replaceable>size</replaceable></term>
+ <listitem>
+ <simpara>
+ Specifies the size of the icon. All icons must be square.
+ Common sizes for icons in the apps context are:
+ 16, 22, 32, 48, 64 and 128.
+ Common sizes for icons in the mimetypes context are:
+ 16, 22, 32, 48, 64 and 128
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--mode</option> <replaceable>mode</replaceable></term>
+ <listitem>
+ <simpara><replaceable>mode</replaceable> can be
+ <emphasis>user</emphasis> or <emphasis>system</emphasis>.
+ In user mode the file is (un)installed for the current user
+ only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in
+ system mode.
+ </simpara>
+ <simpara>
+ The default is to use system mode when called by root
+ and to use user mode when called by a non-root user.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="env_vars">
+ <title>Environment Variables</title>
+ <para>
+ xdg-icon-resource honours the following environment variables:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>XDG_UTILS_DEBUG_LEVEL</term>
+ <listitem>
+ <simpara>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-icon-resource do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>XDG_UTILS_INSTALL_MODE</term>
+ <listitem>
+ <simpara>
+ This environment variable can be used by the user or
+ administrator to override the installation mode.
+ Valid values are <emphasis>user</emphasis> and
+ <emphasis>system</emphasis>.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>5</option></term>
+ <listitem>
+ <simpara>
+ No permission to read one of the files passed on the command
+ line.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="seealso">
+ <title>See Also</title>
+ <para><citerefentry><refentrytitle>xdg-desktop-icon</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>,
+ <citerefentry><refentrytitle>xdg-desktop-menu</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>,
+ <citerefentry><refentrytitle>xdg-mime</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+To install an icon resource to depict a launcher for the application
+myfoobar, the company ShinyThings Inc. can use:
+<programlisting>
+xdg-icon-resource install --size 64 shinythings-myfoobar.png
+</programlisting>
+ </para>
+ <para>
+To install an icon for a new application/x-foobar file type one can use:
+<programlisting>
+xdg-icon-resource install --context mimetypes --size 48 ./mime-foobar-48.png application-x-foobar
+xdg-icon-resource install --context mimetypes --size 64 ./mime-foobar-64.png application-x-foobar
+</programlisting>This will install two icons with the name application-x-foobar
+but with different sizes.
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-mime.xml b/scripts/desc/xdg-mime.xml
new file mode 100644
index 0000000..f848ef8
--- /dev/null
+++ b/scripts/desc/xdg-mime.xml
@@ -0,0 +1,373 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-mime">
+ <refentryinfo>
+ <title>xdg-mime Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-mime</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-mime</refname>
+ <refpurpose>command line tool for querying information about file type handling
+and adding descriptions for new file types</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-mime</command>
+ <arg choice="plain">query</arg>
+ <group choice="req">
+ <arg choice="plain">filetype</arg>
+ <arg choice="plain">default</arg>
+ </group>
+ <arg choice="plain">...</arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-mime</command>
+ <arg choice="plain">default</arg>
+ <arg choice="plain"><replaceable>application</replaceable></arg>
+ <arg choice="plain"><replaceable>mimetype(s)</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-mime</command>
+ <arg choice="plain">install</arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ <arg><option>--novendor</option></arg>
+ <arg choice="plain"><replaceable>mimetypes-file</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-mime</command>
+ <arg choice="plain">uninstall</arg>
+ <arg><option>--mode <replaceable>mode</replaceable></option></arg>
+ <arg choice="plain"><replaceable>mimetypes-file</replaceable></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-mime</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ The xdg-mime program can be used to query information about file types
+ and to add descriptions for new file types.
+ </para>
+ </refsect1>
+ <refsect1 id="commands">
+ <title>Commands</title>
+ <variablelist>
+ <varlistentry>
+ <term>query</term>
+ <listitem>
+ <simpara>
+ Returns information related to file types.
+ </simpara>
+ <simpara>
+ The <emphasis>query</emphasis> option is for use inside a desktop session only.
+ It is not recommended to use xdg-mime query as root.
+ </simpara>
+ <simpara>
+ The following queries are supported:
+ </simpara>
+ <simpara>query filetype <replaceable>FILE</replaceable>:
+ Returns the file type of <replaceable>FILE</replaceable> in the form of a MIME type.
+ </simpara>
+ <simpara>query default <replaceable>mimetype</replaceable>:
+ Returns the default application that the desktop environment uses for opening
+ files of type <replaceable>mimetype</replaceable>. The default application is
+ identified by its *.desktop file.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>default</term>
+ <listitem>
+ <simpara>
+ Ask the desktop environment to make <replaceable>application</replaceable>
+ the default application for opening
+ files of type <replaceable>mimetype</replaceable>. An
+ application can be made the default for several file types by
+ specifying multiple mimetypes.
+ </simpara>
+ <simpara>
+ <replaceable>application</replaceable> is the desktop file
+ id of the application and has the form vendor-name.desktop
+ <replaceable>application</replaceable> must already be installed
+ in the desktop menu before it can be made the default handler.
+ The application's desktop file must list support for all the
+ MIME types that it wishes to be the default handler for.
+ </simpara>
+ <simpara>
+ Requests to make an application a default handler may be
+ subject to system policy or approval by the end-user. xdg-mime
+ query can be used to verify whether an application is the
+ actual default handler for a specific file type.
+ </simpara>
+ <simpara>
+ The <emphasis>default</emphasis> option is for use inside a desktop session only.
+ It is not recommended to use xdg-mime default as root.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>install</term>
+ <listitem>
+ <simpara>
+ Adds the file type descriptions provided in <replaceable>mimetypes-file</replaceable>
+ to the desktop environment. <replaceable>mimetypes-file</replaceable>
+ must be a XML file that follows the freedesktop.org
+ Shared MIME-info Database specification
+ and that has a mime-info element as its document root. For
+ each new file type one or more icons with name
+ <replaceable>type</replaceable>-<replaceable>subtype</replaceable>
+ must be installed with the <command>xdg-icon-resource</command>
+ command in the <emphasis>mimetypes</emphasis> context. For example the
+ filetype application/vnd.oasis.opendocument.text requires an
+ icon named application-vnd.oasis.opendocument.text
+ to be installed (unless the file type recommends another icon name).
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>uninstall</term>
+ <listitem>
+ <simpara>
+ Removes the file type descriptions provided in <replaceable>mimetypes-file</replaceable>
+ and previously added with <command>xdg-mime install</command> from the
+ desktop environment. <replaceable>mimetypes-file</replaceable>
+ must be a XML file that follows the freedesktop.org
+ Shared MIME-info Database specification
+ and that has a mime-info element as its document root.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--mode</option> <replaceable>mode</replaceable></term>
+ <listitem>
+ <simpara><replaceable>mode</replaceable> can be
+ <emphasis>user</emphasis> or <emphasis>system</emphasis>.
+ In user mode the file is (un)installed for the current user
+ only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in
+ system mode.
+ </simpara>
+ <simpara>
+ The default is to use system mode when called by root
+ and to use user mode when called by a non-root user.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--novendor</option></term>
+ <listitem>
+ <simpara>
+ Normally, xdg-mime checks to ensure that the
+ <replaceable>mimetypes-file</replaceable> to be installed
+ has a proper vendor prefix. This option can be
+ used to disable that check.
+ </simpara>
+ <simpara>
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="env_vars">
+ <title>Environment Variables</title>
+ <para>
+ xdg-mime honours the following environment variables:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>XDG_UTILS_DEBUG_LEVEL</term>
+ <listitem>
+ <simpara>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-mime do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>XDG_UTILS_INSTALL_MODE</term>
+ <listitem>
+ <simpara>
+ This environment variable can be used by the user or
+ administrator to override the installation mode.
+ Valid values are <emphasis>user</emphasis> and
+ <emphasis>system</emphasis>.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>5</option></term>
+ <listitem>
+ <simpara>
+ No permission to read one of the files passed on the command
+ line.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="seealso">
+ <title>See Also</title>
+ <para><citerefentry><refentrytitle>xdg-icon-resource</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>,
+ <citerefentry><refentrytitle>xdg-desktop-menu</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-mime query filetype /tmp/foobar.png
+</programlisting>Prints the MIME type of the file /tmp/foobar.png, in this
+case image/png
+ </para>
+ <para>
+<programlisting>
+xdg-mime query default image/png
+</programlisting>Prints the .desktop filename of the application which is
+ registered to open PNG files.
+ </para>
+ <para>
+<programlisting>
+xdg-mime install shinythings-shiny.xml
+</programlisting>Adds a file type description for "shiny"-files.
+ "shinythings-" is used as the vendor prefix.
+ The file type description could look as follows.
+<programlisting>
+shinythings-shiny.xml:
+
+&lt;?xml version="1.0"?&gt;
+&lt;mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'&gt;
+ &lt;mime-type type="text/x-shiny"&gt;
+ &lt;comment&gt;Shiny new file type&lt;/comment&gt;
+ &lt;glob pattern="*.shiny"/&gt;
+ &lt;glob pattern="*.shi"/&gt;
+ &lt;/mime-type&gt;
+&lt;/mime-info&gt;
+</programlisting>An icon for this new file type must also be installed, for
+example with:
+<programlisting>
+xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
+</programlisting>
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-open.xml b/scripts/desc/xdg-open.xml
new file mode 100644
index 0000000..a99785b
--- /dev/null
+++ b/scripts/desc/xdg-open.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-open">
+ <refentryinfo>
+ <title>xdg-open Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-open</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-open</refname>
+ <refpurpose>opens a file or URL in the user's preferred application</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-open</command>
+ <group choice="req">
+ <arg choice="plain"><option><replaceable>file</replaceable></option></arg>
+ <arg choice="plain"><option><replaceable>URL</replaceable></option></arg>
+ </group>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-open</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-open opens a file or URL in the user's preferred application.
+ If a URL is provided the URL will be opened in the user's preferred
+ web browser. If a file is provided the file will be opened in the
+ preferred application for files of that type. xdg-open supports
+ file, ftp, http and https URLs.
+ </para>
+ <para>
+ xdg-open is for use inside a desktop session only.
+ It is not recommended to use xdg-open as root.
+ </para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-open 'http://www.freedesktop.org/'
+</programlisting>
+ Opens the freedesktop.org website in the user's default browser.
+ </para>
+ <para>
+<programlisting>
+xdg-open /tmp/foobar.png
+</programlisting>
+ Opens the PNG image file /tmp/foobar.png in the user's default image
+ viewing application.
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-screensaver.xml b/scripts/desc/xdg-screensaver.xml
new file mode 100644
index 0000000..0dadf04
--- /dev/null
+++ b/scripts/desc/xdg-screensaver.xml
@@ -0,0 +1,227 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-screensaver">
+ <refentryinfo>
+ <title>xdg-screensaver Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Bryce</firstname>
+ <surname>Harrington</surname>
+ </author>
+ <address><email>bryce@osdl.org</email></address>
+ <releaseinfo>xdg-utils 1.0</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-screensaver</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-screensaver</refname>
+ <refpurpose>command line tool for controlling the screensaver</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-screensaver</command>
+ <arg choice="plain"><option>suspend <replaceable>WindowID</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-screensaver</command>
+ <arg choice="plain"><option>resume <replaceable>WindowID</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-screensaver</command>
+ <group choice="req">
+ <arg choice="plain"><option>activate</option></arg>
+ <arg choice="plain"><option>lock</option></arg>
+ <arg choice="plain"><option>reset</option></arg>
+ <arg choice="plain"><option>status</option></arg>
+ </group>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-screensaver</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-screensaver provides commands to control the screensaver.
+ </para>
+ <para>
+ xdg-screensaver is for use inside a desktop session only.
+ It is not recommended to use xdg-screensaver as root.
+ </para>
+ </refsect1>
+ <refsect1 id="commands">
+ <title>Commands</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>suspend <replaceable>WindowID</replaceable></option></term>
+ <listitem>
+ <simpara>
+ Suspends the screensaver and monitor power management.
+ <replaceable>WindowID</replaceable> must be the X Window ID
+ of an existing window of the calling application. The window
+ must remain in existence for the duration of the suspension.
+ </simpara>
+ <simpara>
+ WindowID can be represented as either a decimal number
+ or as a hexadecimal number consisting of the prefix
+ <emphasis>0x</emphasis> followed by one or more hexadecimal
+ digits.
+ </simpara>
+ <simpara>
+ The screensaver can be suspended in relation to multiple
+ windows at the same time. In that case screensaver
+ operation is only restored once the screensaver has been
+ resumed in relation to each of the windows
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>resume <replaceable>WindowID</replaceable></option></term>
+ <listitem>
+ <simpara>
+ Resume the screensaver and monitor power management after being
+ suspended.
+ <replaceable>WindowID</replaceable>
+ must be the same X Window ID that was passed to a previous call
+ of <command>xdg-screensaver suspend</command>
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>activate</option></term>
+ <listitem>
+ <simpara>
+ Turns the screensaver on immediately. This may result in the
+ screen getting locked, depending on existing system policies.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>lock</option></term>
+ <listitem>
+ <simpara>
+ Lock the screen immediately.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>reset</option></term>
+ <listitem>
+ <simpara>
+ Turns the screensaver off immediately. If the screen was locked
+ the user may be asked to authenticate first.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>status</option></term>
+ <listitem>
+ <simpara>
+ Prints <emphasis>enabled</emphasis> to stdout if the
+ screensaver is enabled to turn on after a period of
+ inactivity and prints
+ <emphasis>disabled</emphasis> if the screensaver is
+ not enabled.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-screensaver suspend 0x1c00007
+</programlisting>Causes the screensaver to be disabled till
+ <command>xdg-screensaver resume 0x1c00007</command> is called.
+ <emphasis>0x1c00007</emphasis> must be the X Window ID of an
+ existing window.
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-settings.xml b/scripts/desc/xdg-settings.xml
new file mode 100644
index 0000000..905c65f
--- /dev/null
+++ b/scripts/desc/xdg-settings.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-settings">
+ <refentryinfo>
+ <title>xdg-settings Manual</title>
+ <copyright>
+ <year>2009-2011</year>
+ </copyright>
+ <author>
+ <firstname>Mike</firstname>
+ <surname>Mammarella</surname>
+ </author>
+ <address><email>mdm@google.com</email></address>
+ <!--<releaseinfo>xdg-utils 1.0</releaseinfo>-->
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-settings</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-settings</refname>
+ <refpurpose>get various settings from the desktop environment</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-settings</command>
+ <group choice="req">
+ <arg choice="plain"><option><replaceable>get</replaceable></option></arg>
+ <arg choice="plain"><option><replaceable>check</replaceable></option></arg>
+ <arg choice="plain"><option><replaceable>set</replaceable></option></arg>
+ </group>
+ <group choice="req">
+ <option>property</option>
+ </group>
+ <group choice="opt">
+ <option>subproperty</option>
+ </group>
+ <group choice="opt">
+ <option>value</option>
+ </group>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-settings</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--list</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-settings gets various settings from the desktop environment.
+ For instance, desktop environments often provide proxy configuration
+ and default web browser settings. Using xdg-settings these parameters
+ can be extracted for use by applications that do not use the desktop
+ environment's libraries (which would use the settings natively).
+ </para>
+ <para>
+ xdg-settings is for use inside a desktop session only.
+ It is not recommended to use xdg-settings as root.
+ </para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--list</option></term>
+ <listitem>
+ <simpara>
+ List all properties xdg-settings knows about.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="properties">
+ <title>Properties</title>
+ <para>
+ When using xdg-settings to get, check or set a destkop setting, properties
+ and possibly sub-properties are used to specify the setting to be changed.
+ </para>
+ <para>
+ Some properties (such as default-web-browser) fully describe the setting
+ to be changed. Other properties (such as default-url-scheme-handler) require
+ more information (in this case the actual scheme to set the default handler
+ for) which must be provided in a sub-property.
+ </para>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+ Get the desktop file name of the current default web browser
+ <programlisting>
+ xdg-settings get default-web-browser
+ </programlisting>
+ </para>
+ <para>
+ Check whether the default web browser is firefox.desktop, which can be
+ false even if "get default-web-browser" says that is the current value
+ (if only some of the underlying settings actually reflect that value)
+ <programlisting>
+ xdg-settings check default-web-browser firefox.desktop
+ </programlisting>
+ </para>
+ <para>
+ Set the default web browser to google-chrome.desktop
+ <programlisting>
+ xdg-settings set default-web-browser google-chrome.desktop
+ </programlisting>
+ </para>
+ <para>
+ Set the default mailto URL scheme handler to be evolution.desktop
+ <programlisting>
+ xdg-settings set default-url-scheme-handler mailto evolution.desktop
+ </programlisting>
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-su.xml b/scripts/desc/xdg-su.xml
new file mode 100644
index 0000000..53a0f32
--- /dev/null
+++ b/scripts/desc/xdg-su.xml
@@ -0,0 +1,166 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-su">
+ <refentryinfo>
+ <title>xdg-su Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <author>
+ <firstname>Jeremy</firstname>
+ <surname>White</surname>
+ </author>
+ <address><email>jwhite@codeweavers.com</email></address>
+ <releaseinfo>This is release 0.5 of the xdg-su Manual.</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-su</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-su</refname>
+ <refpurpose>run a GUI program as root after prompting for the root password</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-su</command>
+ <arg><option>-u <replaceable>user</replaceable></option></arg>
+ <arg choice="plain"><option>-c <replaceable>command</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-su</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-su provides a graphical dialog that prompts the user for a password
+ to run <replaceable>command</replaceable> as <replaceable>user</replaceable>
+ or as root if no user was specified.
+ </para>
+ <para>
+ xdg-su is for use inside a desktop session only.
+ </para>
+ <para>
+ xdg-su discards any stdout and stderr output from
+ <replaceable>command</replaceable>.
+ </para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>-u <replaceable>user</replaceable></option></term>
+ <listitem>
+ <simpara>
+ run <replaceable>command</replaceable> as
+ <replaceable>user</replaceable>. The default is to run as root.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>2</option></term>
+ <listitem>
+ <simpara>
+ One of the files passed on the command line did not exist.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="seealso">
+ <title>See Also</title>
+ <para><citerefentry><refentrytitle>su</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>
+ </para>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-su -u root -c "/opt/shinythings/bin/install-GUI --install fast"
+</programlisting>
+ Runs the /opt/shinythings/bin/install-GUI command with root permissions.
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/desc/xdg-terminal.xml b/scripts/desc/xdg-terminal.xml
new file mode 100644
index 0000000..4ed4d90
--- /dev/null
+++ b/scripts/desc/xdg-terminal.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl"
+ href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+]>
+<refentry id="xdg-terminal">
+ <refentryinfo>
+ <title>xdg-terminal Manual</title>
+ <copyright>
+ <year>2006</year>
+ </copyright>
+ <author>
+ <firstname>Kevin</firstname>
+ <surname>Krammer</surname>
+ </author>
+ <address><email>kevin.krammer@gmx.at</email></address>
+ <releaseinfo>xdg-terminal Technology Preview</releaseinfo>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>xdg-terminal</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>xdg-terminal</refname>
+ <refpurpose>opens the user's preferred terminal emulator application</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>xdg-terminal</command>
+ <arg choice="opt"><option><replaceable>command</replaceable></option></arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>xdg-terminal</command>
+ <group choice="req">
+ <arg choice="plain"><option>--help</option></arg>
+ <arg choice="plain"><option>--manual</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+
+ <refsect1 id="description">
+ <title>Description</title>
+ <para>
+ xdg-terminal opens the user's preferred terminal emulator application.
+ If a command is provided the command will be executed by the shell within
+ the newly opened terminal window.
+ </para>
+ <para>
+ xdg-terminal is for use inside a desktop session only.
+ It is not recommended to use xdg-terminal as root.
+ </para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>Options</title>
+ <variablelist>
+ <varlistentry>
+ <term><option>--help</option></term>
+ <listitem>
+ <simpara>
+ Show command synopsis.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--manual</option></term>
+ <listitem>
+ <simpara>
+ Show this manual page.
+ </simpara>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><option>--version</option></term>
+ <listitem>
+ <simpara>
+ Show the xdg-utils version information.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="exitcodes">
+ <title>Exit Codes</title>
+ <para>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><option>1</option></term>
+ <listitem>
+ <simpara>
+ Error in command line syntax.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>3</option></term>
+ <listitem>
+ <simpara>
+ A required tool could not be found.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>4</option></term>
+ <listitem>
+ <simpara>
+ The action failed.
+ </simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="examples">
+ <title>Examples</title>
+ <para>
+<programlisting>
+xdg-terminal
+</programlisting>
+ Opens the user's default terminal emulator, just starting an interactive shell.
+ </para>
+ <para>
+<programlisting>
+xdg-terminal top
+</programlisting>
+ Opens the user's default terminal emulator and lets it run the top executable.
+ </para>
+ </refsect1>
+</refentry>
diff --git a/scripts/generate-help-script.awk b/scripts/generate-help-script.awk
new file mode 100644
index 0000000..d4bf76e
--- /dev/null
+++ b/scripts/generate-help-script.awk
@@ -0,0 +1,110 @@
+#!/usr/bin/awk -f
+#---------------------------------------------
+#
+# generate-script.awk
+#
+# Simple AWK script to generate the XDG scripts, substituting the
+# necessary text from other source files.
+#
+# Copyright 2006, Benedikt Meurer <benny@xfce.org>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+
+# All lines from the input file should be printed
+{
+ print
+}
+
+
+# The text from ../LICENSE should be inserted after
+# the "# LICENSE:" line
+/^# LICENSE:/ {
+ while (getline < "../LICENSE")
+ print
+ close ("../LICENSE")
+}
+
+
+# Insert the examples text from the .txt file
+# after the "cat << _MANUALPAGE" line
+/^cat << _MANUALPAGE/ {
+ # determine the name of the .txt file
+ txtfile = FILENAME
+ sub(/\.in$/, ".txt", txtfile)
+
+ # read the .txt file content
+ for (txtfile_print = 0; getline < txtfile; ) {
+# if (match ($0, /^Examples/) != 0) {
+# # print everything starting at the "Examples" line
+# txtfile_print = 1
+# }
+# if (txtfile_print != 0) {
+# print $0
+# }
+ gsub("`","'")
+ gsub("—","-")
+ print $0
+ }
+ close (txtfile)
+}
+
+
+# Insert the usage text from the .txt file
+# after the "cat << _USAGE" line
+/^cat << _USAGE/ {
+ # determine the name of the .txt file
+ txtfile = FILENAME
+ sub(/\.in$/, ".txt", txtfile)
+
+ # read the .txt file content
+ for (txtfile_print = 0; getline < txtfile; ) {
+ if (match ($0, /^Name/) != 0) {
+ # skip empty line after "Name"
+ getline < txtfile
+
+ # from now on, print everything
+ txtfile_print = 1
+ }
+ else if (match ($0, /^Description/) != 0) {
+ # stop at "Description"
+ break
+ }
+ else if (txtfile_print != 0) {
+ gsub("—","-")
+ print $0
+ }
+ }
+ close (txtfile)
+}
+
+
+# Insert the xdg-utils-common.in content after
+# the "#@xdg-utils-common@" line
+/^#@xdg-utils-common@/ {
+ while (getline < "xdg-utils-common.in")
+ print
+ close ("xdg-utils-common.in")
+}
+
+
diff --git a/scripts/html/.gitignore b/scripts/html/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/html/.gitignore
diff --git a/scripts/html/index.html b/scripts/html/index.html
new file mode 100644
index 0000000..64b0c53
--- /dev/null
+++ b/scripts/html/index.html
@@ -0,0 +1,19 @@
+<html>
+<body>
+<h1>xdg-utils</h1>
+<p>
+This version of xdg-utils contains the following commands:
+</p>
+<table>
+<tr><td><a href="xdg-desktop-menu.html">xdg-desktop-menu</a>:</td><td>command line tool for (un)installing desktop menu items</td></tr>
+<tr><td><a href="xdg-desktop-icon.html">xdg-desktop-icon</a>:</td><td>command line tool for (un)installing icons to the desktop</td></tr>
+<tr><td><a href="xdg-mime.html">xdg-mime</a>:</td><td>command line tool for querying information about file type handling
+and adding descriptions for new file types</td></tr>
+<tr><td><a href="xdg-icon-resource.html">xdg-icon-resource</a>:</td><td>command line tool for (un)installing icon resources</td></tr>
+<tr><td><a href="xdg-open.html">xdg-open</a>:</td><td>opens a file or URL in the user's preferred application</td></tr>
+<tr><td><a href="xdg-email.html">xdg-email</a>:</td><td>command line tool for sending mail using the user's preferred e-mail composer</td></tr>
+<tr><td><a href="xdg-screensaver.html">xdg-screensaver</a>:</td><td>command line tool for controlling the screensaver</td></tr>
+<tr><td><a href="xdg-settings.html">xdg-settings</a>:</td><td>get various settings from the desktop environment</td></tr>
+</table>
+</body>
+</html> \ No newline at end of file
diff --git a/scripts/html/index.html.post b/scripts/html/index.html.post
new file mode 100644
index 0000000..7b999de
--- /dev/null
+++ b/scripts/html/index.html.post
@@ -0,0 +1,3 @@
+</table>
+</body>
+</html> \ No newline at end of file
diff --git a/scripts/html/index.html.pre b/scripts/html/index.html.pre
new file mode 100644
index 0000000..5d43839
--- /dev/null
+++ b/scripts/html/index.html.pre
@@ -0,0 +1,7 @@
+<html>
+<body>
+<h1>xdg-utils</h1>
+<p>
+This version of xdg-utils contains the following commands:
+</p>
+<table>
diff --git a/scripts/html/xdg-desktop-icon.html b/scripts/html/xdg-desktop-icon.html
new file mode 100644
index 0000000..f9683ba
--- /dev/null
+++ b/scripts/html/xdg-desktop-icon.html
@@ -0,0 +1,133 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-desktop-icon</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-desktop-icon"><a name="xdg-desktop-icon"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-desktop-icon &#8212; command line tool for (un)installing icons to the desktop</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-desktop-icon</code> install [<code class="option">--novendor</code>] <em class="replaceable"><code>FILE</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-desktop-icon</code> uninstall <em class="replaceable"><code>FILE</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-desktop-icon</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ The xdg-desktop-icon program can be used to install an application launcher
+ or other file on the desktop of the current user.
+ </p><p>
+ An application launcher is represented by a *.desktop file.
+ Desktop files are defined by the freedesktop.org Desktop Entry
+ Specification. The most important aspects of *.desktop files
+ are summarized below.
+ </p></div><div class="refsect1" title="Commands"><a name="commands"></a><h2>Commands</h2><div class="variablelist"><dl><dt><span class="term">install</span></dt><dd>
+ Installs <em class="replaceable"><code>FILE</code></em> to the desktop of the current user.
+ <em class="replaceable"><code>FILE</code></em> can be a *.desktop file or any
+ other type of file.
+ </dd><dt><span class="term">uninstall</span></dt><dd>
+ Removes <em class="replaceable"><code>FILE</code></em> from the desktop
+ of the current user.
+ </dd></dl></div></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--novendor</code></span></dt><dd><p class="simpara">
+ Normally, xdg-desktop-icon checks to ensure that a *.desktop file
+ to be installed has a vendor prefix. This option can be
+ used to disable that check.
+ </p><p class="simpara">
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Desktop Files"><a name="desktopfiles"></a><h2>Desktop Files</h2><p>
+ An application launcher can be added to the desktop by installing a
+ *.desktop file. A *.desktop file consists of a
+ <span class="emphasis"><em>[Desktop Entry]</em></span> header followed by several
+ <em class="replaceable"><code>Key</code></em>=<em class="replaceable"><code>Value</code></em> lines.
+ </p><p>
+ A *.desktop file can provide a name and description for an application
+ in several different languages. This is done by adding a language
+ code as used by LC_MESSAGES in square brackets behind the
+ <em class="replaceable"><code>Key</code></em>. This way one can specify different
+ values for the same <em class="replaceable"><code>Key</code></em> depending on the
+ currently selected language.
+ </p><p>
+ The following keys are often used:
+ </p><div class="variablelist"><dl><dt><span class="term">Value=1.0</span></dt><dd>
+ This is a mandatory field to indicate that the *.desktop file
+ follows the 1.0 version of the specification.
+ </dd><dt><span class="term">Type=Application</span></dt><dd>
+ This is a mandatory field that indicates that the *.desktop file
+ describes an application launcher.
+ </dd><dt><span class="term">Name=<em class="replaceable"><code>Application Name</code></em></span></dt><dd>
+ The name of the application.
+ For example <span class="emphasis"><em>Mozilla</em></span>
+ </dd><dt><span class="term">GenericName=<em class="replaceable"><code>Generic Name</code></em></span></dt><dd>
+ A generic description of the application.
+ For example <span class="emphasis"><em>Web Browser</em></span>
+ </dd><dt><span class="term">Comment=<em class="replaceable"><code>Comment</code></em></span></dt><dd>
+ Optional field to specify a tooltip for the application.
+ For example <span class="emphasis"><em>Visit websites on the Internet</em></span>
+ </dd><dt><span class="term">Icon=<em class="replaceable"><code>Icon File</code></em></span></dt><dd>
+ The icon to use for the application. This can either be
+ an absolute path to an image file or an icon-name.
+ If an icon-name is provided an image lookup by name is done
+ in the user's current icon theme. The <span class="command"><strong>xdg-icon-resource</strong></span>
+ command can be used to install image files into icon themes.
+ The advantage of using an icon-name instead of an absolute
+ path is that with an icon-name the application icon can be
+ provided in several different sizes as well as in several
+ differently themed styles.
+ </dd><dt><span class="term">Exec=<em class="replaceable"><code>Command Line</code></em></span></dt><dd>
+ The command line to start the application. If the application
+ can open files the %f placeholder should be specified. When
+ a file is dropped on the application launcher the %f is replaced
+ with the file path of the dropped file. If multiple files
+ can be specified on the command line the %F placeholder should
+ be used instead of %f. If the application is able to open URLs
+ in addition to local files then %u or %U can be used instead
+ of %f or %F.
+ </dd></dl></div><p>
+ For a complete oveview of the *.desktop file format please
+ visit http://www.freedesktop.org/wiki/Standards/desktop-entry-spec
+ </p></div><div class="refsect1" title="Environment Variables"><a name="env_vars"></a><h2>Environment Variables</h2><p>
+ xdg-desktop-icon honours the following environment variables:
+ </p><div class="variablelist"><dl><dt><span class="term">XDG_UTILS_DEBUG_LEVEL</span></dt><dd>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-desktop-icon do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd><dt><span class="term"><code class="option">5</code></span></dt><dd>
+ No permission to read one of the files passed on the command
+ line.
+ </dd></dl></div></div><div class="refsect1" title="See Also"><a name="seealso"></a><h2>See Also</h2><p><span class="citerefentry"><span class="refentrytitle">xdg-icon-resource</span>(1)</span>
+ </p></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+ The company ShinyThings Inc. has developed an application named
+ "WebMirror" and would like to add a launcher for for on the desktop.
+ The company will use "shinythings" as its vendor id.
+ In order to add the application to the desktop there needs to be a
+ .desktop file for the application:
+</p><pre class="programlisting">
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+</pre><p>
+ </p><p>Now the xdg-desktop-icon tool can be used to add the webmirror.desktop file
+ to the desktop:
+</p><pre class="programlisting">
+xdg-desktop-icon install ./shinythings-webmirror.desktop
+</pre><p>
+ </p><p>To add a README file to the desktop as well, the following command can be used:
+</p><pre class="programlisting">
+xdg-desktop-icon install ./shinythings-README
+</pre><p>
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-desktop-menu.html b/scripts/html/xdg-desktop-menu.html
new file mode 100644
index 0000000..71b7e04
--- /dev/null
+++ b/scripts/html/xdg-desktop-menu.html
@@ -0,0 +1,334 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-desktop-menu</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-desktop-menu"><a name="xdg-desktop-menu"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-desktop-menu &#8212; command line tool for (un)installing desktop menu items</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-desktop-menu</code> install [<code class="option">--noupdate</code>] [<code class="option">--novendor</code>] [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>] <em class="replaceable"><code>directory-file(s)</code></em> <em class="replaceable"><code>desktop-file(s)</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-desktop-menu</code> uninstall [<code class="option">--noupdate</code>] [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>] <em class="replaceable"><code>directory-file(s)</code></em> <em class="replaceable"><code>desktop-file(s)</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-desktop-menu</code> forceupdate [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>]</p></div><div class="cmdsynopsis"><p><code class="command">xdg-desktop-menu</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ The xdg-desktop-menu program can be used to install new menu entries
+ to the desktop's application menu.
+ </p><p>
+ The application menu works according to the
+ XDG Desktop Menu Specification at
+ http://www.freedesktop.org/Standards/menu-spec
+ </p></div><div class="refsect1" title="Commands"><a name="commands"></a><h2>Commands</h2><div class="variablelist"><dl><dt><span class="term">install</span></dt><dd><p class="simpara">
+ Install one or more applications in a submenu of
+ the desktop menu system.
+ </p><p class="simpara"><em class="replaceable"><code>desktop-file</code></em>:
+ A desktop file represents a single menu entry in the menu.
+ Desktop files are defined by the freedesktop.org Desktop Entry
+ Specification. The most important aspects of *.desktop
+ files are summarized below.
+ </p><p class="simpara">
+ Menu entries can be added to the menu system in two different
+ ways. They can either be added to a predefined submenu in the
+ menu system based on one or more category keywords, or they can
+ be added to a new submenu.
+ </p><p class="simpara">
+ To add a menu entry to a predefined submenu the desktop file
+ that represents the menu entry must have a Categories= entry
+ that lists one or more keywords. The menu item will be included
+ in an appropriate submenu based on the included keywords.
+ </p><p class="simpara">
+ To add menu items to a new submenu the desktop-files must be
+ preceded by a directory-file that describes the submenu.
+ If multiple desktop-files are specified, all entries will
+ be added to the same menu. If entries are installed to a menu
+ that has been created with a previous call to
+ <span class="command"><strong>xdg-desktop-menu</strong></span> the entries will be
+ installed in addition to any already existing entries.
+ </p><p class="simpara"><em class="replaceable"><code>directory-file</code></em>:
+ The *.directory file indicated by
+ <em class="replaceable"><code>directory-file</code></em> represents a submenu.
+ The directory file provides the name and icon for a submenu. The
+ name of the directory file is used to identify the submenu.
+ </p><p class="simpara">
+ If multiple directory files are provided each file will
+ represent a submenu within the menu that preceeds it, creating
+ a nested menu hierarchy (sub-sub-menus).
+ The menu entries themselves will be added to the last submenu.
+ </p><p class="simpara">
+ Directory files follow the syntax defined by the freedesktop.org
+ Desktop Entry Specification.
+ </p></dd><dt><span class="term">uninstall</span></dt><dd><p class="simpara">
+ Remove applications or submenus from the desktop menu system
+ previously installed with <span class="command"><strong>xdg-desktop-menu install</strong></span>.
+ </p><p class="simpara">
+ A submenu and the associated directory file is only removed
+ when the submenu no longer contains any menu entries.
+ </p></dd><dt><span class="term">forceupdate</span></dt><dd><p class="simpara">
+ Force an update of the menu system.
+ </p><p class="simpara">
+ This command is only useful if the last call to
+ xdg-desktop-menu included the <code class="option">--noupdate</code> option.
+ </p></dd></dl></div></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--noupdate</code></span></dt><dd>
+ Postpone updating the menu system. If multiple updates to the
+ menu system are made in sequence this flag can be used to
+ indicate that additional changes will follow and that it is not
+ necassery to update the menu system right away.
+ </dd><dt><span class="term"><code class="option">--novendor</code></span></dt><dd><p class="simpara">
+ Normally, xdg-desktop-menu checks to ensure that any *.directory
+ and *.desktop files to be installed has a vendor prefix.
+ This option can be used to disable that check.
+ </p><p class="simpara">
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </p></dd><dt><span class="term"><code class="option">--mode</code> <em class="replaceable"><code>mode</code></em></span></dt><dd><p class="simpara"><em class="replaceable"><code>mode</code></em> can be
+ <span class="emphasis"><em>user</em></span> or <span class="emphasis"><em>system</em></span>.
+ In user mode the file is (un)installed for the current user
+ only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in
+ system mode.
+ </p><p class="simpara">
+ The default is to use system mode when called by root
+ and to use user mode when called by a non-root user.
+ </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Desktop Files"><a name="desktopfiles"></a><h2>Desktop Files</h2><p>
+ An application item in the application menu is represented by a
+ *.desktop file. A *.desktop file consists of a
+ <span class="emphasis"><em>[Desktop Entry]</em></span> header followed by several
+ <em class="replaceable"><code>Key</code></em>=<em class="replaceable"><code>Value</code></em> lines.
+ </p><p>
+ A *.desktop file can provide a name and description for an application
+ in several different languages. This is done by adding a language
+ code as used by LC_MESSAGES in square brackets behind the
+ <em class="replaceable"><code>Key</code></em>. This way one can specify different
+ values for the same <em class="replaceable"><code>Key</code></em> depending on the
+ currently selected language.
+ </p><p>
+ The following keys are often used:
+ </p><div class="variablelist"><dl><dt><span class="term">Value=1.0</span></dt><dd>
+ This is a mandatory field to indicate that the *.desktop file
+ follows the 1.0 version of the specification.
+ </dd><dt><span class="term">Type=Application</span></dt><dd>
+ This is a mandatory field that indicates that the *.desktop file
+ describes an application launcher.
+ </dd><dt><span class="term">Name=<em class="replaceable"><code>Application Name</code></em></span></dt><dd>
+ The name of the application.
+ For example <span class="emphasis"><em>Mozilla</em></span>
+ </dd><dt><span class="term">GenericName=<em class="replaceable"><code>Generic Name</code></em></span></dt><dd>
+ A generic description of the application.
+ For example <span class="emphasis"><em>Web Browser</em></span>
+ </dd><dt><span class="term">Comment=<em class="replaceable"><code>Comment</code></em></span></dt><dd>
+ Optional field to specify a tooltip for the application.
+ For example <span class="emphasis"><em>Visit websites on the Internet</em></span>
+ </dd><dt><span class="term">Icon=<em class="replaceable"><code>Icon File</code></em></span></dt><dd>
+ The icon to use for the application. This can either be
+ an absolute path to an image file or an icon-name.
+ If an icon-name is provided an image lookup by name is done
+ in the user's current icon theme. The <span class="command"><strong>xdg-icon-resource</strong></span>
+ command can be used to install image files into icon themes.
+ The advantage of using an icon-name instead of an absolute
+ path is that with an icon-name the application icon can be
+ provided in several different sizes as well as in several
+ differently themed styles.
+ </dd><dt><span class="term">Exec=<em class="replaceable"><code>Command Line</code></em></span></dt><dd>
+ The command line to start the application. If the application
+ can open files the %f placeholder should be specified. When
+ a file is dropped on the application launcher the %f is replaced
+ with the file path of the dropped file. If multiple files
+ can be specified on the command line the %F placeholder should
+ be used instead of %f. If the application is able to open URLs
+ in addition to local files then %u or %U can be used instead
+ of %f or %F.
+ </dd><dt><span class="term">Categories=<em class="replaceable"><code>Categories</code></em></span></dt><dd><p class="simpara">
+ A list of categories separated by semi-colons. A category is
+ a keyword that describes and classifies the application.
+ By default applications are organized in the application menu
+ based on category. When menu entries are explicitly assigned
+ to a new submenu it is not necassery to list any categories.
+ </p><p class="simpara">
+ When using categories it is recommended to include
+ one of the following categories:
+ AudioVideo, Development, Education, Game, Graphics, Network,
+ Office, Settings, System, Utility.
+ </p><p class="simpara">
+ See Appendix A of the XDG Desktop Menu Specification
+ for information about additional categories.
+ http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html
+ </p></dd><dt><span class="term">MimeType=<em class="replaceable"><code>Mimetypes</code></em></span></dt><dd>
+ A list of mimetypes separated by semi-colons. This field is
+ used to indicate which file types the application is able to
+ open.
+ </dd></dl></div><p>
+ For a complete oveview of the *.desktop file format please
+ visit http://www.freedesktop.org/wiki/Standards/desktop-entry-spec
+ </p></div><div class="refsect1" title="Directory Files"><a name="directoryfiles"></a><h2>Directory Files</h2><p>
+ The appearance of submenu in the application menu is
+ provided by a *.directory file. In particular it provides the title
+ of the submenu and a possible icon. A *.directory file consists of a
+ <span class="emphasis"><em>[Desktop Entry]</em></span> header followed by several
+ <em class="replaceable"><code>Key</code></em>=<em class="replaceable"><code>Value</code></em> lines.
+ </p><p>
+ A *.directory file can provide a title (name) for the submenu
+ in several different languages. This is done by adding a language
+ code as used by LC_MESSAGES in square brackets behind the
+ <em class="replaceable"><code>Key</code></em>. This way one can specify different
+ values for the same <em class="replaceable"><code>Key</code></em> depending on the
+ currently selected language.
+ </p><p>
+ The following keys are relevqnt for submenus:
+ </p><div class="variablelist"><dl><dt><span class="term">Value=1.0</span></dt><dd>
+ This is a mandatory field to indicate that the *.directory file
+ follows the 1.0 version of the Desktop Entry specification.
+ </dd><dt><span class="term">Type=Directory</span></dt><dd>
+ This is a mandatory field that indicates that the *.directory file
+ describes a submenu.
+ </dd><dt><span class="term">Name=<em class="replaceable"><code>Menu Name</code></em></span></dt><dd>
+ The title of submenu.
+ For example <span class="emphasis"><em>Mozilla</em></span>
+ </dd><dt><span class="term">Comment=<em class="replaceable"><code>Comment</code></em></span></dt><dd>
+ Optional field to specify a tooltip for the submenu.
+ </dd><dt><span class="term">Icon=<em class="replaceable"><code>Icon File</code></em></span></dt><dd>
+ The icon to use for the submenu. This can either be
+ an absolute path to an image file or an icon-name.
+ If an icon-name is provided an image lookup by name is done
+ in the user's current icon theme.
+ The <span class="command"><strong>xdg-icon-resource</strong></span>
+ command can be used to install image files into icon themes.
+ The advantage of using an icon-name instead of an absolute
+ path is that with an icon-name the submenu icon can be
+ provided in several different sizes as well as in several
+ differently themed styles.
+ </dd></dl></div></div><div class="refsect1" title="Environment Variables"><a name="env_vars"></a><h2>Environment Variables</h2><p>
+ xdg-desktop-menu honours the following environment variables:
+ </p><div class="variablelist"><dl><dt><span class="term">XDG_UTILS_DEBUG_LEVEL</span></dt><dd>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-desktop-menu do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </dd><dt><span class="term">XDG_UTILS_INSTALL_MODE</span></dt><dd>
+ This environment variable can be used by the user or
+ administrator to override the installation mode.
+ Valid values are <span class="emphasis"><em>user</em></span> and
+ <span class="emphasis"><em>system</em></span>.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd><dt><span class="term"><code class="option">5</code></span></dt><dd>
+ No permission to read one of the files passed on the command
+ line.
+ </dd></dl></div></div><div class="refsect1" title="See Also"><a name="seealso"></a><h2>See Also</h2><p><span class="citerefentry"><span class="refentrytitle">xdg-desktop-icon</span>(1)</span>,
+ <span class="citerefentry"><span class="refentrytitle">xdg-icon-resource</span>(1)</span>,
+ <span class="citerefentry"><span class="refentrytitle">xdg-mime</span>(1)</span>
+ </p></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+ The company ShinyThings Inc. has developed an application named
+ "WebMirror" and would like to add it to the application menu.
+ The company will use "shinythings" as its vendor id.
+ In order to add the application to the menu there needs to be a
+ .desktop file with a suitable <span class="emphasis"><em>Categories</em></span> entry:
+</p><pre class="programlisting">
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+ Categories=Network;WebDevelopment;
+</pre><p>
+ </p><p>Now the xdg-desktop-menu tool can be used to add the
+ shinythings-webmirror.desktop file to the desktop application menu:
+</p><pre class="programlisting">
+xdg-desktop-menu install ./shinythings-webmirror.desktop
+</pre><p>
+ </p><p>
+ Note that for the purpose of this example the menu items are available
+ in two languages, English and Dutch.
+ The language code for Dutch is nl.
+ </p><p>
+ In the next example the company ShinyThings Inc. will add its own
+ submenu to the desktop application menu consisting of a
+ "WebMirror" menu item and a "WebMirror Admin Tool" menu item.
+ </p><p>
+ First the company needs to create two .desktop files that describe
+ the two menu items. Since the items are to be added to a new submenu
+ it is not necassery to include a Categories= line:
+</p><pre class="programlisting">
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+
+shinythings-webmirror-admin.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror-admintool
+ Icon=shinythings-webmirror-admintool
+
+ Name=WebMirror Admin Tool
+ Name[nl]=WebSpiegel Administratie Tool
+</pre><p>
+ </p><p>
+ In addition a .directory file needs to be created to provide a title and icon
+ for the sub-menu itself:
+</p><pre class="programlisting">
+shinythings-webmirror.directory:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+
+ Icon=shinythings-webmirror-menu
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+</pre><p>
+ </p><p>
+ These file can now be installed with:
+</p><pre class="programlisting">
+xdg-desktop-menu install ./shinythings-webmirror.directory \
+ ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop
+</pre><p>
+ </p><p>
+ The menu entries could also be installed one by one:
+</p><pre class="programlisting">
+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
+ ./shinythings-webmirror.desktop
+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
+ ./shinythings-webmirror-admin.desktop
+xdg-desktop-menu forceupdate
+</pre><p>
+ </p><p>
+ Although the result is the same it is slightly more efficient to
+ install all files at the same time.
+ </p><p>
+ The *.desktop and *.directory files reference icons with the names
+ webmirror, webmirror-admin and webmirror-menu which should also be
+ installed. In this example the icons are installed in two different
+ sizes, once with a size of 22x22 pixels and once with a size
+ of 64x64 pixels:
+</p><pre class="programlisting">
+xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror
+xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu
+xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin
+xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror
+xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu
+xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin
+</pre><p>
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-email.html b/scripts/html/xdg-email.html
new file mode 100644
index 0000000..a3854af
--- /dev/null
+++ b/scripts/html/xdg-email.html
@@ -0,0 +1,89 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-email</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-email"><a name="xdg-email"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-email &#8212; command line tool for sending mail using the user's preferred e-mail composer</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-email</code> [<code class="option">--utf8</code>] [<code class="option">--cc</code> <em class="replaceable"><code>address</code></em>] [<code class="option">--bcc</code> <em class="replaceable"><code>address</code></em>] [<code class="option">--subject</code> <em class="replaceable"><code>text</code></em>] [<code class="option">--body</code> <em class="replaceable"><code>text</code></em>] [<code class="option">--attach</code> <em class="replaceable"><code>file</code></em>] [ <em class="replaceable"><code>mailto-uri</code></em> | <em class="replaceable"><code>address(es)</code></em> ]</p></div><div class="cmdsynopsis"><p><code class="command">xdg-email</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ xdg-email opens the user's preferred e-mail composer in order to send
+ a mail to <em class="replaceable"><code>address(es)</code></em> or
+ <em class="replaceable"><code>mailto-uri</code></em>. RFC2368 defines mailto:
+ URIs. xdg-email limits support to, cc, subject and body fields in
+ <em class="replaceable"><code>mailto-uri</code></em>, all other fields are silently
+ ignored. <em class="replaceable"><code>address(es)</code></em> must follow the
+ syntax of RFC822. Multiple addresses may be provided as
+ separate arguments.
+ </p><p>
+ All information provided on the command line is used to
+ prefill corresponding fields in the user's e-mail composer. The user
+ will have the opportunity to change any of this information before
+ actually sending the e-mail.
+ </p><p>
+ xdg-email is for use inside a desktop session only.
+ It is not recommended to use xdg-email as root.
+ </p><p>
+ See http://portland.freedesktop.org/EmailConfig for information on
+ how the user can change the e-mail composer that is used.
+ </p></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--utf8</code></span></dt><dd>
+ Indicates that all command line options that follow are in utf8.
+ Without this option, command line options are expected to be
+ encoded according to locale.
+ If the locale already specifies utf8 this option has no effect.
+ This option does not affect mailto URIs that are passed on the
+ command line.
+ </dd><dt><span class="term"><code class="option">--cc</code> <em class="replaceable"><code>address</code></em></span></dt><dd>
+ Specify a recipient to be copied on the e-mail.
+ </dd><dt><span class="term"><code class="option">--bcc</code> <em class="replaceable"><code>address</code></em></span></dt><dd>
+ Specify a recipient to be blindly copied on the e-mail.
+ </dd><dt><span class="term"><code class="option">--subject</code> <em class="replaceable"><code>text</code></em></span></dt><dd>
+ Specify a subject for the e-mail.
+ </dd><dt><span class="term"><code class="option">--body</code> <em class="replaceable"><code>text</code></em></span></dt><dd>
+ Specify a body for the e-mail. Since the user will be able to
+ make changes before actually sending the e-mail, this can be
+ used to provide the user with a template for the e-mail.
+ <em class="replaceable"><code>text</code></em> may contain linebreaks.
+ </dd><dt><span class="term"><code class="option">--attach</code> <em class="replaceable"><code>file</code></em></span></dt><dd><p class="simpara">
+ Specify an attachment for the e-mail. <em class="replaceable"><code>file</code></em>
+ must point to an existing file.
+ </p><p class="simpara">
+ Some e-mail applications require the file to remain present
+ after xdg-email returns.
+ </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Environment Variables"><a name="env_vars"></a><h2>Environment Variables</h2><p>
+ xdg-email honours the following environment variables:
+ </p><div class="variablelist"><dl><dt><span class="term">XDG_UTILS_DEBUG_LEVEL</span></dt><dd>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-email do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd><dt><span class="term"><code class="option">5</code></span></dt><dd>
+ No permission to read one of the files passed on the command
+ line.
+ </dd></dl></div></div><div class="refsect1" title="Configuration"><a name="configuration"></a><h2>Configuration</h2><p>Visit http://portland.freedesktop.org/EmailConfig for information
+ how to configure xdg-email to use the email client of your choice.
+ </p></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+</p><pre class="programlisting">
+xdg-email 'Jeremy White &lt;jwhite@example.com&gt;'
+</pre><p>
+ </p><p>
+</p><pre class="programlisting">
+xdg-email --attach /tmp/logo.png \
+ --subject 'Logo contest' \
+ --body 'Attached you find the logo for the contest.' \
+ 'jwhite@example.com'
+</pre><p>
+ </p><p>
+</p><pre class="programlisting">
+xdg-email --subject 'Your password is about to expire' \
+ 'jwhite@example.com' 'bastian@example.com' 'whipple@example.com'
+</pre><p>
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-icon-resource.html b/scripts/html/xdg-icon-resource.html
new file mode 100644
index 0000000..a734033
--- /dev/null
+++ b/scripts/html/xdg-icon-resource.html
@@ -0,0 +1,128 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-icon-resource</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-icon-resource"><a name="xdg-icon-resource"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-icon-resource &#8212; command line tool for (un)installing icon resources</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-icon-resource</code> install [<code class="option">--noupdate</code>] [<code class="option">--novendor</code>] [<code class="option">--theme <em class="replaceable"><code>theme</code></em></code>] [<code class="option">--context <em class="replaceable"><code>context</code></em></code>] [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>] <code class="option">--size <em class="replaceable"><code>size</code></em></code> <em class="replaceable"><code>icon-file</code></em> [<em class="replaceable"><code>icon-name</code></em>]</p></div><div class="cmdsynopsis"><p><code class="command">xdg-icon-resource</code> uninstall [<code class="option">--noupdate</code>] [<code class="option">--theme <em class="replaceable"><code>theme</code></em></code>] [<code class="option">--context <em class="replaceable"><code>context</code></em></code>] [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>] <code class="option">--size <em class="replaceable"><code>size</code></em></code> <em class="replaceable"><code>icon-name</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-icon-resource</code> forceupdate [<code class="option">--theme <em class="replaceable"><code>theme</code></em></code>] [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>]</p></div><div class="cmdsynopsis"><p><code class="command">xdg-icon-resource</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ The xdg-icon-resource program can be used to install icon resources
+ into the desktop icon system in order to illustrate menu entries,
+ to depict desktop icons or to graphically represent file types.
+ </p><p>
+ The desktop icon system identifies icons by name. Depending on the
+ required size, the choice of icon theme and the context in which the
+ icon is used, the desktop icon system locates an appropriate
+ icon resource to depict an icon. Icon resources can be XPM files or
+ PNG files.
+ </p><p>
+ The desktop icon system works according to the
+ XDG Icon Theme Specification at
+ http://www.freedesktop.org/Standards/icon-theme-spec
+ </p></div><div class="refsect1" title="Commands"><a name="commands"></a><h2>Commands</h2><div class="variablelist"><dl><dt><span class="term">install</span></dt><dd>
+ Installs the icon file indicated by <em class="replaceable"><code>icon-file</code></em>
+ to the desktop icon system under the name
+ <em class="replaceable"><code>icon-name</code></em>.
+ Icon names do not have an extension.
+ If <em class="replaceable"><code>icon-name</code></em> is not provided the name is
+ derived from <em class="replaceable"><code>icon-file</code></em>.
+ The icon file must have
+ <span class="emphasis"><em>.png</em></span> or <span class="emphasis"><em>.xpm</em></span>
+ as extension. If a corresponding <span class="emphasis"><em>.icon</em></span>
+ file exists in the same location as <em class="replaceable"><code>icon-file</code></em>
+ it will be installed as well.
+ </dd><dt><span class="term">uninstall</span></dt><dd>
+ Removes the icon indicated by <em class="replaceable"><code>icon-name</code></em>
+ from the desktop icon system. Note that icon names do not have
+ an extension.
+ </dd><dt><span class="term">forceupdate</span></dt><dd>
+ Force an update of the desktop icon system. This is only useful if
+ the last call to xdg-icon-resource included the <code class="option">--noupdate</code> option.
+ </dd></dl></div></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--noupdate</code></span></dt><dd>
+ Postpone updating the desktop icon system. If multiple icons are
+ added in sequence this flag can be used to indicate that
+ additional changes will follow and that it is not
+ necassery to update the desktop icon system right away.
+ </dd><dt><span class="term"><code class="option">--novendor</code></span></dt><dd><p class="simpara">
+ Normally, xdg-icon-resource checks to ensure that an icon file
+ to be installed in the <span class="emphasis"><em>apps</em></span> context has
+ a proper vendor prefix. This option can be used to disable
+ that check.
+ </p><p class="simpara">
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </p></dd><dt><span class="term"><code class="option">--theme</code> <em class="replaceable"><code>theme</code></em></span></dt><dd>
+ Installs or removes the icon file as part of
+ <em class="replaceable"><code>theme</code></em>. If no theme is specified the
+ icons will be installed as part of the default <span class="emphasis"><em>hicolor</em></span> theme.
+ Applications may install icons under multiple themes but should
+ at least install icons for the default <span class="emphasis"><em>hicolor</em></span> theme.
+ </dd><dt><span class="term"><code class="option">--context</code> <em class="replaceable"><code>context</code></em></span></dt><dd>
+ Specifies the context for the icon. Icons to be used in the
+ application menu and as desktop icon should use
+ <span class="emphasis"><em>apps</em></span> as context which is the default
+ context. Icons to be used as file icons should use
+ <span class="emphasis"><em>mimetypes</em></span> as context.
+ Other common contexts are <span class="emphasis"><em>actions</em></span>,
+ <span class="emphasis"><em>devices</em></span>, <span class="emphasis"><em>emblems</em></span>,
+ <span class="emphasis"><em>filesystems</em></span> and <span class="emphasis"><em>stock</em></span>.
+ </dd><dt><span class="term"><code class="option">--size</code> <em class="replaceable"><code>size</code></em></span></dt><dd>
+ Specifies the size of the icon. All icons must be square.
+ Common sizes for icons in the apps context are:
+ 16, 22, 32, 48, 64 and 128.
+ Common sizes for icons in the mimetypes context are:
+ 16, 22, 32, 48, 64 and 128
+ </dd><dt><span class="term"><code class="option">--mode</code> <em class="replaceable"><code>mode</code></em></span></dt><dd><p class="simpara"><em class="replaceable"><code>mode</code></em> can be
+ <span class="emphasis"><em>user</em></span> or <span class="emphasis"><em>system</em></span>.
+ In user mode the file is (un)installed for the current user
+ only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in
+ system mode.
+ </p><p class="simpara">
+ The default is to use system mode when called by root
+ and to use user mode when called by a non-root user.
+ </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Environment Variables"><a name="env_vars"></a><h2>Environment Variables</h2><p>
+ xdg-icon-resource honours the following environment variables:
+ </p><div class="variablelist"><dl><dt><span class="term">XDG_UTILS_DEBUG_LEVEL</span></dt><dd>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-icon-resource do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </dd><dt><span class="term">XDG_UTILS_INSTALL_MODE</span></dt><dd>
+ This environment variable can be used by the user or
+ administrator to override the installation mode.
+ Valid values are <span class="emphasis"><em>user</em></span> and
+ <span class="emphasis"><em>system</em></span>.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd><dt><span class="term"><code class="option">5</code></span></dt><dd>
+ No permission to read one of the files passed on the command
+ line.
+ </dd></dl></div></div><div class="refsect1" title="See Also"><a name="seealso"></a><h2>See Also</h2><p><span class="citerefentry"><span class="refentrytitle">xdg-desktop-icon</span>(1)</span>,
+ <span class="citerefentry"><span class="refentrytitle">xdg-desktop-menu</span>(1)</span>,
+ <span class="citerefentry"><span class="refentrytitle">xdg-mime</span>(1)</span>
+ </p></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+To install an icon resource to depict a launcher for the application
+myfoobar, the company ShinyThings Inc. can use:
+</p><pre class="programlisting">
+xdg-icon-resource install --size 64 shinythings-myfoobar.png
+</pre><p>
+ </p><p>
+To install an icon for a new application/x-foobar file type one can use:
+</p><pre class="programlisting">
+xdg-icon-resource install --context mimetypes --size 48 ./mime-foobar-48.png application-x-foobar
+xdg-icon-resource install --context mimetypes --size 64 ./mime-foobar-64.png application-x-foobar
+</pre><p>This will install two icons with the name application-x-foobar
+but with different sizes.
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-mime.html b/scripts/html/xdg-mime.html
new file mode 100644
index 0000000..53bb99c
--- /dev/null
+++ b/scripts/html/xdg-mime.html
@@ -0,0 +1,145 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-mime</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-mime"><a name="xdg-mime"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-mime &#8212; command line tool for querying information about file type handling
+and adding descriptions for new file types</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-mime</code> query { filetype | default } ... </p></div><div class="cmdsynopsis"><p><code class="command">xdg-mime</code> default <em class="replaceable"><code>application</code></em> <em class="replaceable"><code>mimetype(s)</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-mime</code> install [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>] [<code class="option">--novendor</code>] <em class="replaceable"><code>mimetypes-file</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-mime</code> uninstall [<code class="option">--mode <em class="replaceable"><code>mode</code></em></code>] <em class="replaceable"><code>mimetypes-file</code></em> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-mime</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ The xdg-mime program can be used to query information about file types
+ and to add descriptions for new file types.
+ </p></div><div class="refsect1" title="Commands"><a name="commands"></a><h2>Commands</h2><div class="variablelist"><dl><dt><span class="term">query</span></dt><dd><p class="simpara">
+ Returns information related to file types.
+ </p><p class="simpara">
+ The <span class="emphasis"><em>query</em></span> option is for use inside a desktop session only.
+ It is not recommended to use xdg-mime query as root.
+ </p><p class="simpara">
+ The following queries are supported:
+ </p><p class="simpara">query filetype <em class="replaceable"><code>FILE</code></em>:
+ Returns the file type of <em class="replaceable"><code>FILE</code></em> in the form of a MIME type.
+ </p><p class="simpara">query default <em class="replaceable"><code>mimetype</code></em>:
+ Returns the default application that the desktop environment uses for opening
+ files of type <em class="replaceable"><code>mimetype</code></em>. The default application is
+ identified by its *.desktop file.
+ </p></dd><dt><span class="term">default</span></dt><dd><p class="simpara">
+ Ask the desktop environment to make <em class="replaceable"><code>application</code></em>
+ the default application for opening
+ files of type <em class="replaceable"><code>mimetype</code></em>. An
+ application can be made the default for several file types by
+ specifying multiple mimetypes.
+ </p><p class="simpara">
+ <em class="replaceable"><code>application</code></em> is the desktop file
+ id of the application and has the form vendor-name.desktop
+ <em class="replaceable"><code>application</code></em> must already be installed
+ in the desktop menu before it can be made the default handler.
+ The aplication's desktop file must list support for all the
+ MIME types that it wishes to be the default handler for.
+ </p><p class="simpara">
+ Requests to make an application a default handler may be
+ subject to system policy or approval by the end-user. xdg-mime
+ query can be used to verify whether an application is the
+ actual default handler for a specific file type.
+ </p><p class="simpara">
+ The <span class="emphasis"><em>default</em></span> option is for use inside a desktop session only.
+ It is not recommended to use xdg-mime default as root.
+ </p></dd><dt><span class="term">install</span></dt><dd>
+ Adds the file type descriptions provided in <em class="replaceable"><code>mimetypes-file</code></em>
+ to the desktop environment. <em class="replaceable"><code>mimetypes-file</code></em>
+ must be a XML file that follows the freedesktop.org
+ Shared MIME-info Database specification
+ and that has a mime-info element as its document root. For
+ each new file type one or more icons with name
+ <em class="replaceable"><code>type</code></em>-<em class="replaceable"><code>subtype</code></em>
+ must be installed with the <span class="command"><strong>xdg-icon-resource</strong></span>
+ command in the <span class="emphasis"><em>mimetypes</em></span> context. For example the
+ filetype application/vnd.oasis.opendocument.text requires an
+ icon named application-vnd.oasis.opendocument.text
+ to be installed (unless the file type recommends another icon name).
+ </dd><dt><span class="term">uninstall</span></dt><dd>
+ Removes the file type descriptions provided in <em class="replaceable"><code>mimetypes-file</code></em>
+ and previously added with <span class="command"><strong>xdg-mime install</strong></span> from the
+ desktop environment. <em class="replaceable"><code>mimetypes-file</code></em>
+ must be a XML file that follows the freedesktop.org
+ Shared MIME-info Database specification
+ and that has a mime-info element as its document root.
+ </dd></dl></div></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--mode</code> <em class="replaceable"><code>mode</code></em></span></dt><dd><p class="simpara"><em class="replaceable"><code>mode</code></em> can be
+ <span class="emphasis"><em>user</em></span> or <span class="emphasis"><em>system</em></span>.
+ In user mode the file is (un)installed for the current user
+ only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in
+ system mode.
+ </p><p class="simpara">
+ The default is to use system mode when called by root
+ and to use user mode when called by a non-root user.
+ </p></dd><dt><span class="term"><code class="option">--novendor</code></span></dt><dd><p class="simpara">
+ Normally, xdg-mime checks to ensure that the
+ <em class="replaceable"><code>mimetypes-file</code></em> to be installed
+ has a proper vendor prefix. This option can be
+ used to disable that check.
+ </p><p class="simpara">
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is
+ terminated with a dash ("-").
+ Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold
+ a trademark as their vendor prefix.
+ The purpose of the vendor prefix is to prevent name conflicts.
+ </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Environment Variables"><a name="env_vars"></a><h2>Environment Variables</h2><p>
+ xdg-mime honours the following environment variables:
+ </p><div class="variablelist"><dl><dt><span class="term">XDG_UTILS_DEBUG_LEVEL</span></dt><dd>
+ Setting this environment variable to a non-zero numerical value
+ makes xdg-mime do more verbose reporting on stderr.
+ Setting a higher value increases the verbosity.
+ </dd><dt><span class="term">XDG_UTILS_INSTALL_MODE</span></dt><dd>
+ This environment variable can be used by the user or
+ administrator to override the installation mode.
+ Valid values are <span class="emphasis"><em>user</em></span> and
+ <span class="emphasis"><em>system</em></span>.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd><dt><span class="term"><code class="option">5</code></span></dt><dd>
+ No permission to read one of the files passed on the command
+ line.
+ </dd></dl></div></div><div class="refsect1" title="See Also"><a name="seealso"></a><h2>See Also</h2><p><span class="citerefentry"><span class="refentrytitle">xdg-icon-resource</span>(1)</span>,
+ <span class="citerefentry"><span class="refentrytitle">xdg-desktop-menu</span>(1)</span>
+ </p></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+</p><pre class="programlisting">
+xdg-mime query filetype /tmp/foobar.png
+</pre><p>Prints the MIME type of the file /tmp/foobar.png, in this
+case image/png
+ </p><p>
+</p><pre class="programlisting">
+xdg-mime query default image/png
+</pre><p>Prints the .desktop filename of the application which is
+ registered to open PNG files.
+ </p><p>
+</p><pre class="programlisting">
+xdg-mime install shinythings-shiny.xml
+</pre><p>Adds a file type description for "shiny"-files.
+ "shinythings-" is used as the vendor prefix.
+ The file type description could look as folows.
+</p><pre class="programlisting">
+shinythings-shiny.xml:
+
+&lt;?xml version="1.0"?&gt;
+&lt;mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'&gt;
+ &lt;mime-type type="text/x-shiny"&gt;
+ &lt;comment&gt;Shiny new file type&lt;/comment&gt;
+ &lt;glob pattern="*.shiny"/&gt;
+ &lt;glob pattern="*.shi"/&gt;
+ &lt;/mime-type&gt;
+&lt;/mime-info&gt;
+</pre><p>An icon for this new file type must also be installed, for
+example with:
+</p><pre class="programlisting">
+xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
+</pre><p>
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-open.html b/scripts/html/xdg-open.html
new file mode 100644
index 0000000..2433500
--- /dev/null
+++ b/scripts/html/xdg-open.html
@@ -0,0 +1,38 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-open</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-open"><a name="xdg-open"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-open &#8212; opens a file or URL in the user's preferred application</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-open</code> { <code class="option"><em class="replaceable"><code>file</code></em></code> | <code class="option"><em class="replaceable"><code>URL</code></em></code> }</p></div><div class="cmdsynopsis"><p><code class="command">xdg-open</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ xdg-open opens a file or URL in the user's preferred application.
+ If a URL is provided the URL will be opened in the user's preferred
+ web browser. If a file is provided the file will be opened in the
+ preferred application for files of that type. xdg-open supports
+ file, ftp, http and https URLs.
+ </p><p>
+ xdg-open is for use inside a desktop session only.
+ It is not recommended to use xdg-open as root.
+ </p></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd></dl></div></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+</p><pre class="programlisting">
+xdg-open 'http://www.freedesktop.org/'
+</pre><p>
+ Opens the Freedesktop.org website in the user's default browser
+ </p><p>
+</p><pre class="programlisting">
+xdg-open /tmp/foobar.png
+</pre><p>
+ Opens the PNG image file /tmp/foobar.png in the user's default image
+ viewing application.
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-screensaver.html b/scripts/html/xdg-screensaver.html
new file mode 100644
index 0000000..219f48c
--- /dev/null
+++ b/scripts/html/xdg-screensaver.html
@@ -0,0 +1,63 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-screensaver</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-screensaver"><a name="xdg-screensaver"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-screensaver &#8212; command line tool for controlling the screensaver</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-screensaver</code> <code class="option">suspend <em class="replaceable"><code>WindowID</code></em></code> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-screensaver</code> <code class="option">resume <em class="replaceable"><code>WindowID</code></em></code> </p></div><div class="cmdsynopsis"><p><code class="command">xdg-screensaver</code> { <code class="option">activate</code> | <code class="option">lock</code> | <code class="option">reset</code> | <code class="option">status</code> }</p></div><div class="cmdsynopsis"><p><code class="command">xdg-screensaver</code> { <code class="option">--help</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ xdg-screensaver provides commands to control the screensaver.
+ </p><p>
+ xdg-screensaver is for use inside a desktop session only.
+ It is not recommended to use xdg-screensaver as root.
+ </p></div><div class="refsect1" title="Commands"><a name="commands"></a><h2>Commands</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">suspend <em class="replaceable"><code>WindowID</code></em></code></span></dt><dd><p class="simpara">
+ Suspends the screensaver and monitor power management.
+ <em class="replaceable"><code>WindowID</code></em> must be the X Window ID
+ of an existing window of the calling application. The window
+ must remain in existance for the duration of the suspension.
+ </p><p class="simpara">
+ WindowID can be represented as either a decimal number
+ or as a hexadecimal number consisting of the prefix
+ <span class="emphasis"><em>0x</em></span> followed by one or more hexadecimal
+ digits.
+ </p><p class="simpara">
+ The screensaver can be suspended in relation to multiple
+ windows at the same time. In that case screensaver
+ operation is only restored once the screensaver has been
+ resumed in relation to each of the windows
+ </p></dd><dt><span class="term"><code class="option">resume <em class="replaceable"><code>WindowID</code></em></code></span></dt><dd>
+ Resume the screensaver and monitor power management after being
+ suspended.
+ <em class="replaceable"><code>WindowID</code></em>
+ must be the same X Window ID that was passed to a previous call
+ of <span class="command"><strong>xdg-screensaver suspend</strong></span>
+ </dd><dt><span class="term"><code class="option">activate</code></span></dt><dd>
+ Turns the screensaver on immediately. This may result in the
+ screen getting locked, depending on existing system policies.
+ </dd><dt><span class="term"><code class="option">lock</code></span></dt><dd>
+ Lock the screen immediately.
+ </dd><dt><span class="term"><code class="option">reset</code></span></dt><dd>
+ Turns the screensaver off immediately. If the screen was locked
+ the user may be asked to authenticate first.
+ </dd><dt><span class="term"><code class="option">status</code></span></dt><dd>
+ Prints <span class="emphasis"><em>enabled</em></span> to stdout if the
+ screensaver is enabled to turn on after a period of
+ inactivity and prints
+ <span class="emphasis"><em>disabled</em></span> if the screensaver is
+ not enabled.
+ </dd></dl></div></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd></dl></div></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+</p><pre class="programlisting">
+xdg-screensaver suspend 0x1c00007
+</pre><p>Causes the screensaver to be disabled till
+ <span class="command"><strong>xdg-screensaver resume 0x1c00007</strong></span> is called.
+ <span class="emphasis"><em>0x1c00007</em></span> must be the X Window ID of an
+ existing window.
+ </p></div></div></body></html>
diff --git a/scripts/html/xdg-settings.html b/scripts/html/xdg-settings.html
new file mode 100644
index 0000000..380ad2a
--- /dev/null
+++ b/scripts/html/xdg-settings.html
@@ -0,0 +1,59 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xdg-settings</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" title="xdg-settings"><a name="xdg-settings"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xdg-settings &#8212; get various settings from the desktop environment</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xdg-settings</code> { <code class="option"><em class="replaceable"><code>get</code></em></code> | <code class="option"><em class="replaceable"><code>check</code></em></code> | <code class="option"><em class="replaceable"><code>set</code></em></code> } {<code class="option">property</code>} [<code class="option">subproperty</code>] [<code class="option">value</code>]</p></div><div class="cmdsynopsis"><p><code class="command">xdg-settings</code> { <code class="option">--help</code> | <code class="option">--list</code> | <code class="option">--manual</code> | <code class="option">--version</code> }</p></div></div><div class="refsect1" title="Description"><a name="description"></a><h2>Description</h2><p>
+ xdg-settings gets various settings from the desktop environment.
+ For instance, desktop environments often provide proxy configuration
+ and default web browser settings. Using xdg-settings these parameters
+ can be extracted for use by applications that do not use the desktop
+ environment's libraries (which would use the settings natively).
+ </p><p>
+ xdg-settings is for use inside a desktop session only.
+ It is not recommended to use xdg-settings as root.
+ </p></div><div class="refsect1" title="Options"><a name="options"></a><h2>Options</h2><div class="variablelist"><dl><dt><span class="term"><code class="option">--help</code></span></dt><dd>
+ Show command synopsis.
+ </dd><dt><span class="term"><code class="option">--list</code></span></dt><dd>
+ List all properties xdg-settings knows about.
+ </dd><dt><span class="term"><code class="option">--manual</code></span></dt><dd>
+ Show this manualpage.
+ </dd><dt><span class="term"><code class="option">--version</code></span></dt><dd>
+ Show the xdg-utils version information.
+ </dd></dl></div></div><div class="refsect1" title="Properties"><a name="properties"></a><h2>Properties</h2><p>
+ When using xdg-settings to get, check or set a destkop setting, properties
+ and possibly sub-properties are used to specify the setting to be changed.
+ </p><p>
+ Some properties (such as default-web-browser) fully describe the setting
+ to be changed. Other properties (such as default-url-scheme-handler) require
+ more information (in this case the actual scheme to set the default handler
+ for) which must be provided in a sub-property.
+ </p></div><div class="refsect1" title="Exit Codes"><a name="exitcodes"></a><h2>Exit Codes</h2><p>
+ An exit code of 0 indicates success while a non-zero exit code
+ indicates failure. The following failure codes can be returned:
+ </p><div class="variablelist"><dl><dt><span class="term"><code class="option">1</code></span></dt><dd>
+ Error in command line syntax.
+ </dd><dt><span class="term"><code class="option">2</code></span></dt><dd>
+ One of the files passed on the command line did not exist.
+ </dd><dt><span class="term"><code class="option">3</code></span></dt><dd>
+ A required tool could not be found.
+ </dd><dt><span class="term"><code class="option">4</code></span></dt><dd>
+ The action failed.
+ </dd></dl></div></div><div class="refsect1" title="Examples"><a name="examples"></a><h2>Examples</h2><p>
+ Get the desktop file name of the current default web browser
+ </p><pre class="programlisting">
+ xdg-settings get default-web-browser
+ </pre><p>
+ </p><p>
+ Check whether the default web browser is firefox.desktop, which can be
+ false even if "get default-web-browser" says that is the current value
+ (if only some of the underlying settings actually reflect that value)
+ </p><pre class="programlisting">
+ xdg-settings check default-web-browser firefox.desktop
+ </pre><p>
+ </p><p>
+ Set the default web browser to google-chrome.desktop
+ </p><pre class="programlisting">
+ xdg-settings set default-web-browser google-chrome.desktop
+ </pre><p>
+ </p><p>
+ Set the default mailto URL scheme handler to be evolution.desktop
+ </p><pre class="programlisting">
+ xdg-settings set default-url-scheme-handler mailto evolution.desktop
+ </pre><p>
+ </p></div></div></body></html>
diff --git a/scripts/man/.gitignore b/scripts/man/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/scripts/man/.gitignore
diff --git a/scripts/man/xdg-desktop-icon.1 b/scripts/man/xdg-desktop-icon.1
new file mode 100644
index 0000000..0b062d2
--- /dev/null
+++ b/scripts/man/xdg-desktop-icon.1
@@ -0,0 +1,241 @@
+'\" t
+.\" Title: xdg-desktop-icon
+.\" Author: Kevin Krammer
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-desktop-icon Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-DESKTOP\-ICON" "1" "12/31/2010" "xdg-utils 1.0" "xdg-desktop-icon Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-desktop-icon \- command line tool for (un)installing icons to the desktop
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-desktop\-icon\fR\ 'u
+\fBxdg\-desktop\-icon\fR install [\fB\-\-novendor\fR] \fIFILE\fR
+.HP \w'\fBxdg\-desktop\-icon\fR\ 'u
+\fBxdg\-desktop\-icon\fR uninstall \fIFILE\fR
+.HP \w'\fBxdg\-desktop\-icon\fR\ 'u
+\fBxdg\-desktop\-icon\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+The xdg\-desktop\-icon program can be used to install an application launcher or other file on the desktop of the current user\&.
+.PP
+An application launcher is represented by a *\&.desktop file\&. Desktop files are defined by the freedesktop\&.org Desktop Entry Specification\&. The most important aspects of *\&.desktop files are summarized below\&.
+.SH "COMMANDS"
+.PP
+install
+.RS 4
+Installs
+\fIFILE\fR
+to the desktop of the current user\&.
+\fIFILE\fR
+can be a *\&.desktop file or any other type of file\&.
+.RE
+.PP
+uninstall
+.RS 4
+Removes
+\fIFILE\fR
+from the desktop of the current user\&.
+.RE
+.SH "OPTIONS"
+.PP
+\fB\-\-novendor\fR
+.RS 4
+Normally, xdg\-desktop\-icon checks to ensure that a *\&.desktop file to be installed has a vendor prefix\&. This option can be used to disable that check\&.
+.sp
+A vendor prefix consists of alpha characters ([a\-zA\-Z]) and is terminated with a dash ("\-")\&. Companies and organizations are encouraged to use a word or phrase, preferably the organizations name, for which they hold a trademark as their vendor prefix\&. The purpose of the vendor prefix is to prevent name conflicts\&.
+.RE
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "DESKTOP FILES"
+.PP
+An application launcher can be added to the desktop by installing a *\&.desktop file\&. A *\&.desktop file consists of a
+\fI[Desktop Entry]\fR
+header followed by several
+\fIKey\fR=\fIValue\fR
+lines\&.
+.PP
+A *\&.desktop file can provide a name and description for an application in several different languages\&. This is done by adding a language code as used by LC_MESSAGES in square brackets behind the
+\fIKey\fR\&. This way one can specify different values for the same
+\fIKey\fR
+depending on the currently selected language\&.
+.PP
+The following keys are often used:
+.PP
+Value=1\&.0
+.RS 4
+This is a mandatory field to indicate that the *\&.desktop file follows the 1\&.0 version of the specification\&.
+.RE
+.PP
+Type=Application
+.RS 4
+This is a mandatory field that indicates that the *\&.desktop file describes an application launcher\&.
+.RE
+.PP
+Name=\fIApplication Name\fR
+.RS 4
+The name of the application\&. For example
+\fIMozilla\fR
+.RE
+.PP
+GenericName=\fIGeneric Name\fR
+.RS 4
+A generic description of the application\&. For example
+\fIWeb Browser\fR
+.RE
+.PP
+Comment=\fIComment\fR
+.RS 4
+Optional field to specify a tooltip for the application\&. For example
+\fIVisit websites on the Internet\fR
+.RE
+.PP
+Icon=\fIIcon File\fR
+.RS 4
+The icon to use for the application\&. This can either be an absolute path to an image file or an icon\-name\&. If an icon\-name is provided an image lookup by name is done in the user\*(Aqs current icon theme\&. The
+\fBxdg\-icon\-resource\fR
+command can be used to install image files into icon themes\&. The advantage of using an icon\-name instead of an absolute path is that with an icon\-name the application icon can be provided in several different sizes as well as in several differently themed styles\&.
+.RE
+.PP
+Exec=\fICommand Line\fR
+.RS 4
+The command line to start the application\&. If the application can open files the %f placeholder should be specified\&. When a file is dropped on the application launcher the %f is replaced with the file path of the dropped file\&. If multiple files can be specified on the command line the %F placeholder should be used instead of %f\&. If the application is able to open URLs in addition to local files then %u or %U can be used instead of %f or %F\&.
+.RE
+.PP
+For a complete oveview of the *\&.desktop file format please visit http://www\&.freedesktop\&.org/wiki/Standards/desktop\-entry\-spec
+.SH "ENVIRONMENT VARIABLES"
+.PP
+xdg\-desktop\-icon honours the following environment variables:
+.PP
+XDG_UTILS_DEBUG_LEVEL
+.RS 4
+Setting this environment variable to a non\-zero numerical value makes xdg\-desktop\-icon do more verbose reporting on stderr\&. Setting a higher value increases the verbosity\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.PP
+\fB5\fR
+.RS 4
+No permission to read one of the files passed on the command line\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fBxdg-icon-resource\fR(1)
+.SH "EXAMPLES"
+.PP
+The company ShinyThings Inc\&. has developed an application named "WebMirror" and would like to add a launcher for for on the desktop\&. The company will use "shinythings" as its vendor id\&. In order to add the application to the desktop there needs to be a \&.desktop file for the application:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+shinythings\-webmirror\&.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF\-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings\-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Now the xdg\-desktop\-icon tool can be used to add the webmirror\&.desktop file to the desktop:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-desktop\-icon install \&./shinythings\-webmirror\&.desktop
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+To add a README file to the desktop as well, the following command can be used:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-desktop\-icon install \&./shinythings\-README
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "AUTHORS"
+.PP
+\fBKevin Krammer\fR
+.RS 4
+Author.
+.RE
+.PP
+\fBJeremy White\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-desktop-menu.1 b/scripts/man/xdg-desktop-menu.1
new file mode 100644
index 0000000..b5ca38a
--- /dev/null
+++ b/scripts/man/xdg-desktop-menu.1
@@ -0,0 +1,448 @@
+'\" t
+.\" Title: xdg-desktop-menu
+.\" Author: Kevin Krammer
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-desktop-menu Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-DESKTOP\-MENU" "1" "12/31/2010" "xdg-utils 1.0" "xdg-desktop-menu Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-desktop-menu \- command line tool for (un)installing desktop menu items
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-desktop\-menu\fR\ 'u
+\fBxdg\-desktop\-menu\fR install [\fB\-\-noupdate\fR] [\fB\-\-novendor\fR] [\fB\-\-mode\ \fR\fB\fImode\fR\fR] \fIdirectory\-file(s)\fR \fIdesktop\-file(s)\fR
+.HP \w'\fBxdg\-desktop\-menu\fR\ 'u
+\fBxdg\-desktop\-menu\fR uninstall [\fB\-\-noupdate\fR] [\fB\-\-mode\ \fR\fB\fImode\fR\fR] \fIdirectory\-file(s)\fR \fIdesktop\-file(s)\fR
+.HP \w'\fBxdg\-desktop\-menu\fR\ 'u
+\fBxdg\-desktop\-menu\fR forceupdate [\fB\-\-mode\ \fR\fB\fImode\fR\fR]
+.HP \w'\fBxdg\-desktop\-menu\fR\ 'u
+\fBxdg\-desktop\-menu\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+The xdg\-desktop\-menu program can be used to install new menu entries to the desktop\*(Aqs application menu\&.
+.PP
+The application menu works according to the XDG Desktop Menu Specification at http://www\&.freedesktop\&.org/Standards/menu\-spec
+.SH "COMMANDS"
+.PP
+install
+.RS 4
+Install one or more applications in a submenu of the desktop menu system\&.
+.sp
+\fIdesktop\-file\fR: A desktop file represents a single menu entry in the menu\&. Desktop files are defined by the freedesktop\&.org Desktop Entry Specification\&. The most important aspects of *\&.desktop files are summarized below\&.
+.sp
+Menu entries can be added to the menu system in two different ways\&. They can either be added to a predefined submenu in the menu system based on one or more category keywords, or they can be added to a new submenu\&.
+.sp
+To add a menu entry to a predefined submenu the desktop file that represents the menu entry must have a Categories= entry that lists one or more keywords\&. The menu item will be included in an appropriate submenu based on the included keywords\&.
+.sp
+To add menu items to a new submenu the desktop\-files must be preceded by a directory\-file that describes the submenu\&. If multiple desktop\-files are specified, all entries will be added to the same menu\&. If entries are installed to a menu that has been created with a previous call to
+\fBxdg\-desktop\-menu\fR
+the entries will be installed in addition to any already existing entries\&.
+.sp
+\fIdirectory\-file\fR: The *\&.directory file indicated by
+\fIdirectory\-file\fR
+represents a submenu\&. The directory file provides the name and icon for a submenu\&. The name of the directory file is used to identify the submenu\&.
+.sp
+If multiple directory files are provided each file will represent a submenu within the menu that preceeds it, creating a nested menu hierarchy (sub\-sub\-menus)\&. The menu entries themselves will be added to the last submenu\&.
+.sp
+Directory files follow the syntax defined by the freedesktop\&.org Desktop Entry Specification\&.
+.RE
+.PP
+uninstall
+.RS 4
+Remove applications or submenus from the desktop menu system previously installed with
+\fBxdg\-desktop\-menu install\fR\&.
+.sp
+A submenu and the associated directory file is only removed when the submenu no longer contains any menu entries\&.
+.RE
+.PP
+forceupdate
+.RS 4
+Force an update of the menu system\&.
+.sp
+This command is only useful if the last call to xdg\-desktop\-menu included the
+\fB\-\-noupdate\fR
+option\&.
+.RE
+.SH "OPTIONS"
+.PP
+\fB\-\-noupdate\fR
+.RS 4
+Postpone updating the menu system\&. If multiple updates to the menu system are made in sequence this flag can be used to indicate that additional changes will follow and that it is not necassery to update the menu system right away\&.
+.RE
+.PP
+\fB\-\-novendor\fR
+.RS 4
+Normally, xdg\-desktop\-menu checks to ensure that any *\&.directory and *\&.desktop files to be installed has a vendor prefix\&. This option can be used to disable that check\&.
+.sp
+A vendor prefix consists of alpha characters ([a\-zA\-Z]) and is terminated with a dash ("\-")\&. Companies and organizations are encouraged to use a word or phrase, preferably the organizations name, for which they hold a trademark as their vendor prefix\&. The purpose of the vendor prefix is to prevent name conflicts\&.
+.RE
+.PP
+\fB\-\-mode\fR \fImode\fR
+.RS 4
+\fImode\fR
+can be
+\fIuser\fR
+or
+\fIsystem\fR\&. In user mode the file is (un)installed for the current user only\&. In system mode the file is (un)installed for all users on the system\&. Usually only root is allowed to install in system mode\&.
+.sp
+The default is to use system mode when called by root and to use user mode when called by a non\-root user\&.
+.RE
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "DESKTOP FILES"
+.PP
+An application item in the application menu is represented by a *\&.desktop file\&. A *\&.desktop file consists of a
+\fI[Desktop Entry]\fR
+header followed by several
+\fIKey\fR=\fIValue\fR
+lines\&.
+.PP
+A *\&.desktop file can provide a name and description for an application in several different languages\&. This is done by adding a language code as used by LC_MESSAGES in square brackets behind the
+\fIKey\fR\&. This way one can specify different values for the same
+\fIKey\fR
+depending on the currently selected language\&.
+.PP
+The following keys are often used:
+.PP
+Value=1\&.0
+.RS 4
+This is a mandatory field to indicate that the *\&.desktop file follows the 1\&.0 version of the specification\&.
+.RE
+.PP
+Type=Application
+.RS 4
+This is a mandatory field that indicates that the *\&.desktop file describes an application launcher\&.
+.RE
+.PP
+Name=\fIApplication Name\fR
+.RS 4
+The name of the application\&. For example
+\fIMozilla\fR
+.RE
+.PP
+GenericName=\fIGeneric Name\fR
+.RS 4
+A generic description of the application\&. For example
+\fIWeb Browser\fR
+.RE
+.PP
+Comment=\fIComment\fR
+.RS 4
+Optional field to specify a tooltip for the application\&. For example
+\fIVisit websites on the Internet\fR
+.RE
+.PP
+Icon=\fIIcon File\fR
+.RS 4
+The icon to use for the application\&. This can either be an absolute path to an image file or an icon\-name\&. If an icon\-name is provided an image lookup by name is done in the user\*(Aqs current icon theme\&. The
+\fBxdg\-icon\-resource\fR
+command can be used to install image files into icon themes\&. The advantage of using an icon\-name instead of an absolute path is that with an icon\-name the application icon can be provided in several different sizes as well as in several differently themed styles\&.
+.RE
+.PP
+Exec=\fICommand Line\fR
+.RS 4
+The command line to start the application\&. If the application can open files the %f placeholder should be specified\&. When a file is dropped on the application launcher the %f is replaced with the file path of the dropped file\&. If multiple files can be specified on the command line the %F placeholder should be used instead of %f\&. If the application is able to open URLs in addition to local files then %u or %U can be used instead of %f or %F\&.
+.RE
+.PP
+Categories=\fICategories\fR
+.RS 4
+A list of categories separated by semi\-colons\&. A category is a keyword that describes and classifies the application\&. By default applications are organized in the application menu based on category\&. When menu entries are explicitly assigned to a new submenu it is not necassery to list any categories\&.
+.sp
+When using categories it is recommended to include one of the following categories: AudioVideo, Development, Education, Game, Graphics, Network, Office, Settings, System, Utility\&.
+.sp
+See Appendix A of the XDG Desktop Menu Specification for information about additional categories\&. http://standards\&.freedesktop\&.org/menu\-spec/menu\-spec\-1\&.0\&.html
+.RE
+.PP
+MimeType=\fIMimetypes\fR
+.RS 4
+A list of mimetypes separated by semi\-colons\&. This field is used to indicate which file types the application is able to open\&.
+.RE
+.PP
+For a complete oveview of the *\&.desktop file format please visit http://www\&.freedesktop\&.org/wiki/Standards/desktop\-entry\-spec
+.SH "DIRECTORY FILES"
+.PP
+The appearance of submenu in the application menu is provided by a *\&.directory file\&. In particular it provides the title of the submenu and a possible icon\&. A *\&.directory file consists of a
+\fI[Desktop Entry]\fR
+header followed by several
+\fIKey\fR=\fIValue\fR
+lines\&.
+.PP
+A *\&.directory file can provide a title (name) for the submenu in several different languages\&. This is done by adding a language code as used by LC_MESSAGES in square brackets behind the
+\fIKey\fR\&. This way one can specify different values for the same
+\fIKey\fR
+depending on the currently selected language\&.
+.PP
+The following keys are relevqnt for submenus:
+.PP
+Value=1\&.0
+.RS 4
+This is a mandatory field to indicate that the *\&.directory file follows the 1\&.0 version of the Desktop Entry specification\&.
+.RE
+.PP
+Type=Directory
+.RS 4
+This is a mandatory field that indicates that the *\&.directory file describes a submenu\&.
+.RE
+.PP
+Name=\fIMenu Name\fR
+.RS 4
+The title of submenu\&. For example
+\fIMozilla\fR
+.RE
+.PP
+Comment=\fIComment\fR
+.RS 4
+Optional field to specify a tooltip for the submenu\&.
+.RE
+.PP
+Icon=\fIIcon File\fR
+.RS 4
+The icon to use for the submenu\&. This can either be an absolute path to an image file or an icon\-name\&. If an icon\-name is provided an image lookup by name is done in the user\*(Aqs current icon theme\&. The
+\fBxdg\-icon\-resource\fR
+command can be used to install image files into icon themes\&. The advantage of using an icon\-name instead of an absolute path is that with an icon\-name the submenu icon can be provided in several different sizes as well as in several differently themed styles\&.
+.RE
+.SH "ENVIRONMENT VARIABLES"
+.PP
+xdg\-desktop\-menu honours the following environment variables:
+.PP
+XDG_UTILS_DEBUG_LEVEL
+.RS 4
+Setting this environment variable to a non\-zero numerical value makes xdg\-desktop\-menu do more verbose reporting on stderr\&. Setting a higher value increases the verbosity\&.
+.RE
+.PP
+XDG_UTILS_INSTALL_MODE
+.RS 4
+This environment variable can be used by the user or administrator to override the installation mode\&. Valid values are
+\fIuser\fR
+and
+\fIsystem\fR\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.PP
+\fB5\fR
+.RS 4
+No permission to read one of the files passed on the command line\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fBxdg-desktop-icon\fR(1),
+\fBxdg-icon-resource\fR(1),
+\fBxdg-mime\fR(1)
+.SH "EXAMPLES"
+.PP
+The company ShinyThings Inc\&. has developed an application named "WebMirror" and would like to add it to the application menu\&. The company will use "shinythings" as its vendor id\&. In order to add the application to the menu there needs to be a \&.desktop file with a suitable
+\fICategories\fR
+entry:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+shinythings\-webmirror\&.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF\-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+ Categories=Network;WebDevelopment;
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Now the xdg\-desktop\-menu tool can be used to add the shinythings\-webmirror\&.desktop file to the desktop application menu:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-desktop\-menu install \&./shinythings\-webmirror\&.desktop
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Note that for the purpose of this example the menu items are available in two languages, English and Dutch\&. The language code for Dutch is nl\&.
+.PP
+In the next example the company ShinyThings Inc\&. will add its own submenu to the desktop application menu consisting of a "WebMirror" menu item and a "WebMirror Admin Tool" menu item\&.
+.PP
+First the company needs to create two \&.desktop files that describe the two menu items\&. Since the items are to be added to a new submenu it is not necassery to include a Categories= line:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+shinythings\-webmirror\&.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF\-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings\-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+
+shinythings\-webmirror\-admin\&.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF\-8
+ Type=Application
+
+ Exec=webmirror\-admintool
+ Icon=shinythings\-webmirror\-admintool
+
+ Name=WebMirror Admin Tool
+ Name[nl]=WebSpiegel Administratie Tool
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+In addition a \&.directory file needs to be created to provide a title and icon for the sub\-menu itself:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+shinythings\-webmirror\&.directory:
+
+ [Desktop Entry]
+ Encoding=UTF\-8
+
+ Icon=shinythings\-webmirror\-menu
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+These file can now be installed with:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-desktop\-menu install \&./shinythings\-webmirror\&.directory \e
+ \&./shinythings\-webmirror\&.desktop \&./shinythings\-webmirror\-admin\&.desktop
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+The menu entries could also be installed one by one:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-desktop\-menu install \-\-noupdate \&./shinythings\-webmirror\&.directory \e
+ \&./shinythings\-webmirror\&.desktop
+xdg\-desktop\-menu install \-\-noupdate \&./shinythings\-webmirror\&.directory \e
+ \&./shinythings\-webmirror\-admin\&.desktop
+xdg\-desktop\-menu forceupdate
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Although the result is the same it is slightly more efficient to install all files at the same time\&.
+.PP
+The *\&.desktop and *\&.directory files reference icons with the names webmirror, webmirror\-admin and webmirror\-menu which should also be installed\&. In this example the icons are installed in two different sizes, once with a size of 22x22 pixels and once with a size of 64x64 pixels:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-icon\-resource install \-\-size 22 \&./wmicon\-22\&.png shinythings\-webmirror
+xdg\-icon\-resource install \-\-size 22 \&./wmicon\-menu\-22\&.png shinythings\-webmirror\-menu
+xdg\-icon\-resource install \-\-size 22 \&./wmicon\-admin\-22\&.png shinythings\-webmirror\-admin
+xdg\-icon\-resource install \-\-size 64 \&./wmicon\-64\&.png shinythings\-webmirror
+xdg\-icon\-resource install \-\-size 64 \&./wmicon\-menu\-64\&.png shinythings\-webmirror\-menu
+xdg\-icon\-resource install \-\-size 64 \&./wmicon\-admin\-64\&.png shinythings\-webmirror\-admin
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "AUTHORS"
+.PP
+\fBKevin Krammer\fR
+.RS 4
+Author.
+.RE
+.PP
+\fBJeremy White\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-email.1 b/scripts/man/xdg-email.1
new file mode 100644
index 0000000..09d1709
--- /dev/null
+++ b/scripts/man/xdg-email.1
@@ -0,0 +1,199 @@
+'\" t
+.\" Title: xdg-email
+.\" Author: Kevin Krammer
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-email Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-EMAIL" "1" "12/31/2010" "xdg-utils 1.0" "xdg-email Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-email \- command line tool for sending mail using the user\*(Aqs preferred e\-mail composer
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-email\fR\ 'u
+\fBxdg\-email\fR [\fB\-\-utf8\fR] [\fB\-\-cc\fR\ \fIaddress\fR] [\fB\-\-bcc\fR\ \fIaddress\fR] [\fB\-\-subject\fR\ \fItext\fR] [\fB\-\-body\fR\ \fItext\fR] [\fB\-\-attach\fR\ \fIfile\fR] [\fImailto\-uri\fR | \fIaddress(es)\fR]
+.HP \w'\fBxdg\-email\fR\ 'u
+\fBxdg\-email\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+xdg\-email opens the user\*(Aqs preferred e\-mail composer in order to send a mail to
+\fIaddress(es)\fR
+or
+\fImailto\-uri\fR\&. RFC2368 defines mailto: URIs\&. xdg\-email limits support to, cc, subject and body fields in
+\fImailto\-uri\fR, all other fields are silently ignored\&.
+\fIaddress(es)\fR
+must follow the syntax of RFC822\&. Multiple addresses may be provided as separate arguments\&.
+.PP
+All information provided on the command line is used to prefill corresponding fields in the user\*(Aqs e\-mail composer\&. The user will have the opportunity to change any of this information before actually sending the e\-mail\&.
+.PP
+xdg\-email is for use inside a desktop session only\&. It is not recommended to use xdg\-email as root\&.
+.PP
+See http://portland\&.freedesktop\&.org/EmailConfig for information on how the user can change the e\-mail composer that is used\&.
+.SH "OPTIONS"
+.PP
+\fB\-\-utf8\fR
+.RS 4
+Indicates that all command line options that follow are in utf8\&. Without this option, command line options are expected to be encoded according to locale\&. If the locale already specifies utf8 this option has no effect\&. This option does not affect mailto URIs that are passed on the command line\&.
+.RE
+.PP
+\fB\-\-cc\fR \fIaddress\fR
+.RS 4
+Specify a recipient to be copied on the e\-mail\&.
+.RE
+.PP
+\fB\-\-bcc\fR \fIaddress\fR
+.RS 4
+Specify a recipient to be blindly copied on the e\-mail\&.
+.RE
+.PP
+\fB\-\-subject\fR \fItext\fR
+.RS 4
+Specify a subject for the e\-mail\&.
+.RE
+.PP
+\fB\-\-body\fR \fItext\fR
+.RS 4
+Specify a body for the e\-mail\&. Since the user will be able to make changes before actually sending the e\-mail, this can be used to provide the user with a template for the e\-mail\&.
+\fItext\fR
+may contain linebreaks\&.
+.RE
+.PP
+\fB\-\-attach\fR \fIfile\fR
+.RS 4
+Specify an attachment for the e\-mail\&.
+\fIfile\fR
+must point to an existing file\&.
+.sp
+Some e\-mail applications require the file to remain present after xdg\-email returns\&.
+.RE
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "ENVIRONMENT VARIABLES"
+.PP
+xdg\-email honours the following environment variables:
+.PP
+XDG_UTILS_DEBUG_LEVEL
+.RS 4
+Setting this environment variable to a non\-zero numerical value makes xdg\-email do more verbose reporting on stderr\&. Setting a higher value increases the verbosity\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.PP
+\fB5\fR
+.RS 4
+No permission to read one of the files passed on the command line\&.
+.RE
+.SH "CONFIGURATION"
+.PP
+Visit http://portland\&.freedesktop\&.org/EmailConfig for information how to configure xdg\-email to use the email client of your choice\&.
+.SH "EXAMPLES"
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-email \*(AqJeremy White <jwhite@example\&.com>\*(Aq
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-email \-\-attach /tmp/logo\&.png \e
+ \-\-subject \*(AqLogo contest\*(Aq \e
+ \-\-body \*(AqAttached you find the logo for the contest\&.\*(Aq \e
+ \*(Aqjwhite@example\&.com\*(Aq
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-email \-\-subject \*(AqYour password is about to expire\*(Aq \e
+ \*(Aqjwhite@example\&.com\*(Aq \*(Aqbastian@example\&.com\*(Aq \*(Aqwhipple@example\&.com\*(Aq
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "AUTHORS"
+.PP
+\fBKevin Krammer\fR
+.RS 4
+Author.
+.RE
+.PP
+\fBJeremy White\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-icon-resource.1 b/scripts/man/xdg-icon-resource.1
new file mode 100644
index 0000000..283b903
--- /dev/null
+++ b/scripts/man/xdg-icon-resource.1
@@ -0,0 +1,244 @@
+'\" t
+.\" Title: xdg-icon-resource
+.\" Author: Kevin Krammer
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-icon-resource Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-ICON\-RESOURCE" "1" "12/31/2010" "xdg-utils 1.0" "xdg-icon-resource Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-icon-resource \- command line tool for (un)installing icon resources
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-icon\-resource\fR\ 'u
+\fBxdg\-icon\-resource\fR install [\fB\-\-noupdate\fR] [\fB\-\-novendor\fR] [\fB\-\-theme\ \fR\fB\fItheme\fR\fR] [\fB\-\-context\ \fR\fB\fIcontext\fR\fR] [\fB\-\-mode\ \fR\fB\fImode\fR\fR] \fB\-\-size\ \fR\fB\fIsize\fR\fR \fIicon\-file\fR [\fIicon\-name\fR]
+.HP \w'\fBxdg\-icon\-resource\fR\ 'u
+\fBxdg\-icon\-resource\fR uninstall [\fB\-\-noupdate\fR] [\fB\-\-theme\ \fR\fB\fItheme\fR\fR] [\fB\-\-context\ \fR\fB\fIcontext\fR\fR] [\fB\-\-mode\ \fR\fB\fImode\fR\fR] \fB\-\-size\ \fR\fB\fIsize\fR\fR \fIicon\-name\fR
+.HP \w'\fBxdg\-icon\-resource\fR\ 'u
+\fBxdg\-icon\-resource\fR forceupdate [\fB\-\-theme\ \fR\fB\fItheme\fR\fR] [\fB\-\-mode\ \fR\fB\fImode\fR\fR]
+.HP \w'\fBxdg\-icon\-resource\fR\ 'u
+\fBxdg\-icon\-resource\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+The xdg\-icon\-resource program can be used to install icon resources into the desktop icon system in order to illustrate menu entries, to depict desktop icons or to graphically represent file types\&.
+.PP
+The desktop icon system identifies icons by name\&. Depending on the required size, the choice of icon theme and the context in which the icon is used, the desktop icon system locates an appropriate icon resource to depict an icon\&. Icon resources can be XPM files or PNG files\&.
+.PP
+The desktop icon system works according to the XDG Icon Theme Specification at http://www\&.freedesktop\&.org/Standards/icon\-theme\-spec
+.SH "COMMANDS"
+.PP
+install
+.RS 4
+Installs the icon file indicated by
+\fIicon\-file\fR
+to the desktop icon system under the name
+\fIicon\-name\fR\&. Icon names do not have an extension\&. If
+\fIicon\-name\fR
+is not provided the name is derived from
+\fIicon\-file\fR\&. The icon file must have
+\fI\&.png\fR
+or
+\fI\&.xpm\fR
+as extension\&. If a corresponding
+\fI\&.icon\fR
+file exists in the same location as
+\fIicon\-file\fR
+it will be installed as well\&.
+.RE
+.PP
+uninstall
+.RS 4
+Removes the icon indicated by
+\fIicon\-name\fR
+from the desktop icon system\&. Note that icon names do not have an extension\&.
+.RE
+.PP
+forceupdate
+.RS 4
+Force an update of the desktop icon system\&. This is only useful if the last call to xdg\-icon\-resource included the
+\fB\-\-noupdate\fR
+option\&.
+.RE
+.SH "OPTIONS"
+.PP
+\fB\-\-noupdate\fR
+.RS 4
+Postpone updating the desktop icon system\&. If multiple icons are added in sequence this flag can be used to indicate that additional changes will follow and that it is not necassery to update the desktop icon system right away\&.
+.RE
+.PP
+\fB\-\-novendor\fR
+.RS 4
+Normally, xdg\-icon\-resource checks to ensure that an icon file to be installed in the
+\fIapps\fR
+context has a proper vendor prefix\&. This option can be used to disable that check\&.
+.sp
+A vendor prefix consists of alpha characters ([a\-zA\-Z]) and is terminated with a dash ("\-")\&. Companies and organizations are encouraged to use a word or phrase, preferably the organizations name, for which they hold a trademark as their vendor prefix\&. The purpose of the vendor prefix is to prevent name conflicts\&.
+.RE
+.PP
+\fB\-\-theme\fR \fItheme\fR
+.RS 4
+Installs or removes the icon file as part of
+\fItheme\fR\&. If no theme is specified the icons will be installed as part of the default
+\fIhicolor\fR
+theme\&. Applications may install icons under multiple themes but should at least install icons for the default
+\fIhicolor\fR
+theme\&.
+.RE
+.PP
+\fB\-\-context\fR \fIcontext\fR
+.RS 4
+Specifies the context for the icon\&. Icons to be used in the application menu and as desktop icon should use
+\fIapps\fR
+as context which is the default context\&. Icons to be used as file icons should use
+\fImimetypes\fR
+as context\&. Other common contexts are
+\fIactions\fR,
+\fIdevices\fR,
+\fIemblems\fR,
+\fIfilesystems\fR
+and
+\fIstock\fR\&.
+.RE
+.PP
+\fB\-\-size\fR \fIsize\fR
+.RS 4
+Specifies the size of the icon\&. All icons must be square\&. Common sizes for icons in the apps context are: 16, 22, 32, 48, 64 and 128\&. Common sizes for icons in the mimetypes context are: 16, 22, 32, 48, 64 and 128
+.RE
+.PP
+\fB\-\-mode\fR \fImode\fR
+.RS 4
+\fImode\fR
+can be
+\fIuser\fR
+or
+\fIsystem\fR\&. In user mode the file is (un)installed for the current user only\&. In system mode the file is (un)installed for all users on the system\&. Usually only root is allowed to install in system mode\&.
+.sp
+The default is to use system mode when called by root and to use user mode when called by a non\-root user\&.
+.RE
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "ENVIRONMENT VARIABLES"
+.PP
+xdg\-icon\-resource honours the following environment variables:
+.PP
+XDG_UTILS_DEBUG_LEVEL
+.RS 4
+Setting this environment variable to a non\-zero numerical value makes xdg\-icon\-resource do more verbose reporting on stderr\&. Setting a higher value increases the verbosity\&.
+.RE
+.PP
+XDG_UTILS_INSTALL_MODE
+.RS 4
+This environment variable can be used by the user or administrator to override the installation mode\&. Valid values are
+\fIuser\fR
+and
+\fIsystem\fR\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.PP
+\fB5\fR
+.RS 4
+No permission to read one of the files passed on the command line\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fBxdg-desktop-icon\fR(1),
+\fBxdg-desktop-menu\fR(1),
+\fBxdg-mime\fR(1)
+.SH "EXAMPLES"
+.PP
+To install an icon resource to depict a launcher for the application myfoobar, the company ShinyThings Inc\&. can use:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-icon\-resource install \-\-size 64 shinythings\-myfoobar\&.png
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+To install an icon for a new application/x\-foobar file type one can use:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-icon\-resource install \-\-context mimetypes \-\-size 48 \&./mime\-foobar\-48\&.png application\-x\-foobar
+xdg\-icon\-resource install \-\-context mimetypes \-\-size 64 \&./mime\-foobar\-64\&.png application\-x\-foobar
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This will install two icons with the name application\-x\-foobar but with different sizes\&.
+.SH "AUTHORS"
+.PP
+\fBKevin Krammer\fR
+.RS 4
+Author.
+.RE
+.PP
+\fBJeremy White\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-mime.1 b/scripts/man/xdg-mime.1
new file mode 100644
index 0000000..50811e4
--- /dev/null
+++ b/scripts/man/xdg-mime.1
@@ -0,0 +1,286 @@
+'\" t
+.\" Title: xdg-mime
+.\" Author: Kevin Krammer
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-mime Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-MIME" "1" "12/31/2010" "xdg-utils 1.0" "xdg-mime Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-mime \- command line tool for querying information about file type handling and adding descriptions for new file types
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-mime\fR\ 'u
+\fBxdg\-mime\fR query {filetype | default} \&.\&.\&.
+.HP \w'\fBxdg\-mime\fR\ 'u
+\fBxdg\-mime\fR default \fIapplication\fR \fImimetype(s)\fR
+.HP \w'\fBxdg\-mime\fR\ 'u
+\fBxdg\-mime\fR install [\fB\-\-mode\ \fR\fB\fImode\fR\fR] [\fB\-\-novendor\fR] \fImimetypes\-file\fR
+.HP \w'\fBxdg\-mime\fR\ 'u
+\fBxdg\-mime\fR uninstall [\fB\-\-mode\ \fR\fB\fImode\fR\fR] \fImimetypes\-file\fR
+.HP \w'\fBxdg\-mime\fR\ 'u
+\fBxdg\-mime\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+The xdg\-mime program can be used to query information about file types and to add descriptions for new file types\&.
+.SH "COMMANDS"
+.PP
+query
+.RS 4
+Returns information related to file types\&.
+.sp
+The
+\fIquery\fR
+option is for use inside a desktop session only\&. It is not recommended to use xdg\-mime query as root\&.
+.sp
+The following queries are supported:
+.sp
+query filetype
+\fIFILE\fR: Returns the file type of
+\fIFILE\fR
+in the form of a MIME type\&.
+.sp
+query default
+\fImimetype\fR: Returns the default application that the desktop environment uses for opening files of type
+\fImimetype\fR\&. The default application is identified by its *\&.desktop file\&.
+.RE
+.PP
+default
+.RS 4
+Ask the desktop environment to make
+\fIapplication\fR
+the default application for opening files of type
+\fImimetype\fR\&. An application can be made the default for several file types by specifying multiple mimetypes\&.
+.sp
+
+\fIapplication\fR
+is the desktop file id of the application and has the form vendor\-name\&.desktop
+\fIapplication\fR
+must already be installed in the desktop menu before it can be made the default handler\&. The aplication\*(Aqs desktop file must list support for all the MIME types that it wishes to be the default handler for\&.
+.sp
+Requests to make an application a default handler may be subject to system policy or approval by the end\-user\&. xdg\-mime query can be used to verify whether an application is the actual default handler for a specific file type\&.
+.sp
+The
+\fIdefault\fR
+option is for use inside a desktop session only\&. It is not recommended to use xdg\-mime default as root\&.
+.RE
+.PP
+install
+.RS 4
+Adds the file type descriptions provided in
+\fImimetypes\-file\fR
+to the desktop environment\&.
+\fImimetypes\-file\fR
+must be a XML file that follows the freedesktop\&.org Shared MIME\-info Database specification and that has a mime\-info element as its document root\&. For each new file type one or more icons with name
+\fItype\fR\-\fIsubtype\fR
+must be installed with the
+\fBxdg\-icon\-resource\fR
+command in the
+\fImimetypes\fR
+context\&. For example the filetype application/vnd\&.oasis\&.opendocument\&.text requires an icon named application\-vnd\&.oasis\&.opendocument\&.text to be installed (unless the file type recommends another icon name)\&.
+.RE
+.PP
+uninstall
+.RS 4
+Removes the file type descriptions provided in
+\fImimetypes\-file\fR
+and previously added with
+\fBxdg\-mime install\fR
+from the desktop environment\&.
+\fImimetypes\-file\fR
+must be a XML file that follows the freedesktop\&.org Shared MIME\-info Database specification and that has a mime\-info element as its document root\&.
+.RE
+.SH "OPTIONS"
+.PP
+\fB\-\-mode\fR \fImode\fR
+.RS 4
+\fImode\fR
+can be
+\fIuser\fR
+or
+\fIsystem\fR\&. In user mode the file is (un)installed for the current user only\&. In system mode the file is (un)installed for all users on the system\&. Usually only root is allowed to install in system mode\&.
+.sp
+The default is to use system mode when called by root and to use user mode when called by a non\-root user\&.
+.RE
+.PP
+\fB\-\-novendor\fR
+.RS 4
+Normally, xdg\-mime checks to ensure that the
+\fImimetypes\-file\fR
+to be installed has a proper vendor prefix\&. This option can be used to disable that check\&.
+.sp
+A vendor prefix consists of alpha characters ([a\-zA\-Z]) and is terminated with a dash ("\-")\&. Companies and organizations are encouraged to use a word or phrase, preferably the organizations name, for which they hold a trademark as their vendor prefix\&. The purpose of the vendor prefix is to prevent name conflicts\&.
+.RE
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "ENVIRONMENT VARIABLES"
+.PP
+xdg\-mime honours the following environment variables:
+.PP
+XDG_UTILS_DEBUG_LEVEL
+.RS 4
+Setting this environment variable to a non\-zero numerical value makes xdg\-mime do more verbose reporting on stderr\&. Setting a higher value increases the verbosity\&.
+.RE
+.PP
+XDG_UTILS_INSTALL_MODE
+.RS 4
+This environment variable can be used by the user or administrator to override the installation mode\&. Valid values are
+\fIuser\fR
+and
+\fIsystem\fR\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.PP
+\fB5\fR
+.RS 4
+No permission to read one of the files passed on the command line\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fBxdg-icon-resource\fR(1),
+\fBxdg-desktop-menu\fR(1)
+.SH "EXAMPLES"
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-mime query filetype /tmp/foobar\&.png
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Prints the MIME type of the file /tmp/foobar\&.png, in this case image/png
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-mime query default image/png
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Prints the \&.desktop filename of the application which is registered to open PNG files\&.
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-mime install shinythings\-shiny\&.xml
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Adds a file type description for "shiny"\-files\&. "shinythings\-" is used as the vendor prefix\&. The file type description could look as folows\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+shinythings\-shiny\&.xml:
+
+<?xml version="1\&.0"?>
+<mime\-info xmlns=\*(Aqhttp://www\&.freedesktop\&.org/standards/shared\-mime\-info\*(Aq>
+ <mime\-type type="text/x\-shiny">
+ <comment>Shiny new file type</comment>
+ <glob pattern="*\&.shiny"/>
+ <glob pattern="*\&.shi"/>
+ </mime\-type>
+</mime\-info>
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An icon for this new file type must also be installed, for example with:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-icon\-resource install \-\-context mimetypes \-\-size 64 shiny\-file\-icon\&.png text\-x\-shiny
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "AUTHORS"
+.PP
+\fBKevin Krammer\fR
+.RS 4
+Author.
+.RE
+.PP
+\fBJeremy White\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-open.1 b/scripts/man/xdg-open.1
new file mode 100644
index 0000000..984c58c
--- /dev/null
+++ b/scripts/man/xdg-open.1
@@ -0,0 +1,124 @@
+'\" t
+.\" Title: xdg-open
+.\" Author: Kevin Krammer
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-open Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-OPEN" "1" "12/31/2010" "xdg-utils 1.0" "xdg-open Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-open \- opens a file or URL in the user\*(Aqs preferred application
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-open\fR\ 'u
+\fBxdg\-open\fR {\fB\fIfile\fR\fR | \fB\fIURL\fR\fR}
+.HP \w'\fBxdg\-open\fR\ 'u
+\fBxdg\-open\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+xdg\-open opens a file or URL in the user\*(Aqs preferred application\&. If a URL is provided the URL will be opened in the user\*(Aqs preferred web browser\&. If a file is provided the file will be opened in the preferred application for files of that type\&. xdg\-open supports file, ftp, http and https URLs\&.
+.PP
+xdg\-open is for use inside a desktop session only\&. It is not recommended to use xdg\-open as root\&.
+.SH "OPTIONS"
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.SH "EXAMPLES"
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-open \*(Aqhttp://www\&.freedesktop\&.org/\*(Aq
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Opens the Freedesktop\&.org website in the user\*(Aqs default browser
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-open /tmp/foobar\&.png
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Opens the PNG image file /tmp/foobar\&.png in the user\*(Aqs default image viewing application\&.
+.SH "AUTHORS"
+.PP
+\fBKevin Krammer\fR
+.RS 4
+Author.
+.RE
+.PP
+\fBJeremy White\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-screensaver.1 b/scripts/man/xdg-screensaver.1
new file mode 100644
index 0000000..dc68409
--- /dev/null
+++ b/scripts/man/xdg-screensaver.1
@@ -0,0 +1,154 @@
+'\" t
+.\" Title: xdg-screensaver
+.\" Author: Bryce Harrington
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 12/31/2010
+.\" Manual: xdg-screensaver Manual
+.\" Source: xdg-utils 1.0
+.\" Language: English
+.\"
+.TH "XDG\-SCREENSAVER" "1" "12/31/2010" "xdg-utils 1.0" "xdg-screensaver Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-screensaver \- command line tool for controlling the screensaver
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-screensaver\fR\ 'u
+\fBxdg\-screensaver\fR \fBsuspend\ \fR\fB\fIWindowID\fR\fR
+.HP \w'\fBxdg\-screensaver\fR\ 'u
+\fBxdg\-screensaver\fR \fBresume\ \fR\fB\fIWindowID\fR\fR
+.HP \w'\fBxdg\-screensaver\fR\ 'u
+\fBxdg\-screensaver\fR {\fBactivate\fR | \fBlock\fR | \fBreset\fR | \fBstatus\fR}
+.HP \w'\fBxdg\-screensaver\fR\ 'u
+\fBxdg\-screensaver\fR {\fB\-\-help\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+xdg\-screensaver provides commands to control the screensaver\&.
+.PP
+xdg\-screensaver is for use inside a desktop session only\&. It is not recommended to use xdg\-screensaver as root\&.
+.SH "COMMANDS"
+.PP
+\fBsuspend \fR\fB\fIWindowID\fR\fR
+.RS 4
+Suspends the screensaver and monitor power management\&.
+\fIWindowID\fR
+must be the X Window ID of an existing window of the calling application\&. The window must remain in existance for the duration of the suspension\&.
+.sp
+WindowID can be represented as either a decimal number or as a hexadecimal number consisting of the prefix
+\fI0x\fR
+followed by one or more hexadecimal digits\&.
+.sp
+The screensaver can be suspended in relation to multiple windows at the same time\&. In that case screensaver operation is only restored once the screensaver has been resumed in relation to each of the windows
+.RE
+.PP
+\fBresume \fR\fB\fIWindowID\fR\fR
+.RS 4
+Resume the screensaver and monitor power management after being suspended\&.
+\fIWindowID\fR
+must be the same X Window ID that was passed to a previous call of
+\fBxdg\-screensaver suspend\fR
+.RE
+.PP
+\fBactivate\fR
+.RS 4
+Turns the screensaver on immediately\&. This may result in the screen getting locked, depending on existing system policies\&.
+.RE
+.PP
+\fBlock\fR
+.RS 4
+Lock the screen immediately\&.
+.RE
+.PP
+\fBreset\fR
+.RS 4
+Turns the screensaver off immediately\&. If the screen was locked the user may be asked to authenticate first\&.
+.RE
+.PP
+\fBstatus\fR
+.RS 4
+Prints
+\fIenabled\fR
+to stdout if the screensaver is enabled to turn on after a period of inactivity and prints
+\fIdisabled\fR
+if the screensaver is not enabled\&.
+.RE
+.SH "OPTIONS"
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.SH "EXAMPLES"
+.PP
+
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+xdg\-screensaver suspend 0x1c00007
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Causes the screensaver to be disabled till
+\fBxdg\-screensaver resume 0x1c00007\fR
+is called\&.
+\fI0x1c00007\fR
+must be the X Window ID of an existing window\&.
+.SH "AUTHOR"
+.PP
+\fBBryce Harrington\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2006
+.br
diff --git a/scripts/man/xdg-settings.1 b/scripts/man/xdg-settings.1
new file mode 100644
index 0000000..d02fa2b
--- /dev/null
+++ b/scripts/man/xdg-settings.1
@@ -0,0 +1,154 @@
+'\" t
+.\" Title: xdg-settings
+.\" Author: Mike Mammarella
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\" Date: 07/20/2011
+.\" Manual: xdg-settings Manual
+.\" Source: [FIXME: source]
+.\" Language: English
+.\"
+.TH "XDG\-SETTINGS" "1" "07/20/2011" "[FIXME: source]" "xdg-settings Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+xdg-settings \- get various settings from the desktop environment
+.SH "SYNOPSIS"
+.HP \w'\fBxdg\-settings\fR\ 'u
+\fBxdg\-settings\fR {\fB\fIget\fR\fR | \fB\fIcheck\fR\fR | \fB\fIset\fR\fR} {\fBproperty\fR} [\fBsubproperty\fR] [\fBvalue\fR]
+.HP \w'\fBxdg\-settings\fR\ 'u
+\fBxdg\-settings\fR {\fB\-\-help\fR | \fB\-\-list\fR | \fB\-\-manual\fR | \fB\-\-version\fR}
+.SH "DESCRIPTION"
+.PP
+xdg\-settings gets various settings from the desktop environment\&. For instance, desktop environments often provide proxy configuration and default web browser settings\&. Using xdg\-settings these parameters can be extracted for use by applications that do not use the desktop environment\*(Aqs libraries (which would use the settings natively)\&.
+.PP
+xdg\-settings is for use inside a desktop session only\&. It is not recommended to use xdg\-settings as root\&.
+.SH "OPTIONS"
+.PP
+\fB\-\-help\fR
+.RS 4
+Show command synopsis\&.
+.RE
+.PP
+\fB\-\-list\fR
+.RS 4
+List all properties xdg\-settings knows about\&.
+.RE
+.PP
+\fB\-\-manual\fR
+.RS 4
+Show this manualpage\&.
+.RE
+.PP
+\fB\-\-version\fR
+.RS 4
+Show the xdg\-utils version information\&.
+.RE
+.SH "PROPERTIES"
+.PP
+When using xdg\-settings to get, check or set a destkop setting, properties and possibly sub\-properties are used to specify the setting to be changed\&.
+.PP
+Some properties (such as default\-web\-browser) fully describe the setting to be changed\&. Other properties (such as default\-url\-scheme\-handler) require more information (in this case the actual scheme to set the default handler for) which must be provided in a sub\-property\&.
+.SH "EXIT CODES"
+.PP
+An exit code of 0 indicates success while a non\-zero exit code indicates failure\&. The following failure codes can be returned:
+.PP
+\fB1\fR
+.RS 4
+Error in command line syntax\&.
+.RE
+.PP
+\fB2\fR
+.RS 4
+One of the files passed on the command line did not exist\&.
+.RE
+.PP
+\fB3\fR
+.RS 4
+A required tool could not be found\&.
+.RE
+.PP
+\fB4\fR
+.RS 4
+The action failed\&.
+.RE
+.SH "EXAMPLES"
+.PP
+Get the desktop file name of the current default web browser
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ xdg\-settings get default\-web\-browser
+
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Check whether the default web browser is firefox\&.desktop, which can be false even if "get default\-web\-browser" says that is the current value (if only some of the underlying settings actually reflect that value)
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ xdg\-settings check default\-web\-browser firefox\&.desktop
+
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Set the default web browser to google\-chrome\&.desktop
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ xdg\-settings set default\-web\-browser google\-chrome\&.desktop
+
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+Set the default mailto URL scheme handler to be evolution\&.desktop
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ xdg\-settings set default\-url\-scheme\-handler mailto evolution\&.desktop
+
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+.SH "AUTHOR"
+.PP
+\fBMike Mammarella\fR
+.RS 4
+Author.
+.RE
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2009-2011
+.br
diff --git a/scripts/xdg-copy b/scripts/xdg-copy
new file mode 100755
index 0000000..10b8717
--- /dev/null
+++ b/scripts/xdg-copy
@@ -0,0 +1,303 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-copy
+#
+# Utility script to copy files specified by URLs, including
+# downloading and uploading from/to remote sites.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+ xdg-copy -- command line tool for copying files between desktop URIs
+
+Synopsis
+
+ xdg-copy source destination
+
+ xdg-copy { --help | --manual | --version }
+
+Description
+
+ xdg-copy copies source to destination and provides visual feedback to the
+ user during the operation. Both source and destination can either be a
+ file or URL. Supported URL types are file, ftp, http and https. Additional
+ URL types may be supported depending on the desktop environment.
+
+ xdg-copy is for use inside a desktop session only. It is not recommended
+ to use xdg-copy as root.
+
+Options
+
+ --help
+ Show command synopsis.
+
+ --manual
+ Show this manualpage.
+
+ --version
+ Show the xdg-utils version information.
+
+Exit Codes
+
+ An exit code of 0 indicates success while a non-zero exit code indicates
+ failure. The following failure codes can be returned:
+
+ 1
+ Error in command line syntax.
+
+ 2
+ One of the files passed on the command line did not exist.
+
+ 3
+ A required tool could not be found.
+
+ 4
+ The action failed.
+
+Examples
+
+ xdg-copy "http://portland.freedesktop.org/png/freedesktop-logo.png" .
+
+ xdg-copy "/tmp/foobar.png" "/home/user/foobar-copy.png"
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+ xdg-copy -- command line tool for copying files between desktop URIs
+
+Synopsis
+
+ xdg-copy source destination
+
+ xdg-copy { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-copy: $@" >&2
+ echo "Try 'xdg-copy --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-copy' or 'xdg-copy --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-copy: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-copy: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-copy: $@" >&2
+ fi
+
+ exit 4
+}
+
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ --help)
+ usage
+ echo "Use 'man xdg-copy' or 'xdg-copy --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-copy 1.0beta1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ fi
+}
+
+#----------------------------------------------------------------------------
+
+
+
+copy_kde()
+{
+ kfmclient copy "$1" "$2"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+copy_gnome()
+{
+ if gvfs-copy --help 2>/dev/null 1>&2; then
+ gvfs-copy "$1" "$2"
+ else
+ gnomevfs-copy "$1" "$2"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+source=
+dest=
+while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$dest" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ if [ -n "$source" ] ; then
+ dest=$parm
+ else
+ source=$parm
+ fi
+ ;;
+ esac
+done
+
+if [ -z "${source}" ] ; then
+ exit_failure_syntax "source argument missing"
+fi
+if [ -z "${dest}" ] ; then
+ exit_failure_syntax "destination argument missing"
+fi
+
+detectDE
+
+case "$DE" in
+ kde)
+ copy_kde "$source" "$dest"
+ ;;
+
+ gnome)
+ copy_gnome "$source" "$dest"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for copying '$source' to '$dest'"
+ ;;
+esac
diff --git a/scripts/xdg-copy.in b/scripts/xdg-copy.in
new file mode 100644
index 0000000..6838cd6
--- /dev/null
+++ b/scripts/xdg-copy.in
@@ -0,0 +1,106 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-copy
+#
+# Utility script to copy files specified by URLs, including
+# downloading and uploading from/to remote sites.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+copy_kde()
+{
+ kfmclient copy "$1" "$2"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+copy_gnome()
+{
+ if gvfs-copy --help 2>/dev/null 1>&2; then
+ gvfs-copy "$1" "$2"
+ else
+ gnomevfs-copy "$1" "$2"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+source=
+dest=
+while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$dest" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ if [ -n "$source" ] ; then
+ dest=$parm
+ else
+ source=$parm
+ fi
+ ;;
+ esac
+done
+
+if [ -z "${source}" ] ; then
+ exit_failure_syntax "source argument missing"
+fi
+if [ -z "${dest}" ] ; then
+ exit_failure_syntax "destination argument missing"
+fi
+
+detectDE
+
+case "$DE" in
+ kde)
+ copy_kde "$source" "$dest"
+ ;;
+
+ gnome*)
+ copy_gnome "$source" "$dest"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for copying '$source' to '$dest'"
+ ;;
+esac
diff --git a/scripts/xdg-desktop-icon b/scripts/xdg-desktop-icon
new file mode 100755
index 0000000..219b702
--- /dev/null
+++ b/scripts/xdg-desktop-icon
@@ -0,0 +1,562 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-desktop-icon
+#
+# Utility script to install desktop items on a Linux desktop.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+usage()
+{
+cat << _USAGE
+xdg-desktop-icon - command line tool for (un)installing icons to the desktop
+
+Synopsis
+
+xdg-desktop-icon install [--novendor] FILE
+
+xdg-desktop-icon uninstall FILE
+
+xdg-desktop-icon { --help | --manual | --version }
+
+_USAGE
+}
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-desktop-icon - command line tool for (un)installing icons to the desktop
+
+Synopsis
+
+xdg-desktop-icon install [--novendor] FILE
+
+xdg-desktop-icon uninstall FILE
+
+xdg-desktop-icon { --help | --manual | --version }
+
+Description
+
+The xdg-desktop-icon program can be used to install an application launcher or
+other file on the desktop of the current user.
+
+An application launcher is represented by a *.desktop file. Desktop files are
+defined by the freedesktop.org Desktop Entry Specification. The most important
+aspects of *.desktop files are summarized below.
+
+Commands
+
+install
+ Installs FILE to the desktop of the current user. FILE can be a *.desktop
+ file or any other type of file.
+uninstall
+ Removes FILE from the desktop of the current user.
+
+Options
+
+--novendor
+
+ Normally, xdg-desktop-icon checks to ensure that a *.desktop file to be
+ installed has a vendor prefix. This option can be used to disable that
+ check.
+
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
+ with a dash ("-"). Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold a
+ trademark as their vendor prefix. The purpose of the vendor prefix is to
+ prevent name conflicts.
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Desktop Files
+
+An application launcher can be added to the desktop by installing a *.desktop
+file. A *.desktop file consists of a [Desktop Entry] header followed by several
+Key=Value lines.
+
+A *.desktop file can provide a name and description for an application in
+several different languages. This is done by adding a language code as used by
+LC_MESSAGES in square brackets behind the Key. This way one can specify
+different values for the same Key depending on the currently selected language.
+
+The following keys are often used:
+
+Value=1.0
+ This is a mandatory field to indicate that the *.desktop file follows the
+ 1.0 version of the specification.
+Type=Application
+ This is a mandatory field that indicates that the *.desktop file describes
+ an application launcher.
+Name=Application Name
+ The name of the application. For example Mozilla
+GenericName=Generic Name
+ A generic description of the application. For example Web Browser
+Comment=Comment
+ Optional field to specify a tooltip for the application. For example Visit
+ websites on the Internet
+Icon=Icon File
+ The icon to use for the application. This can either be an absolute path to
+ an image file or an icon-name. If an icon-name is provided an image lookup
+ by name is done in the user's current icon theme. The xdg-icon-resource
+ command can be used to install image files into icon themes. The advantage
+ of using an icon-name instead of an absolute path is that with an icon-name
+ the application icon can be provided in several different sizes as well as
+ in several differently themed styles.
+Exec=Command Line
+ The command line to start the application. If the application can open
+ files the %f placeholder should be specified. When a file is dropped on the
+ application launcher the %f is replaced with the file path of the dropped
+ file. If multiple files can be specified on the command line the %F
+ placeholder should be used instead of %f. If the application is able to
+ open URLs in addition to local files then %u or %U can be used instead of
+ %f or %F.
+
+For a complete oveview of the *.desktop file format please visit http://
+www.freedesktop.org/wiki/Standards/desktop-entry-spec
+
+Environment Variables
+
+xdg-desktop-icon honours the following environment variables:
+
+XDG_UTILS_DEBUG_LEVEL
+ Setting this environment variable to a non-zero numerical value makes
+ xdg-desktop-icon do more verbose reporting on stderr. Setting a higher
+ value increases the verbosity.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+5
+ No permission to read one of the files passed on the command line.
+
+See Also
+
+xdg-icon-resource(1)
+
+Examples
+
+The company ShinyThings Inc. has developed an application named "WebMirror" and
+would like to add a launcher for for on the desktop. The company will use
+"shinythings" as its vendor id. In order to add the application to the desktop
+there needs to be a .desktop file for the application:
+
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+Now the xdg-desktop-icon tool can be used to add the webmirror.desktop file to
+the desktop:
+
+xdg-desktop-icon install ./shinythings-webmirror.desktop
+
+To add a README file to the desktop as well, the following command can be used:
+
+xdg-desktop-icon install ./shinythings-README
+
+_MANUALPAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-icon: $@" >&2
+ echo "Try 'xdg-desktop-icon --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-icon: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-icon: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-icon: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-icon: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-icon: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-desktop-icon: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-desktop-icon --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-desktop-icon' or 'xdg-desktop-icon --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-desktop-icon 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+action=
+desktop_file=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$desktop_file" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ if [ "$action" = "install" ] ; then
+ check_input_file "$parm"
+ fi
+ desktop_file=$parm
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+if [ -z "$desktop_file" ] ; then
+ exit_failure_syntax "FILE argument missing"
+fi
+
+filetype=
+case "$desktop_file" in
+ *.desktop)
+ filetype=desktop
+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$desktop_file"
+ fi
+ ;;
+ *)
+ filetype=other
+ ;;
+esac
+
+my_umask=077
+desktop_dir="$HOME/Desktop"
+if xdg-user-dir 2>/dev/null 1>&2; then
+ desktop_dir=`xdg-user-dir DESKTOP`
+fi
+desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/null`
+if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then
+ desktop_dir_gnome="$HOME"
+ # Don't create $HOME/Desktop if it doesn't exist
+ [ -w "$desktop_dir" ] || desktop_dir=
+fi
+if [ -n "$desktop_dir_kde" ]; then
+ if [ ! -d "$desktop_dir_kde" ]; then
+ save_umask=`umask`
+ umask $my_umask
+ mkdir -p "$desktop_dir_kde"
+ umask $save_umask
+ fi
+ # Is the KDE desktop dir != $HOME/Desktop ?
+ if [ x`readlink -f "$desktop_dir"` != x`readlink -f "$desktop_dir_kde"` ]; then
+ # If so, don't create $HOME/Desktop if it doesn't exist
+ [ -w "$desktop_dir" ] || desktop_dir=
+ else
+ desktop_dir_kde=
+ fi
+fi
+
+basefile=`basename "$desktop_file"`
+
+DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gnome"
+
+case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
+ if [ -n "$x" ]; then
+ mkdir -p "$x"
+ eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output
+ chmod u+x "$x/$basefile"
+ fi
+ done
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
+ if [ -n "$x" ]; then
+ rm -f "$x/$basefile"
+ fi
+ done
+
+ ;;
+esac
+
+exit_success
+
+
diff --git a/scripts/xdg-desktop-icon.in b/scripts/xdg-desktop-icon.in
new file mode 100644
index 0000000..c755174
--- /dev/null
+++ b/scripts/xdg-desktop-icon.in
@@ -0,0 +1,160 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-desktop-icon
+#
+# Utility script to install desktop items on a Linux desktop.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+#@xdg-utils-common@
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+action=
+desktop_file=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$desktop_file" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ if [ "$action" = "install" ] ; then
+ check_input_file "$parm"
+ fi
+ desktop_file=$parm
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+if [ -z "$desktop_file" ] ; then
+ exit_failure_syntax "FILE argument missing"
+fi
+
+filetype=
+case "$desktop_file" in
+ *.desktop)
+ filetype=desktop
+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$desktop_file"
+ fi
+ ;;
+ *)
+ filetype=other
+ ;;
+esac
+
+my_umask=077
+desktop_dir="$HOME/Desktop"
+if xdg-user-dir 2>/dev/null 1>&2; then
+ desktop_dir=`xdg-user-dir DESKTOP`
+fi
+desktop_dir_kde=`kde${KDE_SESSION_VERSION}-config --userpath desktop 2> /dev/null`
+if gconftool-2 -g /apps/nautilus/preferences/desktop_is_home_dir 2> /dev/null | grep true > /dev/null; then
+ desktop_dir_gnome="$HOME"
+ # Don't create $HOME/Desktop if it doesn't exist
+ [ -w "$desktop_dir" ] || desktop_dir=
+fi
+if [ -n "$desktop_dir_kde" ]; then
+ if [ ! -d "$desktop_dir_kde" ]; then
+ save_umask=`umask`
+ umask $my_umask
+ mkdir -p "$desktop_dir_kde"
+ umask $save_umask
+ fi
+ # Is the KDE desktop dir != $HOME/Desktop ?
+ if [ "x`readlink -f "$desktop_dir"`" != "x`readlink -f "$desktop_dir_kde"`" ]; then
+ # If so, don't create $HOME/Desktop if it doesn't exist
+ [ -w "$desktop_dir" ] || desktop_dir=
+ else
+ desktop_dir_kde=
+ fi
+fi
+
+basefile=`basename "$desktop_file"`
+
+DEBUG 1 "$action $desktop_file in $desktop_dir $desktop_dir_kde $desktop_dir_gnome"
+
+case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
+ if [ -n "$x" ]; then
+ mkdir -p "$x"
+ eval 'cp "$desktop_file" "$x/$basefile"'$xdg_redirect_output
+ chmod u+x "$x/$basefile"
+ fi
+ done
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in "$desktop_dir" "$desktop_dir_kde" "$desktop_dir_gnome" ; do
+ if [ -n "$x" ]; then
+ rm -f "$x/$basefile"
+ fi
+ done
+
+ ;;
+esac
+
+exit_success
+
+
diff --git a/scripts/xdg-desktop-menu b/scripts/xdg-desktop-menu
new file mode 100755
index 0000000..dfa90b6
--- /dev/null
+++ b/scripts/xdg-desktop-menu
@@ -0,0 +1,1227 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-desktop-menu
+#
+# Utility script to install menu items on a Linux desktop.
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-desktop-menu - command line tool for (un)installing desktop menu items
+
+Synopsis
+
+xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file
+(s) desktop-file(s)
+
+xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s)
+desktop-file(s)
+
+xdg-desktop-menu forceupdate [--mode mode]
+
+xdg-desktop-menu { --help | --manual | --version }
+
+Description
+
+The xdg-desktop-menu program can be used to install new menu entries to the
+desktop's application menu.
+
+The application menu works according to the XDG Desktop Menu Specification at
+http://www.freedesktop.org/Standards/menu-spec
+
+Commands
+
+install
+
+ Install one or more applications in a submenu of the desktop menu system.
+
+ desktop-file: A desktop file represents a single menu entry in the menu.
+ Desktop files are defined by the freedesktop.org Desktop Entry
+ Specification. The most important aspects of *.desktop files are summarized
+ below.
+
+ Menu entries can be added to the menu system in two different ways. They
+ can either be added to a predefined submenu in the menu system based on one
+ or more category keywords, or they can be added to a new submenu.
+
+ To add a menu entry to a predefined submenu the desktop file that
+ represents the menu entry must have a Categories= entry that lists one or
+ more keywords. The menu item will be included in an appropriate submenu
+ based on the included keywords.
+
+ To add menu items to a new submenu the desktop-files must be preceded by a
+ directory-file that describes the submenu. If multiple desktop-files are
+ specified, all entries will be added to the same menu. If entries are
+ installed to a menu that has been created with a previous call to
+ xdg-desktop-menu the entries will be installed in addition to any already
+ existing entries.
+
+ directory-file: The *.directory file indicated by directory-file represents
+ a submenu. The directory file provides the name and icon for a submenu. The
+ name of the directory file is used to identify the submenu.
+
+ If multiple directory files are provided each file will represent a submenu
+ within the menu that preceeds it, creating a nested menu hierarchy
+ (sub-sub-menus). The menu entries themselves will be added to the last
+ submenu.
+
+ Directory files follow the syntax defined by the freedesktop.org Desktop
+ Entry Specification.
+
+uninstall
+
+ Remove applications or submenus from the desktop menu system previously
+ installed with xdg-desktop-menu install.
+
+ A submenu and the associated directory file is only removed when the
+ submenu no longer contains any menu entries.
+
+forceupdate
+
+ Force an update of the menu system.
+
+ This command is only useful if the last call to xdg-desktop-menu included
+ the --noupdate option.
+
+Options
+
+--noupdate
+ Postpone updating the menu system. If multiple updates to the menu system
+ are made in sequence this flag can be used to indicate that additional
+ changes will follow and that it is not necassery to update the menu system
+ right away.
+--novendor
+
+ Normally, xdg-desktop-menu checks to ensure that any *.directory and
+ *.desktop files to be installed has a vendor prefix. This option can be
+ used to disable that check.
+
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
+ with a dash ("-"). Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold a
+ trademark as their vendor prefix. The purpose of the vendor prefix is to
+ prevent name conflicts.
+
+--mode mode
+
+ mode can be user or system. In user mode the file is (un)installed for the
+ current user only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in system mode.
+
+ The default is to use system mode when called by root and to use user mode
+ when called by a non-root user.
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Desktop Files
+
+An application item in the application menu is represented by a *.desktop file.
+A *.desktop file consists of a [Desktop Entry] header followed by several Key=
+Value lines.
+
+A *.desktop file can provide a name and description for an application in
+several different languages. This is done by adding a language code as used by
+LC_MESSAGES in square brackets behind the Key. This way one can specify
+different values for the same Key depending on the currently selected language.
+
+The following keys are often used:
+
+Value=1.0
+ This is a mandatory field to indicate that the *.desktop file follows the
+ 1.0 version of the specification.
+Type=Application
+ This is a mandatory field that indicates that the *.desktop file describes
+ an application launcher.
+Name=Application Name
+ The name of the application. For example Mozilla
+GenericName=Generic Name
+ A generic description of the application. For example Web Browser
+Comment=Comment
+ Optional field to specify a tooltip for the application. For example Visit
+ websites on the Internet
+Icon=Icon File
+ The icon to use for the application. This can either be an absolute path to
+ an image file or an icon-name. If an icon-name is provided an image lookup
+ by name is done in the user's current icon theme. The xdg-icon-resource
+ command can be used to install image files into icon themes. The advantage
+ of using an icon-name instead of an absolute path is that with an icon-name
+ the application icon can be provided in several different sizes as well as
+ in several differently themed styles.
+Exec=Command Line
+ The command line to start the application. If the application can open
+ files the %f placeholder should be specified. When a file is dropped on the
+ application launcher the %f is replaced with the file path of the dropped
+ file. If multiple files can be specified on the command line the %F
+ placeholder should be used instead of %f. If the application is able to
+ open URLs in addition to local files then %u or %U can be used instead of
+ %f or %F.
+Categories=Categories
+
+ A list of categories separated by semi-colons. A category is a keyword that
+ describes and classifies the application. By default applications are
+ organized in the application menu based on category. When menu entries are
+ explicitly assigned to a new submenu it is not necassery to list any
+ categories.
+
+ When using categories it is recommended to include one of the following
+ categories: AudioVideo, Development, Education, Game, Graphics, Network,
+ Office, Settings, System, Utility.
+
+ See Appendix A of the XDG Desktop Menu Specification for information about
+ additional categories. http://standards.freedesktop.org/menu-spec/
+ menu-spec-1.0.html
+
+MimeType=Mimetypes
+ A list of mimetypes separated by semi-colons. This field is used to
+ indicate which file types the application is able to open.
+
+For a complete oveview of the *.desktop file format please visit http://
+www.freedesktop.org/wiki/Standards/desktop-entry-spec
+
+Directory Files
+
+The appearance of submenu in the application menu is provided by a *.directory
+file. In particular it provides the title of the submenu and a possible icon. A
+*.directory file consists of a [Desktop Entry] header followed by several Key=
+Value lines.
+
+A *.directory file can provide a title (name) for the submenu in several
+different languages. This is done by adding a language code as used by
+LC_MESSAGES in square brackets behind the Key. This way one can specify
+different values for the same Key depending on the currently selected language.
+
+The following keys are relevqnt for submenus:
+
+Value=1.0
+ This is a mandatory field to indicate that the *.directory file follows the
+ 1.0 version of the Desktop Entry specification.
+Type=Directory
+ This is a mandatory field that indicates that the *.directory file
+ describes a submenu.
+Name=Menu Name
+ The title of submenu. For example Mozilla
+Comment=Comment
+ Optional field to specify a tooltip for the submenu.
+Icon=Icon File
+ The icon to use for the submenu. This can either be an absolute path to an
+ image file or an icon-name. If an icon-name is provided an image lookup by
+ name is done in the user's current icon theme. The xdg-icon-resource
+ command can be used to install image files into icon themes. The advantage
+ of using an icon-name instead of an absolute path is that with an icon-name
+ the submenu icon can be provided in several different sizes as well as in
+ several differently themed styles.
+
+Environment Variables
+
+xdg-desktop-menu honours the following environment variables:
+
+XDG_UTILS_DEBUG_LEVEL
+ Setting this environment variable to a non-zero numerical value makes
+ xdg-desktop-menu do more verbose reporting on stderr. Setting a higher
+ value increases the verbosity.
+XDG_UTILS_INSTALL_MODE
+ This environment variable can be used by the user or administrator to
+ override the installation mode. Valid values are user and system.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+5
+ No permission to read one of the files passed on the command line.
+
+See Also
+
+xdg-desktop-icon(1), xdg-icon-resource(1), xdg-mime(1)
+
+Examples
+
+The company ShinyThings Inc. has developed an application named "WebMirror" and
+would like to add it to the application menu. The company will use
+"shinythings" as its vendor id. In order to add the application to the menu
+there needs to be a .desktop file with a suitable Categories entry:
+
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+ Categories=Network;WebDevelopment;
+
+Now the xdg-desktop-menu tool can be used to add the
+shinythings-webmirror.desktop file to the desktop application menu:
+
+xdg-desktop-menu install ./shinythings-webmirror.desktop
+
+Note that for the purpose of this example the menu items are available in two
+languages, English and Dutch. The language code for Dutch is nl.
+
+In the next example the company ShinyThings Inc. will add its own submenu to
+the desktop application menu consisting of a "WebMirror" menu item and a
+"WebMirror Admin Tool" menu item.
+
+First the company needs to create two .desktop files that describe the two menu
+items. Since the items are to be added to a new submenu it is not necassery to
+include a Categories= line:
+
+shinythings-webmirror.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror
+ Icon=shinythings-webmirror
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+
+shinythings-webmirror-admin.desktop:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+ Type=Application
+
+ Exec=webmirror-admintool
+ Icon=shinythings-webmirror-admintool
+
+ Name=WebMirror Admin Tool
+ Name[nl]=WebSpiegel Administratie Tool
+
+In addition a .directory file needs to be created to provide a title and icon
+for the sub-menu itself:
+
+shinythings-webmirror.directory:
+
+ [Desktop Entry]
+ Encoding=UTF-8
+
+ Icon=shinythings-webmirror-menu
+
+ Name=WebMirror
+ Name[nl]=WebSpiegel
+
+These file can now be installed with:
+
+xdg-desktop-menu install ./shinythings-webmirror.directory \
+ ./shinythings-webmirror.desktop ./shinythings-webmirror-admin.desktop
+
+The menu entries could also be installed one by one:
+
+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
+ ./shinythings-webmirror.desktop
+xdg-desktop-menu install --noupdate ./shinythings-webmirror.directory \
+ ./shinythings-webmirror-admin.desktop
+xdg-desktop-menu forceupdate
+
+Although the result is the same it is slightly more efficient to install all
+files at the same time.
+
+The *.desktop and *.directory files reference icons with the names webmirror,
+webmirror-admin and webmirror-menu which should also be installed. In this
+example the icons are installed in two different sizes, once with a size of
+22x22 pixels and once with a size of 64x64 pixels:
+
+xdg-icon-resource install --size 22 ./wmicon-22.png shinythings-webmirror
+xdg-icon-resource install --size 22 ./wmicon-menu-22.png shinythings-webmirror-menu
+xdg-icon-resource install --size 22 ./wmicon-admin-22.png shinythings-webmirror-admin
+xdg-icon-resource install --size 64 ./wmicon-64.png shinythings-webmirror
+xdg-icon-resource install --size 64 ./wmicon-menu-64.png shinythings-webmirror-menu
+xdg-icon-resource install --size 64 ./wmicon-admin-64.png shinythings-webmirror-admin
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-desktop-menu - command line tool for (un)installing desktop menu items
+
+Synopsis
+
+xdg-desktop-menu install [--noupdate] [--novendor] [--mode mode] directory-file
+(s) desktop-file(s)
+
+xdg-desktop-menu uninstall [--noupdate] [--mode mode] directory-file(s)
+desktop-file(s)
+
+xdg-desktop-menu forceupdate [--mode mode]
+
+xdg-desktop-menu { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-menu: $@" >&2
+ echo "Try 'xdg-desktop-menu --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-menu: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-menu: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-menu: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-menu: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-desktop-menu: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-desktop-menu: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-desktop-menu --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-desktop-menu 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+update_desktop_database()
+{
+# echo Update desktop database: $mode
+ if [ "$mode" = "system" ] ; then
+ for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do
+ if [ -x $x/update-desktop-database ] ; then
+ DEBUG 1 "Running $x/update-desktop-database"
+ eval '$x/update-desktop-database'$xdg_redirect_output
+ return
+ fi
+ done
+ fi
+}
+
+# Make application $1/$2 the default for all the mimetypes it support,
+# iff such mimetype didn't had a default application already.
+# $1 Install dir for desktop file
+# $2 base name of desktop file
+make_lazy_default()
+{
+ local mimetypes
+ local xdg_user_dir
+ local xdg_default_dirs
+
+ DEBUG 1 "make_lazy_default $1/$2"
+ mimetypes=`awk '
+{
+ if (match($0,/MimeType=/)) {
+ split(substr($0,RSTART+9),mimetypes,";")
+ for (n in mimetypes)
+ {
+ if (mimetypes[n])
+ print mimetypes[n]
+ }
+ }
+}' "$1/$2" 2> /dev/null`
+
+ for MIME in $mimetypes ; do
+ xdg_default_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_default_dirs" ] || xdg_default_dirs=/usr/local/share/:/usr/share/
+ if [ x"$mode" = x"user" ] ; then
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+ xdg_default_dirs="$xdg_user_dir:$xdg_default_dirs"
+ fi
+ local default_app
+ for x in `echo "$xdg_default_dirs" | sed 's/:/ /g'`; do
+ DEBUG 2 "Checking $x/applications/defaults.list"
+ default_app=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2`
+ if [ -n "$default_app" ] ; then
+ DEBUG 2 "Found default apps for $MIME: $default_app"
+ default_app="$default_app;"
+ break;
+ fi
+ done
+ DEBUG 2 "Current default apps for $MIME: $default_app"
+ if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then
+ # App already listed as default
+ continue;
+ fi
+ default_file="$1/defaults.list"
+ DEBUG 1 "Updating $default_file"
+ grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null
+ if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then
+ echo "[Default Applications]" >> ${default_file}.new
+ fi
+ echo $MIME="$default_app$2" >> ${default_file}.new
+ mv ${default_file}.new $default_file
+ done
+}
+
+update_submenu()
+{
+ DEBUG 1 "update_submenu $1"
+ menu_file="$1"
+
+ xdg_dir_name=menus
+ xdg_user_dir="$XDG_CONFIG_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.config"
+ xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+ xdg_system_dirs="$XDG_CONFIG_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/etc/xdg
+ xdg_global_dir=
+ for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+ done
+ xdg_user_dir="$xdg_user_dir/applications-merged"
+ xdg_global_dir="$xdg_global_dir/applications-merged"
+
+ DEBUG 3 "Install locations for *.menu file:"
+ DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+ DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+ DEBUG 3 "kde_user_dir: $kde_user_dir"
+ DEBUG 3 "kde_global_dir: $kde_global_dir"
+ DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+ DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+ if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+ my_chmod=0600
+ else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ my_chmod=0644
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system menu directory found."
+ fi
+ fi
+
+ if [ -z "$menu_file" ] ; then
+ # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications
+ save_umask=`umask`
+ umask $my_umask
+
+ mkdir -p $xdg_dir
+ touch $xdg_dir/xdg-desktop-menu-dummy.menu
+
+ umask $save_umask
+ return
+ fi
+
+ if [ $action = "install" -a -f "/etc/xdg/menus/gnome-applications.menu" ] ; then
+ # Work around for Debian Gnome
+ gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'`
+ if [ ! -e "$gnome_xdg_dir" ] ; then
+ DEBUG 1 "Debian Workaround: Link '$xdg_dir' to '$gnome_xdg_dir'"
+ mkdir -p `dirname "$gnome_xdg_dir"`
+ eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output
+ fi
+ fi
+ if [ $action = "install" -a -f "/etc/mandrake-release" ] ; then
+ # Work around for Mandriva 2006
+ mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'`
+ if [ ! -e "$mandrake_xdg_dir" ] ; then
+ DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'"
+ mkdir -p `dirname "$mandrake_xdg_dir"`
+ eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output
+ fi
+ fi
+ if [ $action = "install" -a x"$mode" = x"user" -a -d "/etc/xdg/menus/kde-applications-merged" ] ; then
+ # Work around for Fedora Core 5 + patched KDE
+ kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
+ if [ ! -e "$kde_xdg_dir" ] ; then
+ DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'"
+ mkdir -p `dirname "$kde_xdg_dir"`
+ eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output
+ fi
+ fi
+ if [ $action = "install" -a x"$mode" = x"system" -a -d "/etc/xdg/menus/kde-applications-merged" -a ! -d "/etc/xdg/menus/applications-merged" ] ; then
+ # Work around for Kubuntu 6.06
+ kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
+ DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'"
+ eval 'ln -s "kde-applications-merged" "$xdg_dir"'$xdg_redirect_output
+ fi
+
+ orig_menu_file=$xdg_dir/$menu_file
+
+ DEBUG 1 "Updating $orig_menu_file ($action)"
+
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ orig_desktop_files=
+ if [ -r "$orig_menu_file" ] ; then
+ awk '
+# List all files within <Filename> tags
+BEGIN {
+ RS="<"
+}
+/^Filename/ {
+ if (match($0,/>/)) {
+ print substr($0,RSTART+1)
+ }
+}' $orig_menu_file > $tmpfile
+ fi
+
+ orig_desktop_files=`cat $tmpfile`
+ new_desktop_files=
+ if [ $action = "install" ] ; then
+ for desktop_file in $desktop_files; do
+ basefile=`basename "$desktop_file"`
+ if ! grep '^'$basefile'$' $tmpfile > /dev/null 2> /dev/null ; then
+ # Append
+ echo "$basefile" >> $tmpfile
+ fi
+ done
+ new_desktop_files=`cat $tmpfile`
+ fi
+ if [ $action = "uninstall" ] ; then
+ echo > $tmpfile
+ for desktop_file in $desktop_files; do
+ echo "$desktop_file" >> $tmpfile
+ done
+ # Files to uninstall are listed in $tmpfile
+ # Existing files are in $orig_desktop_files
+ for desktop_file in $orig_desktop_files; do
+ if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then
+ # Keep this file, it's not in the uninstall list
+ new_desktop_files="$new_desktop_files $desktop_file"
+ fi
+ done
+ fi
+ rm -f "$tmpfile"
+
+ DEBUG 3 "Files to list in $menu_file: $new_desktop_files"
+
+ if [ -n "$new_desktop_files" ] ; then
+ # Install/update
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ (
+ echo '<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"'
+ echo ' "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">'
+ echo '<!-- Do not edit manually - generated and managed by xdg-desktop-menu -->'
+ echo '<Menu>'
+ echo ' <Name>Applications</Name>'
+
+ for desktop_file in $directory_files; do
+ basefile=`basename "$desktop_file"`
+ basefilename=`echo "$basefile"|cut -d '.' -f 1`
+ echo "<Menu>"
+ echo " <Name>$basefilename</Name>"
+ echo " <Directory>$basefile</Directory>"
+ done
+
+ echo " <Include>"
+ for desktop_file in $new_desktop_files; do
+ echo " <Filename>$desktop_file</Filename>"
+ done
+ echo " </Include>"
+
+ for desktop_file in $directory_files; do
+ echo "</Menu>"
+ done
+
+ echo '</Menu>'
+ ) > $tmpfile
+ chmod $my_chmod $tmpfile
+
+ save_umask=`umask`
+ umask $my_umask
+
+ mkdir -p $xdg_dir
+ eval 'cp $tmpfile $xdg_dir/$menu_file'$xdg_redirect_output
+
+ umask $save_umask
+ rm -f "$tmpfile"
+ else
+ # Uninstall
+ rm -f $xdg_dir/$menu_file
+ fi
+
+ # Uninstall .directory files only if no longer referenced
+ if [ $action = "uninstall" ] ; then
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ for menu_file in $xdg_dir/*; do
+ if grep 'generated and managed by xdg-desktop-menu' $menu_file > /dev/null 2> /dev/null; then
+ awk '
+# List all files within <Directory> tags
+BEGIN {
+ RS="<"
+}
+/^Directory/ {
+ if (match($0,/>/)) {
+ print substr($0,RSTART+1)
+ }
+}' $menu_file >> $tmpfile
+ fi
+ done
+ orig_directory_files="$directory_files"
+ directory_files=
+ for desktop_file in $orig_directory_files; do
+ if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then
+ # No longer in use, safe to delete
+ directory_files="$directory_files $desktop_file"
+ fi
+ done
+ rm -f "$tmpfile"
+ fi
+}
+
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+mode=
+action=
+update=yes
+desktop_files=
+directory_files=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ forceupdate)
+ action=forceupdate
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --noupdate)
+ update=no
+ ;;
+
+ --mode)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mode argument missing for --mode"
+ fi
+ case "$1" in
+ user)
+ mode="user"
+ ;;
+
+ system)
+ mode="system"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown mode '$1'"
+ ;;
+ esac
+ shift
+ ;;
+
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ "$action" = "install" ] ; then
+ check_input_file "$parm"
+ fi
+ case "$parm" in
+ *.directory)
+ if [ -n "$desktop_files" ] ; then
+ exit_failure_syntax "'$parm' must preceed any *.desktop file"
+ fi
+ directory_files="$directory_files $parm"
+ ;;
+ *.desktop)
+ desktop_files="$desktop_files $parm"
+ ;;
+ *)
+ exit_failure_syntax "file to $action must be a *.directory or *.desktop file"
+ ;;
+ esac
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
+ mode="system"
+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
+ mode="user"
+ fi
+fi
+
+if [ -z "$mode" ] ; then
+ if [ `whoami` = "root" ] ; then
+ mode="system"
+ else
+ mode="user"
+ fi
+fi
+
+if [ x"$action" = x"forceupdate" ] ; then
+ update_desktop_database
+ exit_success
+fi
+
+if [ -z "$desktop_files" ] ; then
+ exit_failure_syntax "desktop-file argument missing"
+fi
+
+menu_name=
+for desktop_file in $directory_files; do
+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$desktop_file"
+ fi
+
+ basefilename=`basename "$desktop_file" | cut -d '.' -f 1`
+ if [ -z "$menu_name" ] ; then
+ menu_name="$basefilename"
+ else
+ menu_name="$menu_name-$basefilename"
+ fi
+done
+
+if [ -n "$menu_name" ] ; then
+ if [ x"$mode" = x"user" ] ; then
+ update_submenu "user-$menu_name.menu"
+ else
+ update_submenu "$menu_name.menu"
+ fi
+else
+ # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications
+ if [ x"$mode" = x"user" ] ; then
+ update_submenu
+ fi
+fi
+
+# Install *.directory files
+
+xdg_dir_name=desktop-directories
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+xdg_global_dir=
+for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+
+DEBUG 3 "Install locations for *.directory files:"
+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+DEBUG 3 "kde_user_dir: $kde_user_dir"
+DEBUG 3 "kde_global_dir: $kde_global_dir"
+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system menu directory found."
+ fi
+fi
+
+for desktop_file in $directory_files; do
+ basefile=`basename "$desktop_file"`
+
+ DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir"
+
+ case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ mkdir -p $x
+ eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
+ done
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ rm -f $x/$basefile
+ done
+
+ ;;
+ esac
+done
+
+# Install *.desktop files
+xdg_dir_name=applications
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+xdg_global_dir=
+for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+
+kde_user_dir=`kde${KDE_SESSION_VERSION}-config --path apps 2> /dev/null | cut -d ':' -f 1`
+kde_global_dir=`kde${KDE_SESSION_VERSION}-config --path apps 2> /dev/null | cut -d ':' -f 2`
+[ -w $kde_global_dir ] || kde_global_dir=
+
+gnome_user_dir="$HOME/.gnome/apps"
+gnome_global_dir="/usr/share/gnome/apps"
+[ -w $gnome_global_dir ] || gnome_global_dir=
+
+DEBUG 3 "Install locations for *.desktop files:"
+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+DEBUG 3 "kde_user_dir: $kde_user_dir"
+DEBUG 3 "kde_global_dir: $kde_global_dir"
+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system menu directory found."
+ fi
+fi
+
+for desktop_file in $desktop_files; do
+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$desktop_file"
+ fi
+
+ basefile=`basename "$desktop_file"`
+
+ DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir"
+
+ case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ mkdir -p $x
+ eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
+ done
+
+ if [ -f $kde_dir/$basefile ] ; then
+ echo "OnlyShowIn=Old;" >> $kde_dir/$basefile
+ fi
+
+ if [ -f $gnome_dir/$basefile ] ; then
+ echo "OnlyShowIn=Old;" >> $gnome_dir/$basefile
+ fi
+
+ make_lazy_default "$xdg_dir" "$basefile"
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ rm -f $x/$basefile
+ done
+
+ ;;
+ esac
+done
+
+if [ x"$update" = x"yes" ] ; then
+ update_desktop_database
+fi
+
+exit_success
diff --git a/scripts/xdg-desktop-menu.in b/scripts/xdg-desktop-menu.in
new file mode 100644
index 0000000..431ac2a
--- /dev/null
+++ b/scripts/xdg-desktop-menu.in
@@ -0,0 +1,628 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-desktop-menu
+#
+# Utility script to install menu items on a Linux desktop.
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+update_desktop_database()
+{
+# echo Update desktop database: $mode
+ if [ "$mode" = "system" ] ; then
+ for x in `echo $PATH | sed 's/:/ /g'` /opt/gnome/bin; do
+ if [ -x $x/update-desktop-database ] ; then
+ DEBUG 1 "Running $x/update-desktop-database"
+ eval '$x/update-desktop-database'$xdg_redirect_output
+ return
+ fi
+ done
+ fi
+}
+
+# Make application $1/$2 the default for all the mimetypes it support,
+# iff such mimetype didn't had a default application already.
+# $1 Install dir for desktop file
+# $2 base name of desktop file
+make_lazy_default()
+{
+ local mimetypes
+ local xdg_user_dir
+ local xdg_default_dirs
+
+ DEBUG 1 "make_lazy_default $1/$2"
+ mimetypes=`awk '
+{
+ if (match($0,/MimeType=/)) {
+ split(substr($0,RSTART+9),mimetypes,";")
+ for (n in mimetypes)
+ {
+ if (mimetypes[n])
+ print mimetypes[n]
+ }
+ }
+}' "$1/$2" 2> /dev/null`
+
+ for MIME in $mimetypes ; do
+ xdg_default_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_default_dirs" ] || xdg_default_dirs=/usr/local/share/:/usr/share/
+ if [ x"$mode" = x"user" ] ; then
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+ xdg_default_dirs="$xdg_user_dir:$xdg_default_dirs"
+ fi
+ local default_app
+ for x in `echo "$xdg_default_dirs" | sed 's/:/ /g'`; do
+ DEBUG 2 "Checking $x/applications/defaults.list"
+ default_app=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2`
+ if [ -n "$default_app" ] ; then
+ DEBUG 2 "Found default apps for $MIME: $default_app"
+ default_app="$default_app;"
+ break;
+ fi
+ done
+ DEBUG 2 "Current default apps for $MIME: $default_app"
+ if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then
+ # App already listed as default
+ continue;
+ fi
+ default_file="$(readlink -f "$1/defaults.list")"
+ DEBUG 1 "Updating $default_file"
+ grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null
+ if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then
+ echo "[Default Applications]" >> ${default_file}.new
+ fi
+ echo $MIME="$default_app$2" >> ${default_file}.new
+ mv ${default_file}.new $default_file
+ done
+}
+
+update_submenu()
+{
+ DEBUG 1 "update_submenu $1"
+ menu_file="$1"
+
+ xdg_dir_name=menus
+ xdg_user_dir="$XDG_CONFIG_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.config"
+ xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+ xdg_system_dirs="$XDG_CONFIG_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/etc/xdg
+ xdg_global_dir=
+ for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+ done
+ xdg_user_dir="$xdg_user_dir/applications-merged"
+ xdg_global_dir="$xdg_global_dir/applications-merged"
+
+ DEBUG 3 "Install locations for *.menu file:"
+ DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+ DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+ DEBUG 3 "kde_user_dir: $kde_user_dir"
+ DEBUG 3 "kde_global_dir: $kde_global_dir"
+ DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+ DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+ if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+ my_chmod=0600
+ else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ my_chmod=0644
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system menu directory found."
+ fi
+ fi
+
+ if [ -z "$menu_file" ] ; then
+ # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications
+ save_umask=`umask`
+ umask $my_umask
+
+ mkdir -p $xdg_dir
+ touch $xdg_dir/@NAME@-dummy.menu
+
+ umask $save_umask
+ return
+ fi
+
+ if [ $action = "install" ] && [ -f "/etc/xdg/menus/gnome-applications.menu" ] ; then
+ # Work around for Debian Gnome
+ gnome_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/gnome-applications-merged^'`
+ if [ ! -e "$gnome_xdg_dir" ] ; then
+ DEBUG 1 "Debian Workaround: Link '$xdg_dir' to '$gnome_xdg_dir'"
+ mkdir -p `dirname "$gnome_xdg_dir"`
+ eval 'ln -s "applications-merged" "$gnome_xdg_dir"'$xdg_redirect_output
+ fi
+ fi
+ if [ $action = "install" ] && [ -f "/etc/mandrake-release" ] ; then
+ # Work around for Mandriva 2006
+ mandrake_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/applications-mdk-merged^'`
+ if [ ! -e "$mandrake_xdg_dir" ] ; then
+ DEBUG 1 "Mandriva Workaround: Link '$xdg_dir' to '$mandrake_xdg_dir'"
+ mkdir -p `dirname "$mandrake_xdg_dir"`
+ eval 'ln -s "applications-merged" "$mandrake_xdg_dir"'$xdg_redirect_output
+ fi
+ fi
+ if [ $action = "install" -a x"$mode" = x"user" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] ; then
+ # Work around for Fedora Core 5 + patched KDE
+ kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
+ if [ ! -e "$kde_xdg_dir" ] ; then
+ DEBUG 1 "Fedora Workaround: Link '$xdg_dir' to '$kde_xdg_dir'"
+ mkdir -p `dirname "$kde_xdg_dir"`
+ eval 'ln -s "applications-merged" "$kde_xdg_dir"'$xdg_redirect_output
+ fi
+ fi
+ if [ $action = "install" -a x"$mode" = x"system" ] && [ -d "/etc/xdg/menus/kde-applications-merged" ] && [ ! -d "/etc/xdg/menus/applications-merged" ] ; then
+ # Work around for Kubuntu 6.06
+ kde_xdg_dir=`echo "$xdg_dir" | sed -e 's^/applications-merged^/kde-applications-merged^'`
+ DEBUG 1 "Kubuntu Workaround: Link '$xdg_dir' to 'kde-applications-merged'"
+ eval 'ln -s "kde-applications-merged" "$xdg_dir"'$xdg_redirect_output
+ fi
+
+ orig_menu_file=$xdg_dir/$menu_file
+
+ DEBUG 1 "Updating $orig_menu_file ($action)"
+
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ orig_desktop_files=
+ if [ -r "$orig_menu_file" ] ; then
+ awk '
+# List all files within <Filename> tags
+BEGIN {
+ RS="<"
+}
+/^Filename/ {
+ if (match($0,/>/)) {
+ print substr($0,RSTART+1)
+ }
+}' $orig_menu_file > $tmpfile
+ fi
+
+ orig_desktop_files=`cat $tmpfile`
+ new_desktop_files=
+ if [ $action = "install" ] ; then
+ for desktop_file in $desktop_files; do
+ basefile=`basename "$desktop_file"`
+ if ! grep '^'$basefile'$' $tmpfile > /dev/null 2> /dev/null ; then
+ # Append
+ echo "$basefile" >> $tmpfile
+ fi
+ done
+ new_desktop_files=`cat $tmpfile`
+ fi
+ if [ $action = "uninstall" ] ; then
+ echo > $tmpfile
+ for desktop_file in $desktop_files; do
+ echo "$desktop_file" >> $tmpfile
+ done
+ # Files to uninstall are listed in $tmpfile
+ # Existing files are in $orig_desktop_files
+ for desktop_file in $orig_desktop_files; do
+ if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then
+ # Keep this file, it's not in the uninstall list
+ new_desktop_files="$new_desktop_files $desktop_file"
+ fi
+ done
+ fi
+ rm -f "$tmpfile"
+
+ DEBUG 3 "Files to list in $menu_file: $new_desktop_files"
+
+ if [ -n "$new_desktop_files" ] ; then
+ # Install/update
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ (
+ echo '<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"'
+ echo ' "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">'
+ echo '<!-- Do not edit manually - generated and managed by @NAME@ -->'
+ echo '<Menu>'
+ echo ' <Name>Applications</Name>'
+
+ for desktop_file in $directory_files; do
+ basefile=`basename "$desktop_file"`
+ basefilename=`echo "$basefile"|cut -d '.' -f 1`
+ echo "<Menu>"
+ echo " <Name>$basefilename</Name>"
+ echo " <Directory>$basefile</Directory>"
+ done
+
+ echo " <Include>"
+ for desktop_file in $new_desktop_files; do
+ echo " <Filename>$desktop_file</Filename>"
+ done
+ echo " </Include>"
+
+ for desktop_file in $directory_files; do
+ echo "</Menu>"
+ done
+
+ echo '</Menu>'
+ ) > $tmpfile
+ chmod $my_chmod $tmpfile
+
+ save_umask=`umask`
+ umask $my_umask
+
+ mkdir -p $xdg_dir
+ eval 'cp $tmpfile $xdg_dir/$menu_file'$xdg_redirect_output
+
+ umask $save_umask
+ rm -f "$tmpfile"
+ else
+ # Uninstall
+ rm -f $xdg_dir/$menu_file
+ fi
+
+ # Uninstall .directory files only if no longer referenced
+ if [ $action = "uninstall" ] ; then
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ for menu_file in $xdg_dir/*; do
+ if grep 'generated and managed by @NAME@' $menu_file > /dev/null 2> /dev/null; then
+ awk '
+# List all files within <Directory> tags
+BEGIN {
+ RS="<"
+}
+/^Directory/ {
+ if (match($0,/>/)) {
+ print substr($0,RSTART+1)
+ }
+}' $menu_file >> $tmpfile
+ fi
+ done
+ orig_directory_files="$directory_files"
+ directory_files=
+ for desktop_file in $orig_directory_files; do
+ if ! grep '^'$desktop_file'$' $tmpfile > /dev/null 2> /dev/null; then
+ # No longer in use, safe to delete
+ directory_files="$directory_files $desktop_file"
+ fi
+ done
+ rm -f "$tmpfile"
+ fi
+}
+
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+mode=
+action=
+update=yes
+desktop_files=
+directory_files=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ forceupdate)
+ action=forceupdate
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --noupdate)
+ update=no
+ ;;
+
+ --mode)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mode argument missing for --mode"
+ fi
+ case "$1" in
+ user)
+ mode="user"
+ ;;
+
+ system)
+ mode="system"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown mode '$1'"
+ ;;
+ esac
+ shift
+ ;;
+
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ "$action" = "install" ] ; then
+ check_input_file "$parm"
+ fi
+ case "$parm" in
+ *.directory)
+ if [ -n "$desktop_files" ] ; then
+ exit_failure_syntax "'$parm' must preceed any *.desktop file"
+ fi
+ directory_files="$directory_files $parm"
+ ;;
+ *.desktop)
+ desktop_files="$desktop_files $parm"
+ ;;
+ *)
+ exit_failure_syntax "file to $action must be a *.directory or *.desktop file"
+ ;;
+ esac
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
+ mode="system"
+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
+ mode="user"
+ fi
+fi
+
+if [ -z "$mode" ] ; then
+ if [ `whoami` = "root" ] ; then
+ mode="system"
+ else
+ mode="user"
+ fi
+fi
+
+if [ x"$action" = x"forceupdate" ] ; then
+ update_desktop_database
+ exit_success
+fi
+
+if [ -z "$desktop_files" ] ; then
+ exit_failure_syntax "desktop-file argument missing"
+fi
+
+menu_name=
+for desktop_file in $directory_files; do
+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$desktop_file"
+ fi
+
+ basefilename=`basename "$desktop_file" | cut -d '.' -f 1`
+ if [ -z "$menu_name" ] ; then
+ menu_name="$basefilename"
+ else
+ menu_name="$menu_name-$basefilename"
+ fi
+done
+
+if [ -n "$menu_name" ] ; then
+ if [ x"$mode" = x"user" ] ; then
+ update_submenu "user-$menu_name.menu"
+ else
+ update_submenu "$menu_name.menu"
+ fi
+else
+ # Work around for SUSE/gnome 2.12 to pick up new ~/.local/share/applications
+ if [ x"$mode" = x"user" ] ; then
+ update_submenu
+ fi
+fi
+
+# Install *.directory files
+
+xdg_dir_name=desktop-directories
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+xdg_global_dir=
+for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+
+DEBUG 3 "Install locations for *.directory files:"
+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+DEBUG 3 "kde_user_dir: $kde_user_dir"
+DEBUG 3 "kde_global_dir: $kde_global_dir"
+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system menu directory found."
+ fi
+fi
+
+for desktop_file in $directory_files; do
+ basefile=`basename "$desktop_file"`
+
+ DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir"
+
+ case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ mkdir -p $x
+ eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
+ done
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ rm -f $x/$basefile
+ done
+
+ ;;
+ esac
+done
+
+# Install *.desktop files
+xdg_dir_name=applications
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+xdg_global_dir=
+for x in `echo $xdg_system_dirs | sed 's/:/ /g'` ; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+
+kde_user_dir=`kde${KDE_SESSION_VERSION}-config --path apps 2> /dev/null | cut -d ':' -f 1`
+kde_global_dir=`kde${KDE_SESSION_VERSION}-config --path apps 2> /dev/null | cut -d ':' -f 2`
+[ -w $kde_global_dir ] || kde_global_dir=
+
+gnome_user_dir="$HOME/.gnome/apps"
+gnome_global_dir="/usr/share/gnome/apps"
+[ -w $gnome_global_dir ] || gnome_global_dir=
+
+DEBUG 3 "Install locations for *.desktop files:"
+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+DEBUG 3 "kde_user_dir: $kde_user_dir"
+DEBUG 3 "kde_global_dir: $kde_global_dir"
+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system menu directory found."
+ fi
+fi
+
+for desktop_file in $desktop_files; do
+ if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$desktop_file"
+ fi
+
+ basefile=`basename "$desktop_file"`
+
+ DEBUG 1 "$action $desktop_file in $xdg_dir $kde_dir $gnome_dir"
+
+ case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ mkdir -p $x
+ eval 'cp $desktop_file $x/$basefile'$xdg_redirect_output
+ done
+
+ if [ -f $kde_dir/$basefile ] ; then
+ echo "OnlyShowIn=Old;" >> $kde_dir/$basefile
+ fi
+
+ if [ -f $gnome_dir/$basefile ] ; then
+ echo "OnlyShowIn=Old;" >> $gnome_dir/$basefile
+ fi
+
+ make_lazy_default "$xdg_dir" "$basefile"
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in $xdg_dir $kde_dir $gnome_dir ; do
+ rm -f $x/$basefile
+ done
+
+ ;;
+ esac
+done
+
+if [ x"$update" = x"yes" ] ; then
+ update_desktop_database
+fi
+
+exit_success
diff --git a/scripts/xdg-email b/scripts/xdg-email
new file mode 100755
index 0000000..6ead033
--- /dev/null
+++ b/scripts/xdg-email
@@ -0,0 +1,727 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-email
+#
+# Utility script to open the users favorite email program, using the
+# RFC 2368 mailto: URI spec
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-email - command line tool for sending mail using the user's preferred
+e-mail composer
+
+Synopsis
+
+xdg-email [--utf8] [--cc address] [--bcc address] [--subject text] [--body text
+] [--attach file] [ mailto-uri | address(es) ]
+
+xdg-email { --help | --manual | --version }
+
+Description
+
+xdg-email opens the user's preferred e-mail composer in order to send a mail to
+address(es) or mailto-uri. RFC2368 defines mailto: URIs. xdg-email limits
+support to, cc, subject and body fields in mailto-uri, all other fields are
+silently ignored. address(es) must follow the syntax of RFC822. Multiple
+addresses may be provided as separate arguments.
+
+All information provided on the command line is used to prefill corresponding
+fields in the user's e-mail composer. The user will have the opportunity to
+change any of this information before actually sending the e-mail.
+
+xdg-email is for use inside a desktop session only. It is not recommended to
+use xdg-email as root.
+
+See http://portland.freedesktop.org/EmailConfig for information on how the user
+can change the e-mail composer that is used.
+
+Options
+
+--utf8
+ Indicates that all command line options that follow are in utf8. Without
+ this option, command line options are expected to be encoded according to
+ locale. If the locale already specifies utf8 this option has no effect.
+ This option does not affect mailto URIs that are passed on the command
+ line.
+--cc address
+ Specify a recipient to be copied on the e-mail.
+--bcc address
+ Specify a recipient to be blindly copied on the e-mail.
+--subject text
+ Specify a subject for the e-mail.
+--body text
+ Specify a body for the e-mail. Since the user will be able to make changes
+ before actually sending the e-mail, this can be used to provide the user
+ with a template for the e-mail. text may contain linebreaks.
+--attach file
+
+ Specify an attachment for the e-mail. file must point to an existing file.
+
+ Some e-mail applications require the file to remain present after xdg-email
+ returns.
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Environment Variables
+
+xdg-email honours the following environment variables:
+
+XDG_UTILS_DEBUG_LEVEL
+ Setting this environment variable to a non-zero numerical value makes
+ xdg-email do more verbose reporting on stderr. Setting a higher value
+ increases the verbosity.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+5
+ No permission to read one of the files passed on the command line.
+
+Configuration
+
+Visit http://portland.freedesktop.org/EmailConfig for information how to
+configure xdg-email to use the email client of your choice.
+
+Examples
+
+xdg-email 'Jeremy White <jwhite@example.com>'
+
+xdg-email --attach /tmp/logo.png \
+ --subject 'Logo contest' \
+ --body 'Attached you find the logo for the contest.' \
+ 'jwhite@example.com'
+
+xdg-email --subject 'Your password is about to expire' \
+ 'jwhite@example.com' 'bastian@example.com' 'whipple@example.com'
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-email - command line tool for sending mail using the user's preferred
+e-mail composer
+
+Synopsis
+
+xdg-email [--utf8] [--cc address] [--bcc address] [--subject text] [--body text
+] [--attach file] [ mailto-uri | address(es) ]
+
+xdg-email { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-email: $@" >&2
+ echo "Try 'xdg-email --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-email' or 'xdg-email --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-email: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-email: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-email: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-email: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-email: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-email: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-email --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-email' or 'xdg-email --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-email 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+run_thunderbird()
+{
+ local THUNDERBIRD MAILTO NEWMAILTO TO CC BCC SUBJECT BODY ATTACH
+ THUNDERBIRD="$1"
+ MAILTO=$(echo "$2" | sed 's/^mailto://')
+ echo "$MAILTO" | grep -qs "^?"
+ if [ "$?" = "0" ] ; then
+ MAILTO=$(echo "$MAILTO" | sed 's/^?//')
+ else
+ MAILTO=$(echo "$MAILTO" | sed 's/^/to=/' | sed 's/?/\&/')
+ fi
+
+ MAILTO=$(echo "$MAILTO" | sed 's/&/\n/g')
+ TO=$(echo "$MAILTO" | grep '^to=' | sed 's/^to=//' | awk '{ printf "%s,",$0 }')
+ CC=$(echo "$MAILTO" | grep '^cc=' | sed 's/^cc=//' | awk '{ printf "%s,",$0 }')
+ BCC=$(echo "$MAILTO" | grep '^bcc=' | sed 's/^bcc=//' | awk '{ printf "%s,",$0 }')
+ SUBJECT=$(echo "$MAILTO" | grep '^subject=' | tail -n 1)
+ BODY=$(echo "$MAILTO" | grep '^body=' | tail -n 1)
+ ATTACH=$(echo "$MAILTO" | sed 's/^attach=/\n\nfile:\/\//g' | awk '/^file:/ { printf "%s,",$0 }' | sed 's/,$//')
+
+ if [ -z "$TO" ] ; then
+ NEWMAILTO=
+ else
+ NEWMAILTO="to='$TO'"
+ fi
+ if [ -n "$CC" ] ; then
+ NEWMAILTO="${NEWMAILTO},cc='$CC'"
+ fi
+ if [ -n "$BCC" ] ; then
+ NEWMAILTO="${NEWMAILTO},bcc='$BCC'"
+ fi
+ if [ -n "$SUBJECT" ] ; then
+ NEWMAILTO="${NEWMAILTO},$SUBJECT"
+ fi
+ if [ -n "$BODY" ] ; then
+ NEWMAILTO="${NEWMAILTO},$BODY"
+ fi
+
+ if [ -n "$ATTACH" ] ; then
+ NEWMAILTO="${NEWMAILTO},attachment='${ATTACH}'"
+ fi
+
+ NEWMAILTO=$(echo "$NEWMAILTO" | sed 's/^,//')
+ DEBUG 1 "Running $THUNDERBIRD -compose \"$NEWMAILTO\""
+ "$THUNDERBIRD" -compose "$NEWMAILTO"
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_kde()
+{
+ local client kde_email_profile_name
+ kde_email_profile_name=`kreadconfig --file emaildefaults --group Defaults --key Profile`
+ client=`kreadconfig --file emaildefaults --group PROFILE_"$kde_email_profile_name" --key EmailClient | cut -d ' ' -f 1`
+ echo $client | grep thunderbird > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ run_thunderbird "$client" "$1"
+ fi
+
+ if [ -f /etc/SuSE-release ] ; then
+ # Workaround for SUSE 10.0
+ [ -z "$client" ] && client="kmail"
+ if ! which "$client" > /dev/null 2> /dev/null; then
+ DEBUG 3 "KDE has $client configured as email client which isn't installed"
+ if which gnome-open > /dev/null 2> /dev/null && which evolution > /dev/null 2> /dev/null; then
+ DEBUG 3 "Try gnome-open instead"
+ open_gnome "$1"
+ fi
+ fi
+ fi
+ DEBUG 1 "Running kmailservice \"$1\""
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ KMAILSERVICE=`kde4-config --locate kmailservice --path exe 2>/dev/null`
+ else
+ KMAILSERVICE=`which kmailservice 2>/dev/null`
+ fi
+ # KDE uses locale's encoding when decoding the URI, so set it to UTF-8
+ LC_ALL=C.UTF-8 $KMAILSERVICE "$1"
+ kfmclient_fix_exit_code $?
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_gnome()
+{
+ local client
+ client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -d ' ' -f 1` || ""
+ echo $client | grep thunderbird > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ run_thunderbird "$client" "$1"
+ fi
+
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gvfs-open \"$1\""
+ gvfs-open "$1"
+ else
+ DEBUG 1 "Running gnome-open \"$1\""
+ gnome-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+
+open_xfce()
+{
+ DEBUG 1 "Running exo-open \"$1\""
+ exo-open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_generic()
+{
+ IFS=":"
+ for browser in $BROWSER; do
+ if [ x"$browser" != x"" ]; then
+
+ browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
+ if [ $? -ne 0 ]; then browser_with_arg=$browser;
+ fi
+
+ if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1";
+ else $browser_with_arg;
+ fi
+
+ if [ $? -eq 0 ]; then exit_success;
+ fi
+ fi
+ done
+
+ exit_failure_operation_impossible "no method available for opening '$1'"
+}
+
+url_encode()
+{
+result=$(echo "$1" | $utf8 | awk '
+ BEGIN {
+ for ( i=1; i<=255; ++i ) ord [ sprintf ("%c", i) "" ] = i + 0
+ e = ""
+ linenr = 1
+ }
+ {
+ if ( linenr++ != 1 ) {
+ e = e "%0D%0A"
+ }
+ for ( i=1; i<=length ($0); ++i ) {
+ c = substr ($0, i, 1)
+ if ( ord [c] > 127 ) {
+ e = e "%" sprintf("%02X", ord [c])
+ } else if ( c ~ /[@a-zA-Z0-9.-\\\/]/ ) {
+ e = e c
+ } else {
+ e = e "%" sprintf("%02X", ord [c])
+ }
+ }
+ }
+ END {
+ print e
+ }
+')
+}
+
+options=
+mailto=
+utf8="iconv -t utf8"
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --utf8)
+ utf8="cat"
+ ;;
+
+ --to)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "email address argument missing for --to"
+ fi
+ url_encode "$1"
+ options="${options}to=${result}&"
+ shift
+ ;;
+
+ --cc)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "email address argument missing for --cc"
+ fi
+ url_encode "$1"
+ options="${options}cc=${result}&"
+ shift
+ ;;
+
+ --bcc)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "email address argument missing for --bcc"
+ fi
+ url_encode "$1"
+ options="${options}bcc=${result}&"
+ shift
+ ;;
+
+ --subject)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "text argument missing for --subject option"
+ fi
+ url_encode "$1"
+ options="${options}subject=${result}&"
+ shift
+ ;;
+
+ --body)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "text argument missing for --body option"
+ fi
+ url_encode "$1"
+ options="${options}body=${result}&"
+ shift
+ ;;
+
+ --attach)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "file argument missing for --attach option"
+ fi
+ check_input_file "$1"
+ file=`readlink -f "$1"` # Normalize path
+ if [ -z "$file" -o ! -f "$file" ] ; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+
+ url_encode "$file"
+ options="${options}attach=${result}&"
+ shift
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ mailto:*)
+ mailto="$parm"
+ ;;
+
+ *@*)
+ url_encode "$parm"
+ if [ -z "${mailto}" ] ; then
+ mailto="mailto:"${result}"?"
+ else
+ options="${options}to=${result}&"
+ fi
+ ;;
+
+ *)
+ exit_failure_syntax "unexpected argument '$parm'"
+ ;;
+ esac
+done
+
+if [ -z "${mailto}" ] ; then
+ # TO address is optional
+ mailto="mailto:?"
+fi
+
+case $mailto in
+ *\?)
+ mailto="${mailto}${options}"
+ ;;
+
+ *\?*)
+ mailto="${mailto}&${options}"
+ ;;
+
+ *)
+ mailto="${mailto}?${options}"
+ ;;
+esac
+
+# Strip trailing ? and &
+mailto=`echo "${mailto}"| sed 's/[?&]$//'`
+
+# Shouldn't happen
+[ x"${mailto}" != x"" ] || exit_failure_syntax
+
+if which xdg-email-hook.sh > /dev/null 2> /dev/null; then
+ xdg-email-hook.sh "${mailto}"
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+fi
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ DE=generic
+fi
+
+# if BROWSER variable is not set, check some well known browsers instead
+if [ x"$BROWSER" = x"" ]; then
+ BROWSER=links2:links:lynx:w3m
+ if [ -n "$DISPLAY" ]; then
+ BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
+ fi
+fi
+
+case "$DE" in
+ kde)
+ open_kde "${mailto}"
+ ;;
+
+ gnome)
+ open_gnome "${mailto}"
+ ;;
+
+ xfce)
+ open_xfce "${mailto}"
+ ;;
+
+ generic|lxde)
+ open_generic "${mailto}"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening '${mailto}'"
+ ;;
+esac
diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in
new file mode 100644
index 0000000..4c3cb83
--- /dev/null
+++ b/scripts/xdg-email.in
@@ -0,0 +1,411 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-email
+#
+# Utility script to open the users favorite email program, using the
+# RFC 2368 mailto: URI spec
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+run_thunderbird()
+{
+ local THUNDERBIRD MAILTO NEWMAILTO TO CC BCC SUBJECT BODY ATTACH
+ THUNDERBIRD="$1"
+ MAILTO=$(echo "$2" | sed 's/^mailto://')
+ echo "$MAILTO" | grep -qs "^?"
+ if [ "$?" = "0" ] ; then
+ MAILTO=$(echo "$MAILTO" | sed 's/^?//')
+ else
+ MAILTO=$(echo "$MAILTO" | sed 's/^/to=/' | sed 's/?/\&/')
+ fi
+
+ MAILTO=$(echo "$MAILTO" | sed 's/&/\n/g')
+ TO=$(echo -e $(echo "$MAILTO" | grep '^to=' | sed 's/^to=//;s/%\(..\)/\\x\1/g' | awk '{ printf "\"%s\",",$0 }'))
+ CC=$(echo -e $(echo "$MAILTO" | grep '^cc=' | sed 's/^cc=//;s/%\(..\)/\\x\1/g' | awk '{ printf "\"%s\",",$0 }'))
+ BCC=$(echo -e $(echo "$MAILTO" | grep '^bcc=' | sed 's/^bcc=//;s/%\(..\)/\\x\1/g' | awk '{ printf "\"%s\",",$0 }'))
+ SUBJECT=$(echo "$MAILTO" | grep '^subject=' | tail -n 1)
+ BODY=$(echo "$MAILTO" | grep '^body=' | tail -n 1)
+ ATTACH=$(echo -e $(echo "$MAILTO" | grep '^attach=' | sed 's/^attach=//;s/%\(..\)/\\x\1/g' | awk '{ printf "%s,",$0 }' | sed 's/,$//'))
+
+ if [ -z "$TO" ] ; then
+ NEWMAILTO=
+ else
+ NEWMAILTO="to='$TO'"
+ fi
+ if [ -n "$CC" ] ; then
+ NEWMAILTO="${NEWMAILTO},cc='$CC'"
+ fi
+ if [ -n "$BCC" ] ; then
+ NEWMAILTO="${NEWMAILTO},bcc='$BCC'"
+ fi
+ if [ -n "$SUBJECT" ] ; then
+ NEWMAILTO="${NEWMAILTO},$SUBJECT"
+ fi
+ if [ -n "$BODY" ] ; then
+ NEWMAILTO="${NEWMAILTO},$BODY"
+ fi
+
+ if [ -n "$ATTACH" ] ; then
+ NEWMAILTO="${NEWMAILTO},attachment='${ATTACH}'"
+ fi
+
+ NEWMAILTO=$(echo "$NEWMAILTO" | sed 's/^,//')
+ DEBUG 1 "Running $THUNDERBIRD -compose \"$NEWMAILTO\""
+ "$THUNDERBIRD" -compose "$NEWMAILTO"
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_kde()
+{
+ local client kde_email_profile_name
+ kde_email_profile_name=`kreadconfig --file emaildefaults --group Defaults --key Profile`
+ client=`kreadconfig --file emaildefaults --group PROFILE_"$kde_email_profile_name" --key EmailClient | cut -d ' ' -f 1`
+ echo $client | grep thunderbird > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ run_thunderbird "$client" "$1"
+ fi
+
+ if [ -f /etc/SuSE-release ] ; then
+ # Workaround for SUSE 10.0
+ [ -z "$client" ] && client="kmail"
+ if ! which "$client" > /dev/null 2> /dev/null; then
+ DEBUG 3 "KDE has $client configured as email client which isn't installed"
+ if which gnome-open > /dev/null 2> /dev/null && which evolution > /dev/null 2> /dev/null; then
+ DEBUG 3 "Try gnome-open instead"
+ open_gnome "$1"
+ fi
+ fi
+ fi
+ DEBUG 1 "Running kmailservice \"$1\""
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ KMAILSERVICE=`kde4-config --locate kmailservice --path exe 2>/dev/null`
+ $KMAILSERVICE "$1"
+ else
+ KMAILSERVICE=`which kmailservice 2>/dev/null`
+ # KDE3 uses locale's encoding when decoding the URI, so set it to UTF-8
+ LC_ALL=C.UTF-8 $KMAILSERVICE "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_gnome3()
+{
+ local client
+ local desktop
+ desktop=`xdg-mime query default "x-scheme-handler/mailto"`
+ client=`desktop_file_to_binary "$browser"`
+ echo $client | grep thunderbird > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ run_thunderbird "$client" "$1"
+ fi
+
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gvfs-open \"$1\""
+ gvfs-open "$1"
+ else
+ DEBUG 1 "Running gnome-open \"$1\""
+ gnome-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_gnome()
+{
+ local client
+ client=`gconftool-2 --get /desktop/gnome/url-handlers/mailto/command | cut -d ' ' -f 1` || ""
+ echo $client | grep thunderbird > /dev/null 2>&1
+ if [ $? -eq 0 ] ; then
+ run_thunderbird "$client" "$1"
+ fi
+
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gvfs-open \"$1\""
+ gvfs-open "$1"
+ else
+ DEBUG 1 "Running gnome-open \"$1\""
+ gnome-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+
+open_xfce()
+{
+ DEBUG 1 "Running exo-open \"$1\""
+ exo-open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_generic()
+{
+ IFS=":"
+ for browser in $BROWSER; do
+ if [ x"$browser" != x"" ]; then
+
+ browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
+ if [ $? -ne 0 ]; then browser_with_arg=$browser;
+ fi
+
+ if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1";
+ else $browser_with_arg;
+ fi
+
+ if [ $? -eq 0 ]; then exit_success;
+ fi
+ fi
+ done
+
+ exit_failure_operation_impossible "no method available for opening '$1'"
+}
+
+url_encode()
+{
+str=$(echo "$1" | $utf8)
+local ORIG_LANG="$LANG"
+local ORIG_LC_ALL="$LC_ALL"
+LANG=C
+LC_ALL=C
+result=$(echo "$str" | awk '
+ BEGIN {
+ for ( i=1; i<=255; ++i ) ord [ sprintf ("%c", i) "" ] = i + 0
+ e = ""
+ linenr = 1
+ }
+ {
+ if ( linenr++ != 1 ) {
+ e = e "%0D%0A"
+ }
+ for ( i=1; i<=length ($0); ++i ) {
+ c = substr ($0, i, 1)
+ if ( ord [c] > 127 ) {
+ e = e "%" sprintf("%02X", ord [c])
+ } else if ( c ~ /[@a-zA-Z0-9.-\\\/]/ ) {
+ e = e c
+ } else {
+ e = e "%" sprintf("%02X", ord [c])
+ }
+ }
+ }
+ END {
+ print e
+ }
+')
+LANG="$ORIG_LANG"
+LC_ALL="$ORIG_LC_ALL"
+}
+
+options=
+mailto=
+utf8="iconv -t utf8"
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --utf8)
+ utf8="cat"
+ ;;
+
+ --to)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "email address argument missing for --to"
+ fi
+ url_encode "$1"
+ options="${options}to=${result}&"
+ shift
+ ;;
+
+ --cc)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "email address argument missing for --cc"
+ fi
+ url_encode "$1"
+ options="${options}cc=${result}&"
+ shift
+ ;;
+
+ --bcc)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "email address argument missing for --bcc"
+ fi
+ url_encode "$1"
+ options="${options}bcc=${result}&"
+ shift
+ ;;
+
+ --subject)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "text argument missing for --subject option"
+ fi
+ url_encode "$1"
+ options="${options}subject=${result}&"
+ shift
+ ;;
+
+ --body)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "text argument missing for --body option"
+ fi
+ url_encode "$1"
+ options="${options}body=${result}&"
+ shift
+ ;;
+
+ --attach)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "file argument missing for --attach option"
+ fi
+ check_input_file "$1"
+ file=`readlink -f "$1"` # Normalize path
+ if [ -z "$file" ] || [ ! -f "$file" ] ; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+
+ url_encode "$file"
+ options="${options}attach=${result}&"
+ shift
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ mailto:*)
+ mailto="$parm"
+ ;;
+
+ *@*)
+ url_encode "$parm"
+ if [ -z "${mailto}" ] ; then
+ mailto="mailto:"${result}"?"
+ else
+ options="${options}to=${result}&"
+ fi
+ ;;
+
+ *)
+ exit_failure_syntax "unexpected argument '$parm'"
+ ;;
+ esac
+done
+
+if [ -z "${mailto}" ] ; then
+ # TO address is optional
+ mailto="mailto:?"
+fi
+
+case $mailto in
+ *\?)
+ mailto="${mailto}${options}"
+ ;;
+
+ *\?*)
+ mailto="${mailto}&${options}"
+ ;;
+
+ *)
+ mailto="${mailto}?${options}"
+ ;;
+esac
+
+# Strip trailing ? and &
+mailto=`echo "${mailto}"| sed 's/[?&]$//'`
+
+# Shouldn't happen
+[ x"${mailto}" != x"" ] || exit_failure_syntax
+
+if which @NAME@-hook.sh > /dev/null 2> /dev/null; then
+ @NAME@-hook.sh "${mailto}"
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+fi
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ DE=generic
+fi
+
+# if BROWSER variable is not set, check some well known browsers instead
+if [ x"$BROWSER" = x"" ]; then
+ BROWSER=links2:elinks:links:lynx:w3m
+ if [ -n "$DISPLAY" ]; then
+ BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
+ fi
+fi
+
+case "$DE" in
+ kde)
+ open_kde "${mailto}"
+ ;;
+
+ gnome)
+ open_gnome "${mailto}"
+ ;;
+
+ gnome3)
+ open_gnome3 "${mailto}"
+ ;;
+
+ xfce)
+ open_xfce "${mailto}"
+ ;;
+
+ generic|lxde)
+ open_generic "${mailto}"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening '${mailto}'"
+ ;;
+esac
diff --git a/scripts/xdg-file-dialog b/scripts/xdg-file-dialog
new file mode 100755
index 0000000..3f6fae7
--- /dev/null
+++ b/scripts/xdg-file-dialog
@@ -0,0 +1,603 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-file-dialog
+#
+# Utility script to file selection dialogs
+# on XDG compliant systems.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+ xdg-file-dialog -- command line tool for providing file and directory
+ selection dialogs
+
+Synopsis
+
+ xdg-file-dialog openfilename [--title TITLE] [FILENAME]
+
+ xdg-file-dialog openfilenamelist [--title TITLE] [FILENAME]
+
+ xdg-file-dialog savefilename [--title TITLE] [FILENAME]
+
+ xdg-file-dialog directory [--title TITLE] [DIRNAME]
+
+ xdg-file-dialog { --help | --manual | --version }
+
+Description
+
+ The xdg-file-dialog program can be used to let the native file selection
+ dialog handle file and directory input.
+
+ xdg-file-dialog is for use inside a desktop session only. It is not
+ recommended to use xdg-file-dialog as root.
+
+Commands
+
+ openfilename
+ Returns the filename with path for a file to read from. FILENAME
+ can optionally be used to specify path and filename of a
+ preselection.
+
+ openfilenamelist
+ Returns one or more filenames with path for files to read from,
+ each on a new line. FILENAME can optionally be used to specify
+ path and filename of a preselection.
+
+ savefilename
+ Returns the filename with path for file to write to. FILENAME can
+ optionally be used to specify path and filename of a preselection.
+
+ directory
+ Returns the path for an exsiting directory. DIRNAME can optionally
+ be used to specify a path of a preselection.
+
+Options
+
+ --title TITLE
+ Sets the dialog's title (caption) to the specified text.
+
+ --help
+ Show command synopsis.
+
+ --manual
+ Show this manualpage.
+
+ --version
+ Show the xdg-utils version information.
+
+Exit Codes
+
+ An exit code of 0 indicates success while a non-zero exit code indicates
+ failure. The following failure codes can be returned:
+
+ 1
+ Error in command line syntax.
+
+ 2
+ One of the files passed on the command line did not exist.
+
+ 3
+ A required tool could not be found.
+
+ 4
+ The action failed.
+
+Examples
+
+ xdg-file-dialog savefilename /tmp/foobar.png
+
+ Asks for a save file name starting in directory /tmp and suggesting
+ foobar.png as the filename
+
+ xdg-file-dialog directory --title "Select a target folder" /tmp
+
+ Asks for a directory name starting in directory /tmp using the text
+ "Select a target folder" as the dialog's title/caption.
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+ xdg-file-dialog -- command line tool for providing file and directory
+ selection dialogs
+
+Synopsis
+
+ xdg-file-dialog openfilename [--title TITLE] [FILENAME]
+
+ xdg-file-dialog openfilenamelist [--title TITLE] [FILENAME]
+
+ xdg-file-dialog savefilename [--title TITLE] [FILENAME]
+
+ xdg-file-dialog directory [--title TITLE] [DIRNAME]
+
+ xdg-file-dialog { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-file-dialog: $@" >&2
+ echo "Try 'xdg-file-dialog --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-file-dialog' or 'xdg-file-dialog --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-file-dialog: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-file-dialog: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-file-dialog: $@" >&2
+ fi
+
+ exit 4
+}
+
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ --help)
+ usage
+ echo "Use 'man xdg-file-dialog' or 'xdg-file-dialog --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-file-dialog 1.0beta1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ fi
+}
+
+#----------------------------------------------------------------------------
+
+
+
+open_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --getopenfilename "$1" ""
+ else
+ $DIALOG --getopenfilename "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+open_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd `dirname "$1"` 2>/dev/null
+ FILENAME=`basename "$1"`
+ if [ x"$FILENAME" != x"" ]; then
+ FILENAME="--filename=""$FILENAME"
+ fi
+ fi
+
+ if [ x"$FILENAME" != x"" ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --file-selection "$FILENAME"
+ else
+ $DIALOG --file-selection "$FILENAME"
+ fi
+ else
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --file-selection
+ else
+ $DIALOG --file-selection
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+open_multi_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --multiple --separate-output \
+ --getopenfilename "$1" ""
+ else
+ $DIALOG --multiple --separate-output --getopenfilename "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+open_multi_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd `dirname "$1"` 2>/dev/null
+ FILENAME=`basename "$1"`
+ if [ x"$FILENAME" != x"" ]; then
+ FILENAME="--filename=""$FILENAME"
+ fi
+ fi
+
+ if [ x"$FILENAME" != x"" ]; then
+ if [ x"$TITLE" != x"" ]; then
+ LIST=`$DIALOG --title "$TITLE" --multiple --file-selection "$FILENAME"`
+ else
+ LIST=`$DIALOG --multiple --file-selection "$FILENAME"`
+ fi
+ else
+ if [ x"$TITLE" != x"" ]; then
+ LIST=`$DIALOG --title "$TITLE" --multiple --file-selection`
+ else
+ LIST=`$DIALOG --multiple --file-selection`
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ echo "$LIST" | sed s#'|'#\\n#g
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+save_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --getsavefilename "$1" ""
+ else
+ $DIALOG --getsavefilename "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+save_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd `dirname "$1"` 2>/dev/null
+ FILENAME=`basename "$1"`
+ if [ x"$FILENAME" != x"" ]; then
+ FILENAME="--filename=""$FILENAME"
+ fi
+ fi
+
+ if [ x"$FILENAME" != x"" ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --save --file-selection "$FILENAME"
+ else
+ $DIALOG --save --file-selection "$FILENAME"
+ fi
+ else
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --save --file-selection
+ else
+ $DIALOG --save --file-selection
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+directory_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --getexistingdirectory "$1" ""
+ else
+ $DIALOG --getexistingdirectory "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+directory_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd "$1" 2>/dev/null
+ fi
+
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --directory --file-selection
+ else
+ $DIALOG --directory --file-selection
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+TITLE=
+action=
+filename=
+
+case $1 in
+ openfilename)
+ action=openfilename
+ ;;
+
+ openfilenamelist)
+ action=openfilenamelist
+ ;;
+
+ savefilename)
+ action=savefilename
+ ;;
+
+ directory)
+ action=directory
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+while [ $# -gt 0 ] ; do
+ parm=$1
+ shift
+
+ case $parm in
+ --title)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "TITLE argument missing for --title"
+ fi
+ TITLE="$1"
+ shift
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$filename" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ filename="$parm"
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+detectDE
+
+if [ "$action" = "openfilename" ]; then
+ case "$DE" in
+ kde)
+ open_kde "$filename"
+ ;;
+
+ gnome|xfce)
+ open_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a filename dialog"
+ ;;
+ esac
+elif [ "$action" = "openfilenamelist" ]; then
+ case "$DE" in
+ kde)
+ open_multi_kde "$filename"
+ ;;
+
+ gnome|xfce)
+ open_multi_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a filename dialog"
+ ;;
+ esac
+elif [ "$action" = "savefilename" ]; then
+ case "$DE" in
+ kde)
+ save_kde "$filename"
+ ;;
+
+ gnome|xfce)
+ save_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a filename dialog"
+ ;;
+ esac
+elif [ "$action" = "directory" ]; then
+ case "$DE" in
+ kde)
+ directory_kde "$filename"
+ ;;
+
+ gnome|xfce)
+ directory_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a directory dialog"
+ ;;
+ esac
+fi
diff --git a/scripts/xdg-file-dialog.in b/scripts/xdg-file-dialog.in
new file mode 100644
index 0000000..14fc102
--- /dev/null
+++ b/scripts/xdg-file-dialog.in
@@ -0,0 +1,365 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-file-dialog
+#
+# Utility script to file selection dialogs
+# on XDG compliant systems.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+open_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --getopenfilename "$1" ""
+ else
+ $DIALOG --getopenfilename "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+open_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd `dirname "$1"` 2>/dev/null
+ FILENAME=`basename "$1"`
+ if [ x"$FILENAME" != x"" ]; then
+ FILENAME="--filename=""$FILENAME"
+ fi
+ fi
+
+ if [ x"$FILENAME" != x"" ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --file-selection "$FILENAME"
+ else
+ $DIALOG --file-selection "$FILENAME"
+ fi
+ else
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --file-selection
+ else
+ $DIALOG --file-selection
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+open_multi_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --multiple --separate-output \
+ --getopenfilename "$1" ""
+ else
+ $DIALOG --multiple --separate-output --getopenfilename "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+open_multi_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd `dirname "$1"` 2>/dev/null
+ FILENAME=`basename "$1"`
+ if [ x"$FILENAME" != x"" ]; then
+ FILENAME="--filename=""$FILENAME"
+ fi
+ fi
+
+ if [ x"$FILENAME" != x"" ]; then
+ if [ x"$TITLE" != x"" ]; then
+ LIST=`$DIALOG --title "$TITLE" --multiple --file-selection "$FILENAME"`
+ else
+ LIST=`$DIALOG --multiple --file-selection "$FILENAME"`
+ fi
+ else
+ if [ x"$TITLE" != x"" ]; then
+ LIST=`$DIALOG --title "$TITLE" --multiple --file-selection`
+ else
+ LIST=`$DIALOG --multiple --file-selection`
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ echo "$LIST" | sed s#'|'#\\n#g
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+save_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --getsavefilename "$1" ""
+ else
+ $DIALOG --getsavefilename "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+save_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd `dirname "$1"` 2>/dev/null
+ FILENAME=`basename "$1"`
+ if [ x"$FILENAME" != x"" ]; then
+ FILENAME="--filename=""$FILENAME"
+ fi
+ fi
+
+ if [ x"$FILENAME" != x"" ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --save --file-selection "$FILENAME"
+ else
+ $DIALOG --save --file-selection "$FILENAME"
+ fi
+ else
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --save --file-selection
+ else
+ $DIALOG --save --file-selection
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+directory_kde()
+{
+ DIALOG=`which kdialog`
+ if [ $? -eq 0 ]; then
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --getexistingdirectory "$1" ""
+ else
+ $DIALOG --getexistingdirectory "$1" ""
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+directory_zenity()
+{
+ DIALOG=`which zenity`
+ if [ $? -eq 0 ]; then
+ if [ x"$1" != x"" ]; then
+ cd "$1" 2>/dev/null
+ fi
+
+ if [ x"$TITLE" != x"" ]; then
+ $DIALOG --title "$TITLE" --directory --file-selection
+ else
+ $DIALOG --directory --file-selection
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+TITLE=
+action=
+filename=
+
+case $1 in
+ openfilename)
+ action=openfilename
+ ;;
+
+ openfilenamelist)
+ action=openfilenamelist
+ ;;
+
+ savefilename)
+ action=savefilename
+ ;;
+
+ directory)
+ action=directory
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --title)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "TITLE argument missing for --title"
+ fi
+ TITLE="$1"
+ shift
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$filename" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ filename="$parm"
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+detectDE
+
+if [ "$action" = "openfilename" ]; then
+ case "$DE" in
+ kde)
+ open_kde "$filename"
+ ;;
+
+ gnome*|xfce|lxde)
+ open_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a filename dialog"
+ ;;
+ esac
+elif [ "$action" = "openfilenamelist" ]; then
+ case "$DE" in
+ kde)
+ open_multi_kde "$filename"
+ ;;
+
+ gnome*|xfce|lxde)
+ open_multi_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a filename dialog"
+ ;;
+ esac
+elif [ "$action" = "savefilename" ]; then
+ case "$DE" in
+ kde)
+ save_kde "$filename"
+ ;;
+
+ gnome*|xfce|lxde)
+ save_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a filename dialog"
+ ;;
+ esac
+elif [ "$action" = "directory" ]; then
+ case "$DE" in
+ kde)
+ directory_kde "$filename"
+ ;;
+
+ gnome*|xfce|lxde)
+ directory_zenity "$filename"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening a directory dialog"
+ ;;
+ esac
+fi
diff --git a/scripts/xdg-icon-resource b/scripts/xdg-icon-resource
new file mode 100755
index 0000000..8c61bf8
--- /dev/null
+++ b/scripts/xdg-icon-resource
@@ -0,0 +1,844 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-icon-resource
+#
+# Utility script to install icons on a Linux desktop.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-icon-resource - command line tool for (un)installing icon resources
+
+Synopsis
+
+xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
+context] [--mode mode] --size size icon-file [icon-name]
+
+xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
+[--mode mode] --size size icon-name
+
+xdg-icon-resource forceupdate [--theme theme] [--mode mode]
+
+xdg-icon-resource { --help | --manual | --version }
+
+Description
+
+The xdg-icon-resource program can be used to install icon resources into the
+desktop icon system in order to illustrate menu entries, to depict desktop
+icons or to graphically represent file types.
+
+The desktop icon system identifies icons by name. Depending on the required
+size, the choice of icon theme and the context in which the icon is used, the
+desktop icon system locates an appropriate icon resource to depict an icon.
+Icon resources can be XPM files or PNG files.
+
+The desktop icon system works according to the XDG Icon Theme Specification at
+http://www.freedesktop.org/Standards/icon-theme-spec
+
+Commands
+
+install
+ Installs the icon file indicated by icon-file to the desktop icon system
+ under the name icon-name. Icon names do not have an extension. If icon-name
+ is not provided the name is derived from icon-file. The icon file must have
+ .png or .xpm as extension. If a corresponding .icon file exists in the same
+ location as icon-file it will be installed as well.
+uninstall
+ Removes the icon indicated by icon-name from the desktop icon system. Note
+ that icon names do not have an extension.
+forceupdate
+ Force an update of the desktop icon system. This is only useful if the last
+ call to xdg-icon-resource included the --noupdate option.
+
+Options
+
+--noupdate
+ Postpone updating the desktop icon system. If multiple icons are added in
+ sequence this flag can be used to indicate that additional changes will
+ follow and that it is not necassery to update the desktop icon system right
+ away.
+--novendor
+
+ Normally, xdg-icon-resource checks to ensure that an icon file to be
+ installed in the apps context has a proper vendor prefix. This option can
+ be used to disable that check.
+
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
+ with a dash ("-"). Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold a
+ trademark as their vendor prefix. The purpose of the vendor prefix is to
+ prevent name conflicts.
+
+--theme theme
+ Installs or removes the icon file as part of theme. If no theme is
+ specified the icons will be installed as part of the default hicolor theme.
+ Applications may install icons under multiple themes but should at least
+ install icons for the default hicolor theme.
+--context context
+ Specifies the context for the icon. Icons to be used in the application
+ menu and as desktop icon should use apps as context which is the default
+ context. Icons to be used as file icons should use mimetypes as context.
+ Other common contexts are actions, devices, emblems, filesystems and stock.
+--size size
+ Specifies the size of the icon. All icons must be square. Common sizes for
+ icons in the apps context are: 16, 22, 32, 48, 64 and 128. Common sizes for
+ icons in the mimetypes context are: 16, 22, 32, 48, 64 and 128
+--mode mode
+
+ mode can be user or system. In user mode the file is (un)installed for the
+ current user only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in system mode.
+
+ The default is to use system mode when called by root and to use user mode
+ when called by a non-root user.
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Environment Variables
+
+xdg-icon-resource honours the following environment variables:
+
+XDG_UTILS_DEBUG_LEVEL
+ Setting this environment variable to a non-zero numerical value makes
+ xdg-icon-resource do more verbose reporting on stderr. Setting a higher
+ value increases the verbosity.
+XDG_UTILS_INSTALL_MODE
+ This environment variable can be used by the user or administrator to
+ override the installation mode. Valid values are user and system.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+5
+ No permission to read one of the files passed on the command line.
+
+See Also
+
+xdg-desktop-icon(1), xdg-desktop-menu(1), xdg-mime(1)
+
+Examples
+
+To install an icon resource to depict a launcher for the application myfoobar,
+the company ShinyThings Inc. can use:
+
+xdg-icon-resource install --size 64 shinythings-myfoobar.png
+
+To install an icon for a new application/x-foobar file type one can use:
+
+xdg-icon-resource install --context mimetypes --size 48 ./mime-foobar-48.png application-x-foobar
+xdg-icon-resource install --context mimetypes --size 64 ./mime-foobar-64.png application-x-foobar
+
+This will install two icons with the name application-x-foobar but with
+different sizes.
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-icon-resource - command line tool for (un)installing icon resources
+
+Synopsis
+
+xdg-icon-resource install [--noupdate] [--novendor] [--theme theme] [--context
+context] [--mode mode] --size size icon-file [icon-name]
+
+xdg-icon-resource uninstall [--noupdate] [--theme theme] [--context context]
+[--mode mode] --size size icon-name
+
+xdg-icon-resource forceupdate [--theme theme] [--mode mode]
+
+xdg-icon-resource { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-icon-resource: $@" >&2
+ echo "Try 'xdg-icon-resource --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-icon-resource: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-icon-resource: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-icon-resource: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-icon-resource: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-icon-resource: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-icon-resource: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-icon-resource --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-icon-resource' or 'xdg-icon-resource --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-icon-resource 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+# Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or
+# to "-" if not found.
+GTK_UPDATE_ICON_CACHE=
+find_gtk_update_icon_cache()
+{
+ [ -n "$GTK_UPDATE_ICON_CACHE" ] && return;
+
+ GTK_UPDATE_ICON_CACHE="-"
+ for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
+ DEBUG 3 "Checking $x for gtk-update-icon-cache"
+ if [ -x "$x/gtk-update-icon-cache" ] ; then
+ DEBUG 1 "Found $x/gtk-update-icon-cache"
+ GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache"
+ return
+ fi
+ done
+}
+
+# Start GNOME legacy workaround section
+need_dot_icon_path()
+{
+ # GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons
+ # The availability of gtk-update-icon-cache is used as indication
+ # of whether the system is using GTK 2.6 or later
+ find_gtk_update_icon_cache
+ [ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1;
+ return 0;
+}
+
+update_icon_database()
+{
+ # Touch me, I'm dirty
+ touch "$1/.xdg-icon-resource-dummy"
+ rm -f "$1/.xdg-icon-resource-dummy"
+
+ # Don't create a cache if there wan't one already
+ if [ -f "$1/icon-theme.cache" ] ; then
+ find_gtk_update_icon_cache
+ if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then
+ DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\""
+ eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output
+ return
+ fi
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+mode=
+action=
+update=yes
+size=
+theme=hicolor
+context=apps
+icon_file=
+icon_name=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ forceupdate)
+ action=forceupdate
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case $parm in
+ --noupdate)
+ update=no
+ ;;
+
+ --mode)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mode argument missing for --mode"
+ fi
+ case "$1" in
+ user)
+ mode="user"
+ ;;
+
+ system)
+ mode="system"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown mode '$1'"
+ ;;
+ esac
+ shift
+ ;;
+
+ --theme)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "theme argument missing for --theme"
+ fi
+ theme="$1"
+ shift
+ ;;
+
+ --size)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "size argument missing for --size"
+ fi
+ if echo "$1" | grep '[^0-9]' > /dev/null 2> /dev/null; then
+ exit_failure_syntax "size argument must be numeric"
+ fi
+ size="$1"
+ shift
+ ;;
+
+ --context)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "context argument missing for --context"
+ fi
+ context="$1"
+ shift
+ ;;
+
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$icon_name" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ elif [ -n "$icon_file" ] ; then
+ icon_name="$parm"
+ else
+ if [ "$action" = "install" ] ; then
+ check_input_file "$parm"
+ fi
+ icon_file="$parm"
+ fi
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+# Shouldn't happen
+if [ -z "$context" ] ; then
+ exit_failure_syntax "context argument missing"
+fi
+
+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
+ mode="system"
+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
+ mode="user"
+ fi
+fi
+
+if [ -z "$mode" ] ; then
+ if [ `whoami` = "root" ] ; then
+ mode="system"
+ else
+ mode="user"
+ fi
+fi
+
+xdg_dir_name="icons/$theme"
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+xdg_user_prefix="$xdg_user_dir/icons"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_global_dir=
+xdg_global_prefix=
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs="/usr/local/share/:/usr/share/"
+for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_prefix="$x/icons"
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+[ -w $xdg_global_dir ] || xdg_global_dir=
+
+dot_icon_dir=
+dot_base_dir=
+if [ x"$mode" = x"user" ] ; then
+ xdg_base_dir="$xdg_user_dir"
+ #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
+ if need_dot_icon_path ; then
+ dot_icon_dir="$HOME/.icons"
+ dot_base_dir="$dot_icon_dir/$theme"
+ fi
+else
+ xdg_base_dir="$xdg_global_dir"
+ if [ -z "$xdg_base_dir" ] ; then
+ exit_failure_operation_impossible "No writable system icon directory found."
+ fi
+fi
+
+if [ x"$action" = x"forceupdate" ] ; then
+ if [ -n "$icon_file" ] ; then
+ exit_failure_syntax "unexpected argument '$icon_file'"
+ fi
+ update_icon_database $xdg_base_dir
+ if [ -n "$dot_icon_dir" ] ; then
+ if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
+ update_icon_database $dot_base_dir
+ fi
+ fi
+ exit_success
+fi
+
+if [ -z "$icon_file" ] ; then
+ if [ x"$action" = x"install" ] ; then
+ exit_failure_syntax "icon-file argument missing"
+ else
+ exit_failure_syntax "icon-name argument missing"
+ fi
+fi
+
+xdg_size_name=
+extension=
+
+if [ -z "$size" ] ; then
+ exit_failure_syntax "the icon size must be specified with --size"
+fi
+xdg_size_name="${size}x${size}"
+
+if [ x"$action" = x"install" ] ; then
+ case $icon_file in
+ *.xpm)
+ extension="xpm"
+ ;;
+ *.png)
+ extension="png"
+ ;;
+ *)
+ exit_failure_syntax "icon file to install must be a *.png or *.xpm file"
+ ;;
+ esac
+fi
+
+if [ -n "$icon_name" ] ; then
+ case $icon_name in
+ *.png)
+ exit_failure_syntax "icon name should not include an extension"
+ ;;
+ *.xpm)
+ exit_failure_syntax "icon name should not include an extension"
+ ;;
+ esac
+fi
+
+# Start KDE legacy workaround section
+need_kde_icon_path()
+{
+ local path
+ path=`readlink -f "$1" 2> /dev/null` # Normalize path
+ DEBUG 2 "need_kde_icon_path $path"
+ if [ -z "$path" ] ; then
+ DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no xdg icon dir)"
+ return 1; # Not needed
+ fi
+
+ # if kde-config not found... return 0
+ kde_icon_dirs=`kde${KDE_SESSION_VERSION}-config --path icon 2> /dev/null |sed 's/:/ /g'`
+ DEBUG 3 "kde_icon_dirs: $kde_icon_dirs"
+ if [ -z "$kde_icon_dirs" ] ; then
+ DEBUG 3 "no result from kde${KDE_SESSION_VERSION}-config --path icon"
+ DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no kde icon path)"
+ return 1; # Not needed
+ fi
+ needed=0 # Needed
+ for y in $kde_icon_dirs ; do
+ x=`readlink -f "$y"` # Normalize path
+ DEBUG 3 "Normalize $y --> $x"
+ if [ -n "$x" ] ; then
+ if [ "$x" = "$path" ] ; then
+ needed=1 # Not needed
+ fi
+ if [ -w "$x" ] ; then
+ kde_global_prefix="$x"
+ # Take last writable dir
+ fi
+ fi
+ done
+ DEBUG 2 "kde_global_prefix: $kde_global_prefix"
+ [ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed)"
+ [ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)"
+ return $needed
+}
+
+kde_dir=
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
+ #KDE 3.x doesn't support XDG_DATA_HOME for icons
+ #Check if xdg_dir prefix is listed by kde-config --path icon
+ #If not, install additional symlink to kdedir
+ if need_kde_icon_path "$xdg_user_prefix" ; then
+ kde_user_icon_dir=`kde${KDE_SESSION_VERSION}-config --path icon | cut -d ':' -f 1`
+ kde_user_dir="$kde_user_icon_dir/$theme"
+ kde_dir="$kde_user_dir/$xdg_size_name/$context"
+ fi
+ #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
+ if [ -n "$dot_icon_dir" ] ; then
+ if [ -L "$dot_icon_dir" ] ; then
+ # Don't do anything
+ dot_icon_dir=
+ elif [ ! -d "$dot_icon_dir/" ] ; then
+ # Symlink if it doesn't exist
+ eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_output
+ dot_icon_dir=
+ else
+ dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context"
+ fi
+ fi
+ my_umask=077
+else
+ xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
+ #KDE 3.x doesn't support XDG_DATA_DIRS for icons
+ #Check if xdg_dir prefix is listed by kde-config --path icon
+ #If not, install additional symlink to kdedir
+ if need_kde_icon_path "$xdg_global_prefix" ; then
+ kde_global_dir="$kde_global_prefix/$theme"
+ kde_dir="$kde_global_dir/$xdg_size_name/$context"
+ fi
+ my_umask=022
+fi
+# End KDE legacy workaround section
+
+# Start GNOME legacy workaround section
+need_gnome_mime=
+[ $context = "mimetypes" ] && need_gnome_mime=true
+# End GNOME legacy workaround section
+
+[ -n "$icon_name" ] || icon_name=`basename "$icon_file" | sed 's/\.[a-z][a-z][a-z]$//'`
+
+if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then
+ check_vendor_prefix "$icon_name" "icon name"
+fi
+
+icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'`
+icon_icon_name="$icon_name.icon"
+
+DEBUG 1 "$action icon in $xdg_dir"
+[ $action = "install" -a -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir"
+[ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)"
+[ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNOME 2.x support)"
+[ $action = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)"
+
+case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for icon_dir in $xdg_dir $dot_icon_dir; do
+ mkdir -p $icon_dir
+ eval 'cp "$icon_file" "$icon_dir/$icon_name.$extension"'$xdg_redirect_output
+ if [ -f "$icon_icon_file" ] ; then
+ eval 'cp "$icon_icon_file" "$icon_dir/$icon_icon_name"'$xdg_redirect_output
+ fi
+ if [ -n "$need_gnome_mime" ] ; then
+ eval 'ln -s "$icon_name.$extension" "$icon_dir/gnome-mime-$icon_name.$extension"'$xdg_redirect_output
+ fi
+ done
+ if [ -n "$kde_dir" ] ; then
+ mkdir -p $kde_dir
+ eval 'ln -s "$xdg_dir/$icon_name.$extension" "$kde_dir/$icon_name.$extension"'$xdg_redirect_output
+ fi
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for icon_dir in $xdg_dir $dot_icon_dir; do
+ rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png"
+ rm -f "$icon_dir/$icon_icon_name"
+ if [ -n "$need_gnome_mime" ] ; then
+ rm -f "$icon_dir/gnome-mime-$icon_name.xpm"
+ rm -f "$icon_dir/gnome-mime-$icon_name.png"
+ fi
+ done
+ if [ -n "$kde_dir" ] ; then
+ rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png"
+ fi
+
+ ;;
+esac
+
+if [ x"$update" = x"yes" ] ; then
+ update_icon_database "$xdg_base_dir"
+ if [ -n "$dot_icon_dir" ] ; then
+ if [ -d "$dot_icon_dir/" -a ! -L "$dot_icon_dir" ] ; then
+ update_icon_database $dot_base_dir
+ fi
+ fi
+fi
+
+exit_success
diff --git a/scripts/xdg-icon-resource.in b/scripts/xdg-icon-resource.in
new file mode 100644
index 0000000..be1ad58
--- /dev/null
+++ b/scripts/xdg-icon-resource.in
@@ -0,0 +1,450 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-icon-resource
+#
+# Utility script to install icons on a Linux desktop.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+# Set GTK_UPDATE_ICON_CACHE to gtk-update-icon-cache executable path or
+# to "-" if not found.
+GTK_UPDATE_ICON_CACHE=
+find_gtk_update_icon_cache()
+{
+ [ -n "$GTK_UPDATE_ICON_CACHE" ] && return;
+
+ GTK_UPDATE_ICON_CACHE="-"
+ for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
+ DEBUG 3 "Checking $x for gtk-update-icon-cache"
+ if [ -x "$x/gtk-update-icon-cache" ] ; then
+ DEBUG 1 "Found $x/gtk-update-icon-cache"
+ GTK_UPDATE_ICON_CACHE="$x/gtk-update-icon-cache"
+ return
+ fi
+ done
+}
+
+# Start GNOME legacy workaround section
+need_dot_icon_path()
+{
+ # GTK < 2.6 uses ~/.icons but not XDG_DATA_HOME/icons
+ # The availability of gtk-update-icon-cache is used as indication
+ # of whether the system is using GTK 2.6 or later
+ find_gtk_update_icon_cache
+ [ "$GTK_UPDATE_ICON_CACHE" != "-" ] && return 1;
+ return 0;
+}
+
+update_icon_database()
+{
+ # Touch me, I'm dirty
+ touch "$1/.@NAME@-dummy"
+ rm -f "$1/.@NAME@-dummy"
+
+ # Don't create a cache if there wan't one already
+ if [ -f "$1/icon-theme.cache" ] ; then
+ find_gtk_update_icon_cache
+ if [ "$GTK_UPDATE_ICON_CACHE" != "-" ] ; then
+ DEBUG 1 "Running $GTK_UPDATE_ICON_CACHE -f -t \"$1\""
+ eval '$GTK_UPDATE_ICON_CACHE -f -t "$1"'$xdg_redirect_output
+ return
+ fi
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+mode=
+action=
+update=yes
+size=
+theme=hicolor
+context=apps
+icon_file=
+icon_name=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ forceupdate)
+ action=forceupdate
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case $parm in
+ --noupdate)
+ update=no
+ ;;
+
+ --mode)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mode argument missing for --mode"
+ fi
+ case "$1" in
+ user)
+ mode="user"
+ ;;
+
+ system)
+ mode="system"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown mode '$1'"
+ ;;
+ esac
+ shift
+ ;;
+
+ --theme)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "theme argument missing for --theme"
+ fi
+ theme="$1"
+ shift
+ ;;
+
+ --size)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "size argument missing for --size"
+ fi
+ if echo "$1" | grep '[^0-9]' > /dev/null 2> /dev/null; then
+ exit_failure_syntax "size argument must be numeric"
+ fi
+ size="$1"
+ shift
+ ;;
+
+ --context)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "context argument missing for --context"
+ fi
+ context="$1"
+ shift
+ ;;
+
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$icon_name" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ elif [ -n "$icon_file" ] ; then
+ icon_name="$parm"
+ else
+ if [ "$action" = "install" ] ; then
+ check_input_file "$parm"
+ fi
+ icon_file="$parm"
+ fi
+ ;;
+ esac
+done
+
+# Shouldn't happen
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+# Shouldn't happen
+if [ -z "$context" ] ; then
+ exit_failure_syntax "context argument missing"
+fi
+
+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
+ mode="system"
+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
+ mode="user"
+ fi
+fi
+
+if [ -z "$mode" ] ; then
+ if [ `whoami` = "root" ] ; then
+ mode="system"
+ else
+ mode="user"
+ fi
+fi
+
+xdg_dir_name="icons/$theme"
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+xdg_user_prefix="$xdg_user_dir/icons"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_global_dir=
+xdg_global_prefix=
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs="/usr/local/share/:/usr/share/"
+for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ xdg_global_prefix="$x/icons"
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+[ -w $xdg_global_dir ] || xdg_global_dir=
+
+dot_icon_dir=
+dot_base_dir=
+if [ x"$mode" = x"user" ] ; then
+ xdg_base_dir="$xdg_user_dir"
+ #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
+ if need_dot_icon_path ; then
+ dot_icon_dir="$HOME/.icons"
+ dot_base_dir="$dot_icon_dir/$theme"
+ fi
+else
+ xdg_base_dir="$xdg_global_dir"
+ if [ -z "$xdg_base_dir" ] ; then
+ exit_failure_operation_impossible "No writable system icon directory found."
+ fi
+fi
+
+if [ x"$action" = x"forceupdate" ] ; then
+ if [ -n "$icon_file" ] ; then
+ exit_failure_syntax "unexpected argument '$icon_file'"
+ fi
+ update_icon_database $xdg_base_dir
+ if [ -n "$dot_icon_dir" ] ; then
+ if [ -d "$dot_icon_dir/" ] && [ ! -L "$dot_icon_dir" ] ; then
+ update_icon_database $dot_base_dir
+ fi
+ fi
+ exit_success
+fi
+
+if [ -z "$icon_file" ] ; then
+ if [ x"$action" = x"install" ] ; then
+ exit_failure_syntax "icon-file argument missing"
+ else
+ exit_failure_syntax "icon-name argument missing"
+ fi
+fi
+
+xdg_size_name=
+extension=
+
+if [ -z "$size" ] ; then
+ exit_failure_syntax "the icon size must be specified with --size"
+fi
+xdg_size_name="${size}x${size}"
+
+if [ x"$action" = x"install" ] ; then
+ case $icon_file in
+ *.xpm)
+ extension="xpm"
+ ;;
+ *.png)
+ extension="png"
+ ;;
+ *)
+ exit_failure_syntax "icon file to install must be a *.png or *.xpm file"
+ ;;
+ esac
+fi
+
+if [ -n "$icon_name" ] ; then
+ case $icon_name in
+ *.png)
+ exit_failure_syntax "icon name should not include an extension"
+ ;;
+ *.xpm)
+ exit_failure_syntax "icon name should not include an extension"
+ ;;
+ esac
+fi
+
+# Start KDE legacy workaround section
+need_kde_icon_path()
+{
+ local path
+ path=`readlink -f "$1" 2> /dev/null` # Normalize path
+ DEBUG 2 "need_kde_icon_path $path"
+ if [ -z "$path" ] ; then
+ DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no xdg icon dir)"
+ return 1; # Not needed
+ fi
+
+ # if kde-config not found... return 0
+ kde_icon_dirs=`kde${KDE_SESSION_VERSION}-config --path icon 2> /dev/null |sed 's/:/ /g'`
+ DEBUG 3 "kde_icon_dirs: $kde_icon_dirs"
+ if [ -z "$kde_icon_dirs" ] ; then
+ DEBUG 3 "no result from kde${KDE_SESSION_VERSION}-config --path icon"
+ DEBUG 2 "need_kde_icon_path RETURN 1 (not needed, no kde icon path)"
+ return 1; # Not needed
+ fi
+ needed=0 # Needed
+ for y in $kde_icon_dirs ; do
+ x=`readlink -f "$y"` # Normalize path
+ DEBUG 3 "Normalize $y --> $x"
+ if [ -n "$x" ] ; then
+ if [ "$x" = "$path" ] ; then
+ needed=1 # Not needed
+ fi
+ if [ -w "$x" ] ; then
+ kde_global_prefix="$x"
+ # Take last writable dir
+ fi
+ fi
+ done
+ DEBUG 2 "kde_global_prefix: $kde_global_prefix"
+ [ $needed -eq "1" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (not needed)"
+ [ $needed -eq "0" ] && DEBUG 2 "need_kde_icon_path RETURN $needed (needed)"
+ return $needed
+}
+
+kde_dir=
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
+ #KDE 3.x doesn't support XDG_DATA_HOME for icons
+ #Check if xdg_dir prefix is listed by kde-config --path icon
+ #If not, install additional symlink to kdedir
+ if need_kde_icon_path "$xdg_user_prefix" ; then
+ kde_user_icon_dir=`kde${KDE_SESSION_VERSION}-config --path icon | cut -d ':' -f 1`
+ kde_user_dir="$kde_user_icon_dir/$theme"
+ kde_dir="$kde_user_dir/$xdg_size_name/$context"
+ fi
+ #Gnome 2.8 supports ~/.icons but not XDG_DATA_HOME
+ if [ -n "$dot_icon_dir" ] ; then
+ if [ -L "$dot_icon_dir" ] ; then
+ # Don't do anything
+ dot_icon_dir=
+ elif [ ! -d "$dot_icon_dir/" ] ; then
+ # Symlink if it doesn't exist
+ eval 'ln -s ".local/share/icons" "$dot_icon_dir"'$xdg_redirect_output
+ dot_icon_dir=
+ else
+ dot_icon_dir="$dot_icon_dir/$theme/$xdg_size_name/$context"
+ fi
+ fi
+ my_umask=077
+else
+ xdg_dir="$xdg_base_dir/$xdg_size_name/$context"
+ #KDE 3.x doesn't support XDG_DATA_DIRS for icons
+ #Check if xdg_dir prefix is listed by kde-config --path icon
+ #If not, install additional symlink to kdedir
+ if need_kde_icon_path "$xdg_global_prefix" ; then
+ kde_global_dir="$kde_global_prefix/$theme"
+ kde_dir="$kde_global_dir/$xdg_size_name/$context"
+ fi
+ my_umask=022
+fi
+# End KDE legacy workaround section
+
+# Start GNOME legacy workaround section
+need_gnome_mime=
+[ $context = "mimetypes" ] && need_gnome_mime=true
+# End GNOME legacy workaround section
+
+[ -n "$icon_name" ] || icon_name=`basename "$icon_file" | sed 's/\.[a-z][a-z][a-z]$//'`
+
+if [ "$vendor" = "true" -a "$action" = "install" -a "$context" = "apps" ] ; then
+ check_vendor_prefix "$icon_name" "icon name"
+fi
+
+icon_icon_file=`echo "$icon_file" | sed 's/\.[a-z][a-z][a-z]$/.icon/'`
+icon_icon_name="$icon_name.icon"
+
+DEBUG 1 "$action icon in $xdg_dir"
+[ $action = "install" ] && [ -f $icon_icon_file ] && DEBUG 1 "install $icon_icon_name meta file in $xdg_dir"
+[ -n "$kde_dir" ] && DEBUG 1 "$action symlink in $kde_dir (KDE 3.x support)"
+[ -n "$need_gnome_mime" ] && DEBUG 1 "$action gnome-mime-$icon_name symlink (GNOME 2.x support)"
+[ $action = "install" -a -n "$dot_icon_dir" ] && DEBUG 1 "$action ~/.icons symlink (GNOME 2.8 support)"
+
+case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for icon_dir in $xdg_dir $dot_icon_dir; do
+ mkdir -p $icon_dir
+ eval 'cp "$icon_file" "$icon_dir/$icon_name.$extension"'$xdg_redirect_output
+ if [ -f "$icon_icon_file" ] ; then
+ eval 'cp "$icon_icon_file" "$icon_dir/$icon_icon_name"'$xdg_redirect_output
+ fi
+ if [ -n "$need_gnome_mime" ] ; then
+ eval 'ln -s "$icon_name.$extension" "$icon_dir/gnome-mime-$icon_name.$extension"'$xdg_redirect_output
+ fi
+ done
+ if [ -n "$kde_dir" ] ; then
+ mkdir -p $kde_dir
+ eval 'ln -s "$xdg_dir/$icon_name.$extension" "$kde_dir/$icon_name.$extension"'$xdg_redirect_output
+ fi
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for icon_dir in $xdg_dir $dot_icon_dir; do
+ rm -f "$icon_dir/$icon_name.xpm" "$icon_dir/$icon_name.png"
+ rm -f "$icon_dir/$icon_icon_name"
+ if [ -n "$need_gnome_mime" ] ; then
+ rm -f "$icon_dir/gnome-mime-$icon_name.xpm"
+ rm -f "$icon_dir/gnome-mime-$icon_name.png"
+ fi
+ done
+ if [ -n "$kde_dir" ] ; then
+ rm -f "$kde_dir/$icon_name.xpm" "$kde_dir/$icon_name.png"
+ fi
+
+ ;;
+esac
+
+if [ x"$update" = x"yes" ] ; then
+ update_icon_database "$xdg_base_dir"
+ if [ -n "$dot_icon_dir" ] ; then
+ if [ -d "$dot_icon_dir/" ] && [ ! -L "$dot_icon_dir" ] ; then
+ update_icon_database $dot_base_dir
+ fi
+ fi
+fi
+
+exit_success
diff --git a/scripts/xdg-mime b/scripts/xdg-mime
new file mode 100755
index 0000000..1171522
--- /dev/null
+++ b/scripts/xdg-mime
@@ -0,0 +1,1216 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-mime
+#
+# Utility script to manipulate MIME related information
+# on XDG compliant systems.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-mime - command line tool for querying information about file type handling
+and adding descriptions for new file types
+
+Synopsis
+
+xdg-mime query { filetype | default } ...
+
+xdg-mime default application mimetype(s)
+
+xdg-mime install [--mode mode] [--novendor] mimetypes-file
+
+xdg-mime uninstall [--mode mode] mimetypes-file
+
+xdg-mime { --help | --manual | --version }
+
+Description
+
+The xdg-mime program can be used to query information about file types and to
+add descriptions for new file types.
+
+Commands
+
+query
+
+ Returns information related to file types.
+
+ The query option is for use inside a desktop session only. It is not
+ recommended to use xdg-mime query as root.
+
+ The following queries are supported:
+
+ query filetype FILE: Returns the file type of FILE in the form of a MIME
+ type.
+
+ query default mimetype: Returns the default application that the desktop
+ environment uses for opening files of type mimetype. The default
+ application is identified by its *.desktop file.
+
+default
+
+ Ask the desktop environment to make application the default application for
+ opening files of type mimetype. An application can be made the default for
+ several file types by specifying multiple mimetypes.
+
+ application is the desktop file id of the application and has the form
+ vendor-name.desktop application must already be installed in the desktop
+ menu before it can be made the default handler. The aplication's desktop
+ file must list support for all the MIME types that it wishes to be the
+ default handler for.
+
+ Requests to make an application a default handler may be subject to system
+ policy or approval by the end-user. xdg-mime query can be used to verify
+ whether an application is the actual default handler for a specific file
+ type.
+
+ The default option is for use inside a desktop session only. It is not
+ recommended to use xdg-mime default as root.
+
+install
+ Adds the file type descriptions provided in mimetypes-file to the desktop
+ environment. mimetypes-file must be a XML file that follows the
+ freedesktop.org Shared MIME-info Database specification and that has a
+ mime-info element as its document root. For each new file type one or more
+ icons with name type-subtype must be installed with the xdg-icon-resource
+ command in the mimetypes context. For example the filetype application/
+ vnd.oasis.opendocument.text requires an icon named
+ application-vnd.oasis.opendocument.text to be installed (unless the file
+ type recommends another icon name).
+uninstall
+ Removes the file type descriptions provided in mimetypes-file and
+ previously added with xdg-mime install from the desktop environment.
+ mimetypes-file must be a XML file that follows the freedesktop.org Shared
+ MIME-info Database specification and that has a mime-info element as its
+ document root.
+
+Options
+
+--mode mode
+
+ mode can be user or system. In user mode the file is (un)installed for the
+ current user only. In system mode the file is (un)installed for all users
+ on the system. Usually only root is allowed to install in system mode.
+
+ The default is to use system mode when called by root and to use user mode
+ when called by a non-root user.
+
+--novendor
+
+ Normally, xdg-mime checks to ensure that the mimetypes-file to be installed
+ has a proper vendor prefix. This option can be used to disable that check.
+
+ A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated
+ with a dash ("-"). Companies and organizations are encouraged to use a word
+ or phrase, preferably the organizations name, for which they hold a
+ trademark as their vendor prefix. The purpose of the vendor prefix is to
+ prevent name conflicts.
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Environment Variables
+
+xdg-mime honours the following environment variables:
+
+XDG_UTILS_DEBUG_LEVEL
+ Setting this environment variable to a non-zero numerical value makes
+ xdg-mime do more verbose reporting on stderr. Setting a higher value
+ increases the verbosity.
+XDG_UTILS_INSTALL_MODE
+ This environment variable can be used by the user or administrator to
+ override the installation mode. Valid values are user and system.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+5
+ No permission to read one of the files passed on the command line.
+
+See Also
+
+xdg-icon-resource(1), xdg-desktop-menu(1)
+
+Examples
+
+xdg-mime query filetype /tmp/foobar.png
+
+Prints the MIME type of the file /tmp/foobar.png, in this case image/png
+
+xdg-mime query default image/png
+
+Prints the .desktop filename of the application which is registered to open PNG
+files.
+
+xdg-mime install shinythings-shiny.xml
+
+Adds a file type description for "shiny"-files. "shinythings-" is used as the
+vendor prefix. The file type description could look as folows.
+
+shinythings-shiny.xml:
+
+<?xml version="1.0"?>
+<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="text/x-shiny">
+ <comment>Shiny new file type</comment>
+ <glob pattern="*.shiny"/>
+ <glob pattern="*.shi"/>
+ </mime-type>
+</mime-info>
+
+An icon for this new file type must also be installed, for example with:
+
+xdg-icon-resource install --context mimetypes --size 64 shiny-file-icon.png text-x-shiny
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-mime - command line tool for querying information about file type handling
+and adding descriptions for new file types
+
+Synopsis
+
+xdg-mime query { filetype | default } ...
+
+xdg-mime default application mimetype(s)
+
+xdg-mime install [--mode mode] [--novendor] mimetypes-file
+
+xdg-mime uninstall [--mode mode] mimetypes-file
+
+xdg-mime { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-mime: $@" >&2
+ echo "Try 'xdg-mime --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-mime' or 'xdg-mime --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-mime: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-mime: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-mime: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-mime: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-mime: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-mime: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-mime --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-mime' or 'xdg-mime --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-mime 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+update_mime_database()
+{
+ if [ x"$mode" = x"user" -a -n "$DISPLAY" ] ; then
+ detectDE
+ if [ x"$DE" = x"kde" ] ; then
+ DEBUG 1 "Running kbuildsycoca"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ eval 'kbuildsycoca4'$xdg_redirect_output
+ else
+ eval 'kbuildsycoca'$xdg_redirect_output
+ fi
+ fi
+ fi
+ for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
+ if [ -x $x/update-mime-database ] ; then
+ DEBUG 1 "Running $x/update-mime-database $1"
+ eval '$x/update-mime-database $1'$xdg_redirect_output
+ return
+ fi
+ done
+}
+
+info_kde()
+{
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ DEBUG 1 "Running kmimetypefinder \"$1\""
+ KMIMETYPEFINDER=`which kmimetypefinder 2>/dev/null`
+ $KMIMETYPEFINDER "$1" 2>/dev/null | head -n 1
+ else
+ DEBUG 1 "Running kfile \"$1\""
+ KFILE=`which kfile 2>/dev/null`
+ $KFILE "$1" 2> /dev/null | head -n 1 | cut -d "(" -f 2 | cut -d ")" -f 1
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+info_gnome()
+{
+ file=`readlink -f "$1"` # Normalize path
+
+ if gvfs-info --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gvfs-info \"$file\""
+ gvfs-info "$file" 2> /dev/null | grep standard::content-type | cut -d' ' -f4
+ else
+ DEBUG 1 "Running gnomevfs-info \"$file\""
+ gnomevfs-info --slow-mime "$file" 2> /dev/null | grep "^MIME" | cut -d ":" -f 2 | sed s/"^ "//
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+info_generic()
+{
+ DEBUG 1 "Running file -i \"$1\""
+ /usr/bin/file -i "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "//
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+make_default_kde()
+{
+ # $1 is vendor-name.desktop
+ # $2 is mime/type
+ #
+ # On KDE 3, add to $KDE_CONFIG_PATH/profilerc:
+ # [$2 - 1]
+ # Application=$1
+ #
+ # Remove all [$2 - *] sections, or even better,
+ # renumber [$2 - *] sections and remove duplicate
+ #
+ # On KDE 4, add $2=$1 to $XDG_DATA_APPS/mimeapps.list
+ #
+ # Example file:
+ #
+ # [Added Associations]
+ # text/plain=kde4-kate.desktop;kde4-kwrite.desktop;
+ #
+ # [Removed Associations]
+ # text/plain=gnome-gedit.desktop;gnu-emacs.desktop;
+ vendor="$1"
+ mimetype="$2"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ default_dir=`kde4-config --path xdgdata-apps 2> /dev/null | cut -d ':' -f 1`
+ default_file="$default_dir/mimeapps.list"
+ else
+ default_dir=`kde-config --path config 2> /dev/null | cut -d ':' -f 1`
+ default_file="$default_dir/profilerc"
+ fi
+ if [ -z "$default_dir" ]; then
+ DEBUG 2 "make_default_kde: No kde runtime detected"
+ return
+ fi
+ DEBUG 2 "make_default_kde $vendor $mimetype"
+ DEBUG 1 "Updating $default_file"
+ mkdir -p "$default_dir"
+ [ -f $default_file ] || touch $default_file
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ [ -f $default_file ] || touch $default_file
+ awk -v application="$vendor" -v mimetype="$mimetype" '
+ BEGIN {
+ prefix=mimetype "="
+ associations=0
+ found=0
+ blanks=0
+ }
+ {
+ suppress=0
+ if (index($0, "[Added Associations]") == 1) {
+ associations=1
+ } else if (index($0, "[") == 1) {
+ if (associations && !found) {
+ print prefix application
+ found=1
+ }
+ associations=0
+ } else if ($0 == "") {
+ blanks++
+ suppress=1
+ } else if (associations && index($0, prefix) == 1) {
+ value=substr($0, length(prefix) + 1, length)
+ split(value, apps, ";")
+ value=application ";"
+ count=0
+ for (i in apps) {
+ count++
+ }
+ for (i=0; i < count; i++) {
+ if (apps[i] != application && apps[i] != "") {
+ value=value apps[i] ";"
+ }
+ }
+ $0=prefix value
+ found=1
+ }
+ if (!suppress) {
+ while (blanks > 0) {
+ print ""
+ blanks--
+ }
+ print $0
+ }
+ }
+ END {
+ if (!found) {
+ if (!associations) {
+ print "[Added Associations]"
+ }
+ print prefix application
+ }
+ while (blanks > 0) {
+ print ""
+ blanks--
+ }
+ }
+' $default_file > ${default_file}.new && mv ${default_file}.new $default_file
+ eval 'kbuildsycoca4'$xdg_redirect_output
+ else
+ awk -v application="$vendor" -v mimetype="$mimetype" '
+ BEGIN {
+ header_start="[" mimetype " - "
+ suppress=0
+ }
+ {
+ if (index($0, header_start) == 1 )
+ suppress=1
+ else
+ if (/^\[/) { suppress=0 }
+
+ if (!suppress) {
+ print $0
+ }
+ }
+ END {
+ print ""
+ print "[" mimetype " - 1]"
+ print "Application=" application
+ print "AllowAsDefault=true"
+ print "GenericServiceType=Application"
+ print "Preference=1"
+ print "ServiceType=" mimetype
+ }
+' $default_file > ${default_file}.new && mv ${default_file}.new $default_file
+ fi
+}
+
+make_default_generic()
+{
+ # $1 is vendor-name.desktop
+ # $2 is mime/type
+ # Add $2=$1 to XDG_DATA_HOME/applications/defaults.list
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+ default_file="$xdg_user_dir/applications/defaults.list"
+ DEBUG 2 "make_default_generic $1 $2"
+ DEBUG 1 "Updating $default_file"
+ grep -v "$2=" $default_file > ${default_file}.new 2> /dev/null
+ if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then
+ echo "[Default Applications]" >> ${default_file}.new
+ fi
+ echo $2=$1 >> ${default_file}.new
+ mv ${default_file}.new $default_file
+}
+
+defapp_generic()
+{
+ MIME="$1"
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+ xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+ xdg_system_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+
+ for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
+ DEBUG 2 "Checking $x/applications/defaults.list"
+ trader_result=`grep "$MIME=" $x/applications/defaults.list 2> /dev/null | cut -d '=' -f 2 | cut -d ';' -f 1`
+ if [ -n "$trader_result" ] ; then
+ echo $trader_result
+ exit_success
+ fi
+ done
+ exit_success
+}
+
+defapp_kde()
+{
+ MIME="$1"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ KTRADER=`which ktraderclient 2> /dev/null`
+ MIMETYPE="--mimetype"
+ SERVICETYPE="--servicetype"
+ else
+ KTRADER=`which ktradertest 2> /dev/null`
+ fi
+ if [ -n "$KTRADER" ] ; then
+ DEBUG 1 "Running KDE trader query \"$MIME\" mimetype and \"Application\" servicetype"
+ trader_result=`$KTRADER $MIMETYPE "$MIME" $SERVICETYPE Application 2>/dev/null \
+ | grep DesktopEntryPath | head -n 1 | cut -d ':' -f 2 | cut -d \' -f 2`
+ if [ -n "$trader_result" ] ; then
+ basename "$trader_result"
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ defapp_generic "$1"
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+mode=
+action=
+filename=
+mimetype=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ query)
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "query type argument missing"
+ fi
+
+ case $1 in
+ filetype)
+ action=info
+
+ filename="$2"
+ if [ -z "$filename" ] ; then
+ exit_failure_syntax "FILE argument missing"
+ fi
+ case $filename in
+ -*)
+ exit_failure_syntax "unexpected option '$filename'"
+ ;;
+ esac
+ check_input_file "$filename"
+ ;;
+
+ default)
+ action=defapp
+ mimetype="$2"
+ if [ -z "$mimetype" ] ; then
+ exit_failure_syntax "mimetype argument missing"
+ fi
+ case $mimetype in
+ -*)
+ exit_failure_syntax "unexpected option '$mimetype'"
+ ;;
+
+ */*)
+ # Ok
+ ;;
+
+ *)
+ exit_failure_syntax "mimetype '$mimetype' is not in the form 'minor/major'"
+ ;;
+ esac
+ ;;
+
+ *)
+ exit_failure_syntax "unknown query type '$1'"
+ ;;
+ esac
+ ;;
+
+ default)
+ action=makedefault
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "application argument missing"
+ fi
+ case $1 in
+ -*)
+ exit_failure_syntax "unexpected option '$1'"
+ ;;
+
+ *.desktop)
+ filename="$1"
+ ;;
+
+ *)
+ exit_failure_syntax "malformed argument '$1', expected *.desktop"
+ ;;
+ esac
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+
+if [ "$action" = "makedefault" ]; then
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mimetype argument missing"
+ fi
+
+ while [ $# -gt 0 ] ; do
+ case $1 in
+ -*)
+ exit_failure_syntax "unexpected option '$1'"
+ ;;
+ esac
+ mimetype="$1"
+ shift
+
+ make_default_kde "$filename" "$mimetype"
+ make_default_generic "$filename" "$mimetype"
+ done
+ exit_success
+fi
+
+if [ "$action" = "info" ]; then
+ detectDE
+
+ if [ x"$DE" = x"" ]; then
+ if [ -x /usr/bin/file ]; then
+ DE=generic
+ fi
+ fi
+
+ case "$DE" in
+ kde)
+ info_kde "$filename"
+ ;;
+
+ gnome)
+ info_gnome "$filename"
+ ;;
+
+ *)
+ info_generic "$filename"
+ ;;
+ esac
+ exit_failure_operation_impossible "no method available for quering MIME type of '$filename'"
+fi
+
+if [ "$action" = "defapp" ]; then
+ detectDE
+
+ case "$DE" in
+ kde)
+ defapp_kde "$mimetype"
+ ;;
+
+ *)
+ defapp_generic "$mimetype"
+ ;;
+ esac
+ exit_failure_operation_impossible "no method available for quering default application for '$mimetype'"
+fi
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case $parm in
+ --mode)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mode argument missing for --mode"
+ fi
+ case "$1" in
+ user)
+ mode="user"
+ ;;
+
+ system)
+ mode="system"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown mode '$1'"
+ ;;
+ esac
+ shift
+ ;;
+
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$filename" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+
+ filename="$parm"
+ check_input_file "$filename"
+ ;;
+ esac
+done
+
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
+ mode="system"
+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
+ mode="user"
+ fi
+fi
+
+if [ -z "$mode" ] ; then
+ if [ `whoami` = "root" ] ; then
+ mode="system"
+ else
+ mode="user"
+ fi
+fi
+
+if [ -z "$filename" ] ; then
+ exit_failure_syntax "mimetypes-file argument missing"
+fi
+
+if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$filename"
+fi
+
+xdg_base_dir=
+xdg_dir_name=mime/packages/
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+[ x"$mode" = x"user" ] && xdg_base_dir="$xdg_user_dir/mime"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+for x in `echo $xdg_system_dirs | sed 's/:/ /g'`; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ [ x"$mode" = x"system" ] && xdg_base_dir="$x/mime"
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+[ -w $xdg_global_dir ] || xdg_global_dir=
+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+
+# Find KDE3 mimelnk directory
+kde_user_dir=
+kde_global_dir=
+kde_global_dirs=`kde${KDE_SESSION_VERSION}-config --path mime 2> /dev/null`
+DEBUG 3 "kde_global_dirs: $kde_global_dirs"
+first=
+for x in `echo $kde_global_dirs | sed 's/:/ /g'` ; do
+ if [ -z "$first" ] ; then
+ first=false
+ kde_user_dir="$x"
+ elif [ -w $x ] ; then
+ kde_global_dir="$x"
+ fi
+done
+DEBUG 3 "kde_user_dir: $kde_user_dir"
+DEBUG 3 "kde_global_dir: $kde_global_dir"
+
+# TODO: Gnome legacy support
+# See http://forums.fedoraforum.org/showthread.php?t=26875
+gnome_user_dir="$HOME/.gnome/apps"
+gnome_global_dir=/usr/share/gnome/apps
+[ -w $gnome_global_dir ] || gnome_global_dir=
+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system mimetype directory found."
+ fi
+fi
+
+# echo "[xdg|$xdg_user_dir|$xdg_global_dir]"
+# echo "[kde|$kde_user_dir|$kde_global_dir]"
+# echo "[gnome|$gnome_user_dir|$gnome_global_dir]"
+# echo "[using|$xdg_dir|$kde_dir|$gnome_dir]"
+
+basefile=`basename "$filename"`
+#[ -z $vendor ] || basefile="$vendor-$basefile"
+
+mimetypes=
+if [ -n "$kde_dir" ] ; then
+ DEBUG 2 "KDE3 mimelnk directory found, extracting mimetypes from XML file"
+
+ mimetypes=`awk < "$filename" '
+# Strip XML comments
+BEGIN {
+ suppress=0
+}
+{
+ do
+ if (suppress) {
+ if (match($0,/-->/)) {
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=0
+ }
+ else {
+ break
+ }
+ }
+ else {
+ if (match($0,/<!--/)) {
+ if (RSTART>1) print substr($0,0,RSTART)
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=1
+ }
+ else {
+ if ($0) print $0
+ break
+ }
+ }
+ while(1)
+}
+' | awk '
+# List MIME types listed in <mime-type> tags
+BEGIN {
+ RS="<"
+}
+/^mime-info/, /^\/mime-info/ {
+ if (match($0,/^mime-type/)) {
+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
+ print substr($0,RSTART+6,RLENGTH-6)
+ }
+ }
+}'`
+fi
+
+DEBUG 1 "$action mimetype in $xdg_dir"
+
+case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in $xdg_dir ; do
+ mkdir -p $x
+ eval 'cp $filename $x/$basefile'$xdg_redirect_output
+ done
+
+ if [ -n "$mimetypes" ] ; then
+ # No quotes around $mimetypes
+ for x in $mimetypes ; do
+ DEBUG 1 "Installing $kde_dir/$x.desktop (KDE 3.x support)"
+ mkdir -p `dirname $kde_dir/$x.desktop`
+ awk < "$filename" '
+# Strip XML comments
+BEGIN {
+ suppress=0
+}
+{
+ do
+ if (suppress) {
+ if (match($0,/-->/)) {
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=0
+ }
+ else {
+ break
+ }
+ }
+ else {
+ if (match($0,/<!--/)) {
+ if (RSTART>1) print substr($0,0,RSTART)
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=1
+ }
+ else {
+ if ($0) print $0
+ break
+ }
+ }
+ while(1)
+}
+' | awk > $kde_dir/$x.desktop '
+# Extract mimetype $x from the XML file $filename
+# Note that bash requires us to escape a single quote as '"'"'
+BEGIN {
+ the_type=ARGV[1]
+ the_source=ARGV[2]
+ ARGC=1
+ RS="<"
+ found=0
+ glob_patterns=""
+}
+/^mime-info/, /^\/mime-info/ {
+ if (match($0,/^mime-type/)) {
+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
+ if (substr($0,RSTART+6,RLENGTH-6) == the_type) {
+ found=1
+ print "[Desktop Entry]"
+ print "# Installed by xdg-mime from " the_source
+ print "Type=MimeType"
+ print "MimeType=" the_type
+ the_icon=the_type
+ sub("/", "-", the_icon)
+ print "Icon=" the_icon
+ }
+ }
+ }
+ else if (found) {
+ if (match($0,/^\/mime-type/)) {
+ if (glob_patterns)
+ print "Patterns=" glob_patterns
+ exit 0
+ }
+
+ if (match($0,/^sub-class-of/)) {
+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
+ print "X-KDE-IsAlso=" substr($0,RSTART+6,RLENGTH-6)
+ }
+ else {
+ print "Error: '"'"'type'"'"' argument missing in " RS $0
+ exit 1
+ }
+ }
+ if (match($0,/^glob/)) {
+ if (match($0,/pattern="[^"]*/) || match($0,/pattern='"'"'[^'"'"']*/)) {
+ glob_patterns = glob_patterns substr($0,RSTART+9,RLENGTH-9) ";"
+ }
+ else {
+ print "Error: '"'"'pattern'"'"' argument missing in " RS $0
+ exit 1
+ }
+ }
+ if (match($0,/^comment/)) {
+ if (match($0,/xml:lang="[^"]*/) || match($0,/xml:lang='"'"'[^'"'"']*/)) {
+ lang=substr($0,RSTART+10,RLENGTH-10)
+ }
+ else {
+ lang=""
+ }
+ if (match($0,/>/)) {
+ comment=substr($0,RSTART+1)
+ sub("&lt;", "<", comment)
+ sub("&gt;", ">", comment)
+ sub("&amp;", "\\&", comment)
+ if (lang)
+ print "Comment[" lang "]=" comment
+ else
+ print "Comment=" comment
+ }
+ }
+ }
+}
+END {
+ if (!found) {
+ print "Error: Mimetype '"'"'" the_type "'"'"' not found"
+ exit 1
+ }
+}
+' $x $basefile
+ if [ "$?" = "1" ] ; then
+ grep -A 10 "^Error:" $kde_dir/$x.desktop >&2
+ rm $kde_dir/$x.desktop
+ exit 1
+ fi
+ done
+ fi
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in $xdg_dir ; do
+ rm -f $x/$basefile
+ done
+
+ # No quotes around $mimetypes
+ for x in $mimetypes ; do
+ if grep '^# Installed by xdg-mime' $kde_dir/$x.desktop >/dev/null 2>&1; then
+ DEBUG 1 "Removing $kde_dir/$x.desktop (KDE 3.x support)"
+ rm -f $kde_dir/$x.desktop
+ fi
+ done
+ ;;
+esac
+
+update_mime_database $xdg_base_dir
+
+exit_success
+
diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in
new file mode 100644
index 0000000..2de4657
--- /dev/null
+++ b/scripts/xdg-mime.in
@@ -0,0 +1,918 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-mime
+#
+# Utility script to manipulate MIME related information
+# on XDG compliant systems.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+update_mime_database()
+{
+ if [ x"$mode" = x"user" -a -n "$DISPLAY" ] ; then
+ detectDE
+ if [ x"$DE" = x"kde" ] ; then
+ DEBUG 1 "Running kbuildsycoca"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ eval 'kbuildsycoca4'$xdg_redirect_output
+ else
+ eval 'kbuildsycoca'$xdg_redirect_output
+ fi
+ fi
+ fi
+ for x in `echo "$PATH:/opt/gnome/bin" | sed 's/:/ /g'`; do
+ if [ -x $x/update-mime-database ] ; then
+ DEBUG 1 "Running $x/update-mime-database $1"
+ eval '$x/update-mime-database $1'$xdg_redirect_output
+ return
+ fi
+ done
+}
+
+info_kde()
+{
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ DEBUG 1 "Running kmimetypefinder \"$1\""
+ kmimetypefinder "$1" 2>/dev/null | head -n 1
+ else
+ DEBUG 1 "Running kfile \"$1\""
+ kfile "$1" 2> /dev/null | head -n 1 | cut -d "(" -f 2 | cut -d ")" -f 1
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+info_gnome()
+{
+ if gvfs-info --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gvfs-info \"$1\""
+ gvfs-info "$1" 2> /dev/null | grep standard::content-type | cut -d' ' -f4
+ elif gnomevfs-info --help 2>/dev/null 1>&2; then
+ DEBUG 1 "Running gnomevfs-info \"$1\""
+ gnomevfs-info --slow-mime "$1" 2> /dev/null | grep "^MIME" | cut -d ":" -f 2 | sed s/"^ "//
+ else
+ # according to https://bugs.freedesktop.org/show_bug.cgi?id=33094#c5
+ # neither gvfs-info or gnomevfs-info are present in a default Ubuntu Natty
+ # install, so fallback to info_generic
+ info_generic "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+info_generic()
+{
+ if mimetype --version >/dev/null 2>&1; then
+ DEBUG 1 "Running mimetype -b \"$1\""
+ mimetype -b "$1"
+ else
+ DEBUG 1 "Running file --mime-type \"$1\""
+ /usr/bin/file --mime-type "$1" 2> /dev/null | cut -d ":" -f 2 | sed s/"^ "//
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+make_default_kde()
+{
+ # $1 is vendor-name.desktop
+ # $2 is mime/type
+ #
+ # On KDE 3, add to $KDE_CONFIG_PATH/profilerc:
+ # [$2 - 1]
+ # Application=$1
+ #
+ # Remove all [$2 - *] sections, or even better,
+ # renumber [$2 - *] sections and remove duplicate
+ #
+ # On KDE 4, add $2=$1 to $XDG_DATA_APPS/mimeapps.list
+ #
+ # Example file:
+ #
+ # [Added Associations]
+ # text/plain=kde4-kate.desktop;kde4-kwrite.desktop;
+ #
+ # [Removed Associations]
+ # text/plain=gnome-gedit.desktop;gnu-emacs.desktop;
+ vendor="$1"
+ mimetype="$2"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ default_dir=`kde4-config --path xdgdata-apps 2> /dev/null | cut -d ':' -f 1`
+ default_file="$default_dir/mimeapps.list"
+ else
+ default_dir=`kde-config --path config 2> /dev/null | cut -d ':' -f 1`
+ default_file="$default_dir/profilerc"
+ fi
+ if [ -z "$default_dir" ]; then
+ DEBUG 2 "make_default_kde: No kde runtime detected"
+ return
+ fi
+ DEBUG 2 "make_default_kde $vendor $mimetype"
+ DEBUG 1 "Updating $default_file"
+ mkdir -p "$default_dir"
+ [ -f "$default_file" ] || touch "$default_file"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ [ -f "$default_file" ] || touch "$default_file"
+ awk -v application="$vendor" -v mimetype="$mimetype" '
+ BEGIN {
+ prefix=mimetype "="
+ associations=0
+ found=0
+ blanks=0
+ }
+ {
+ suppress=0
+ if (index($0, "[Added Associations]") == 1) {
+ associations=1
+ } else if (index($0, "[") == 1) {
+ if (associations && !found) {
+ print prefix application
+ found=1
+ }
+ associations=0
+ } else if ($0 == "") {
+ blanks++
+ suppress=1
+ } else if (associations && index($0, prefix) == 1) {
+ value=substr($0, length(prefix) + 1, length)
+ split(value, apps, ";")
+ value=application ";"
+ count=0
+ for (i in apps) {
+ count++
+ }
+ for (i=0; i < count; i++) {
+ if (apps[i] != application && apps[i] != "") {
+ value=value apps[i] ";"
+ }
+ }
+ $0=prefix value
+ found=1
+ }
+ if (!suppress) {
+ while (blanks > 0) {
+ print ""
+ blanks--
+ }
+ print $0
+ }
+ }
+ END {
+ if (!found) {
+ if (!associations) {
+ print "[Added Associations]"
+ }
+ print prefix application
+ }
+ while (blanks > 0) {
+ print ""
+ blanks--
+ }
+ }
+' "$default_file" > "${default_file}.new" && mv "${default_file}.new" "$default_file"
+ eval 'kbuildsycoca4'$xdg_redirect_output
+ else
+ awk -v application="$vendor" -v mimetype="$mimetype" '
+ BEGIN {
+ header_start="[" mimetype " - "
+ suppress=0
+ }
+ {
+ if (index($0, header_start) == 1 )
+ suppress=1
+ else
+ if (/^\[/) { suppress=0 }
+
+ if (!suppress) {
+ print $0
+ }
+ }
+ END {
+ print ""
+ print "[" mimetype " - 1]"
+ print "Application=" application
+ print "AllowAsDefault=true"
+ print "GenericServiceType=Application"
+ print "Preference=1"
+ print "ServiceType=" mimetype
+ }
+' "$default_file" > "${default_file}.new" && mv "${default_file}.new" "$default_file"
+ fi
+}
+
+make_default_generic()
+{
+ # $1 is vendor-name.desktop
+ # $2 is mime/type
+ # Add $2=$1 to XDG_DATA_HOME/applications/mimeapps.list
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+ default_file="$xdg_user_dir/applications/mimeapps.list"
+ DEBUG 2 "make_default_generic $1 $2"
+ DEBUG 1 "Updating $default_file"
+ [ -f "$default_file" ] || touch "$default_file"
+ awk -v mimetype="$2" -v application="$1" '
+ BEGIN {
+ prefix=mimetype "="
+ indefault=0
+ added=0
+ blanks=0
+ found=0
+ }
+ {
+ suppress=0
+ if (index($0, "[Default Applications]") == 1) {
+ indefault=1
+ found=1
+ } else if (index($0, "[") == 1) {
+ if (!added && indefault) {
+ print prefix application
+ added=1
+ }
+ indefault=0
+ } else if ($0 == "") {
+ suppress=1
+ blanks++
+ } else if (indefault && !added && index($0, prefix) == 1) {
+ $0=prefix application
+ added=1
+ }
+ if (!suppress) {
+ while (blanks > 0) {
+ print ""
+ blanks--
+ }
+ print $0
+ }
+ }
+ END {
+ if (!added) {
+ if (!found) {
+ print ""
+ print "[Default Applications]"
+ }
+ print prefix application
+ }
+ while (blanks > 0) {
+ print ""
+ blanks--
+ }
+ }
+' "$default_file" > "${default_file}.new" && mv "${default_file}.new" "$default_file"
+}
+
+search_desktop_file()
+{
+ local MIME="$1"
+ local dir="$2"
+
+ grep -l "$MIME;" "$dir/"*.desktop 2>/dev/null
+
+ for f in $dir/*/; do
+ [ -d "$f" ] && search_desktop_file "$MIME" "$f"
+ done
+}
+
+defapp_fallback()
+{
+ MIME="$1"
+
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+
+ xdg_system_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+
+ preference=-1
+ desktop_file=""
+ for d in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
+ for x in `search_desktop_file "$MIME" "$d/applications"`; do
+ pref=0`awk -F"=" '/InitialPreference=/ {print($2)}' "$x"`
+ DEBUG 2 " Checking $x"
+
+ if [ $pref -gt $preference ]; then
+ DEBUG 2 " Select $x [ $preference => $pref ]"
+ preference=$pref
+ desktop_file=$x
+ fi
+ done
+ done
+
+ if [ -n "$desktop_file" ] ; then
+ echo `basename $desktop_file`
+ exit_success
+ fi
+}
+
+defapp_generic()
+{
+ MIME="$1"
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+ xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+ xdg_system_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+
+ for x in `echo "$xdg_user_dir" | sed 's/:/ /g'`; do
+ mimeapps_list="$x/applications/mimeapps.list"
+ if [ -f "$mimeapps_list" ] ; then
+ DEBUG 2 "Checking $mimeapps_list"
+ trader_result=`awk -v mimetype="$MIME" '
+ BEGIN {
+ prefix=mimetype "="
+ indefault=0
+ found=0
+ }
+ {
+ if (index($0, "[Default Applications]") == 1) {
+ indefault=1
+ } else if (index($0, "[") == 1) {
+ indefault=0
+ } else if (!found && indefault && index($0, prefix) == 1) {
+ print substr($0, length(prefix) +1, length)
+ found=1
+ }
+ }
+' $mimeapps_list`
+ if [ -n "$trader_result" ] ; then
+ echo $trader_result
+ exit_success
+ fi
+ fi
+ done
+
+ for x in `echo "$xdg_system_dirs" | sed 's/:/ /g'`; do
+ for prefix in "$XDG_MENU_PREFIX" ""; do
+ DEBUG 2 "Checking $x/applications/${prefix}defaults.list"
+ trader_result=`grep "$MIME=" $x/applications/${prefix}defaults.list 2> /dev/null | cut -d '=' -f 2 | cut -d ';' -f 1`
+ if [ -n "$trader_result" ] ; then
+ echo $trader_result
+ exit_success
+ fi
+ done
+ done
+
+ defapp_fallback $MIME
+ exit_success
+}
+
+defapp_kde()
+{
+ MIME="$1"
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ KTRADER=`which ktraderclient 2> /dev/null`
+ MIMETYPE="--mimetype"
+ SERVICETYPE="--servicetype"
+ else
+ KTRADER=`which ktradertest 2> /dev/null`
+ fi
+ if [ -n "$KTRADER" ] ; then
+ DEBUG 1 "Running KDE trader query \"$MIME\" mimetype and \"Application\" servicetype"
+ trader_result=`$KTRADER $MIMETYPE "$MIME" $SERVICETYPE Application 2>/dev/null \
+ | grep DesktopEntryPath | head -n 1 | cut -d ':' -f 2 | cut -d \' -f 2`
+ if [ -n "$trader_result" ] ; then
+ basename "$trader_result"
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ defapp_generic "$1"
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+mode=
+action=
+filename=
+mimetype=
+
+case $1 in
+ install)
+ action=install
+ ;;
+
+ uninstall)
+ action=uninstall
+ ;;
+
+ query)
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "query type argument missing"
+ fi
+
+ case $1 in
+ filetype)
+ action=info
+
+ filename="$2"
+ if [ -z "$filename" ] ; then
+ exit_failure_syntax "FILE argument missing"
+ fi
+ case $filename in
+ -*)
+ exit_failure_syntax "unexpected option '$filename'"
+ ;;
+ esac
+ check_input_file "$filename"
+ filename=`readlink -f -- "$filename"`
+ ;;
+
+ default)
+ action=defapp
+ mimetype="$2"
+ if [ -z "$mimetype" ] ; then
+ exit_failure_syntax "mimetype argument missing"
+ fi
+ case $mimetype in
+ -*)
+ exit_failure_syntax "unexpected option '$mimetype'"
+ ;;
+
+ */*)
+ # Ok
+ ;;
+
+ *)
+ exit_failure_syntax "mimetype '$mimetype' is not in the form 'minor/major'"
+ ;;
+ esac
+ ;;
+
+ *)
+ exit_failure_syntax "unknown query type '$1'"
+ ;;
+ esac
+ ;;
+
+ default)
+ action=makedefault
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "application argument missing"
+ fi
+ case $1 in
+ -*)
+ exit_failure_syntax "unexpected option '$1'"
+ ;;
+
+ *.desktop)
+ filename="$1"
+ ;;
+
+ *)
+ exit_failure_syntax "malformed argument '$1', expected *.desktop"
+ ;;
+ esac
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+shift
+
+
+if [ "$action" = "makedefault" ]; then
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mimetype argument missing"
+ fi
+
+ while [ $# -gt 0 ] ; do
+ case $1 in
+ -*)
+ exit_failure_syntax "unexpected option '$1'"
+ ;;
+ esac
+ mimetype="$1"
+ shift
+
+ make_default_kde "$filename" "$mimetype"
+ make_default_generic "$filename" "$mimetype"
+ done
+ exit_success
+fi
+
+if [ "$action" = "info" ]; then
+ detectDE
+
+ if [ x"$DE" = x"" ]; then
+ if [ -x /usr/bin/file ]; then
+ DE=generic
+ fi
+ fi
+
+ case "$DE" in
+ kde)
+ info_kde "$filename"
+ ;;
+
+ gnome*)
+ info_gnome "$filename"
+ ;;
+
+ *)
+ info_generic "$filename"
+ ;;
+ esac
+ exit_failure_operation_impossible "no method available for quering MIME type of '$filename'"
+fi
+
+if [ "$action" = "defapp" ]; then
+ detectDE
+
+ case "$DE" in
+ kde)
+ defapp_kde "$mimetype"
+ ;;
+
+ *)
+ defapp_generic "$mimetype"
+ ;;
+ esac
+ exit_failure_operation_impossible "no method available for quering default application for '$mimetype'"
+fi
+
+vendor=true
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case $parm in
+ --mode)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "mode argument missing for --mode"
+ fi
+ case "$1" in
+ user)
+ mode="user"
+ ;;
+
+ system)
+ mode="system"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown mode '$1'"
+ ;;
+ esac
+ shift
+ ;;
+
+ --novendor)
+ vendor=false
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$filename" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+
+ filename="$parm"
+ check_input_file "$filename"
+ ;;
+ esac
+done
+
+if [ -z "$action" ] ; then
+ exit_failure_syntax "command argument missing"
+fi
+
+if [ -n "$XDG_UTILS_INSTALL_MODE" ] ; then
+ if [ "$XDG_UTILS_INSTALL_MODE" = "system" ] ; then
+ mode="system"
+ elif [ "$XDG_UTILS_INSTALL_MODE" = "user" ] ; then
+ mode="user"
+ fi
+fi
+
+if [ -z "$mode" ] ; then
+ if [ `whoami` = "root" ] ; then
+ mode="system"
+ else
+ mode="user"
+ fi
+fi
+
+if [ -z "$filename" ] ; then
+ exit_failure_syntax "mimetypes-file argument missing"
+fi
+
+if [ "$vendor" = "true" -a "$action" = "install" ] ; then
+ check_vendor_prefix "$filename"
+fi
+
+xdg_base_dir=
+xdg_dir_name=mime/packages/
+
+xdg_user_dir="$XDG_DATA_HOME"
+[ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+[ x"$mode" = x"user" ] && xdg_base_dir="$xdg_user_dir/mime"
+xdg_user_dir="$xdg_user_dir/$xdg_dir_name"
+
+xdg_system_dirs="$XDG_DATA_DIRS"
+[ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+for x in `echo $xdg_system_dirs | sed 's/:/ /g'`; do
+ if [ -w $x/$xdg_dir_name ] ; then
+ [ x"$mode" = x"system" ] && xdg_base_dir="$x/mime"
+ xdg_global_dir="$x/$xdg_dir_name"
+ break
+ fi
+done
+[ -w $xdg_global_dir ] || xdg_global_dir=
+DEBUG 3 "xdg_user_dir: $xdg_user_dir"
+DEBUG 3 "xdg_global_dir: $xdg_global_dir"
+
+# Find KDE3 mimelnk directory
+kde_user_dir=
+kde_global_dir=
+kde_global_dirs=`kde${KDE_SESSION_VERSION}-config --path mime 2> /dev/null`
+DEBUG 3 "kde_global_dirs: $kde_global_dirs"
+first=
+for x in `echo $kde_global_dirs | sed 's/:/ /g'` ; do
+ if [ -z "$first" ] ; then
+ first=false
+ kde_user_dir="$x"
+ elif [ -w $x ] ; then
+ kde_global_dir="$x"
+ fi
+done
+DEBUG 3 "kde_user_dir: $kde_user_dir"
+DEBUG 3 "kde_global_dir: $kde_global_dir"
+
+# TODO: Gnome legacy support
+# See http://forums.fedoraforum.org/showthread.php?t=26875
+gnome_user_dir="$HOME/.gnome/apps"
+gnome_global_dir=/usr/share/gnome/apps
+[ -w $gnome_global_dir ] || gnome_global_dir=
+DEBUG 3 "gnome_user_dir: $gnome_user_dir"
+DEBUG 3 "gnome_global_dir: $gnome_global_dir"
+
+if [ x"$mode" = x"user" ] ; then
+ xdg_dir="$xdg_user_dir"
+ kde_dir="$kde_user_dir"
+ gnome_dir="$gnome_user_dir"
+ my_umask=077
+else
+ xdg_dir="$xdg_global_dir"
+ kde_dir="$kde_global_dir"
+ gnome_dir="$gnome_global_dir"
+ my_umask=022
+ if [ -z "${xdg_dir}${kde_dir}${gnome_dir}" ] ; then
+ exit_failure_operation_impossible "No writable system mimetype directory found."
+ fi
+fi
+
+# echo "[xdg|$xdg_user_dir|$xdg_global_dir]"
+# echo "[kde|$kde_user_dir|$kde_global_dir]"
+# echo "[gnome|$gnome_user_dir|$gnome_global_dir]"
+# echo "[using|$xdg_dir|$kde_dir|$gnome_dir]"
+
+basefile=`basename "$filename"`
+#[ -z $vendor ] || basefile="$vendor-$basefile"
+
+mimetypes=
+if [ -n "$kde_dir" ] ; then
+ DEBUG 2 "KDE3 mimelnk directory found, extracting mimetypes from XML file"
+
+ mimetypes=`awk < "$filename" '
+# Strip XML comments
+BEGIN {
+ suppress=0
+}
+{
+ do
+ if (suppress) {
+ if (match($0,/-->/)) {
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=0
+ }
+ else {
+ break
+ }
+ }
+ else {
+ if (match($0,/<!--/)) {
+ if (RSTART>1) print substr($0,0,RSTART)
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=1
+ }
+ else {
+ if ($0) print $0
+ break
+ }
+ }
+ while(1)
+}
+' | awk '
+# List MIME types listed in <mime-type> tags
+BEGIN {
+ RS="<"
+}
+/^mime-info/, /^\/mime-info/ {
+ if (match($0,/^mime-type/)) {
+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
+ print substr($0,RSTART+6,RLENGTH-6)
+ }
+ }
+}'`
+fi
+
+DEBUG 1 "$action mimetype in $xdg_dir"
+
+case $action in
+ install)
+ save_umask=`umask`
+ umask $my_umask
+
+ for x in $xdg_dir ; do
+ mkdir -p $x
+ eval 'cp $filename $x/$basefile'$xdg_redirect_output
+ done
+
+ if [ -n "$mimetypes" ] ; then
+ # No quotes around $mimetypes
+ for x in $mimetypes ; do
+ DEBUG 1 "Installing $kde_dir/$x.desktop (KDE 3.x support)"
+ mkdir -p `dirname $kde_dir/$x.desktop`
+ awk < "$filename" '
+# Strip XML comments
+BEGIN {
+ suppress=0
+}
+{
+ do
+ if (suppress) {
+ if (match($0,/-->/)) {
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=0
+ }
+ else {
+ break
+ }
+ }
+ else {
+ if (match($0,/<!--/)) {
+ if (RSTART>1) print substr($0,0,RSTART)
+ $0=substr($0,RSTART+RLENGTH)
+ suppress=1
+ }
+ else {
+ if ($0) print $0
+ break
+ }
+ }
+ while(1)
+}
+' | awk > $kde_dir/$x.desktop '
+# Extract mimetype $x from the XML file $filename
+# Note that bash requires us to escape a single quote as '"'"'
+BEGIN {
+ the_type=ARGV[1]
+ the_source=ARGV[2]
+ ARGC=1
+ RS="<"
+ found=0
+ glob_patterns=""
+}
+/^mime-info/, /^\/mime-info/ {
+ if (match($0,/^mime-type/)) {
+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
+ if (substr($0,RSTART+6,RLENGTH-6) == the_type) {
+ found=1
+ print "[Desktop Entry]"
+ print "# Installed by xdg-mime from " the_source
+ print "Type=MimeType"
+ print "MimeType=" the_type
+ the_icon=the_type
+ sub("/", "-", the_icon)
+ print "Icon=" the_icon
+ }
+ }
+ }
+ else if (found) {
+ if (match($0,/^\/mime-type/)) {
+ if (glob_patterns)
+ print "Patterns=" glob_patterns
+ exit 0
+ }
+
+ if (match($0,/^sub-class-of/)) {
+ if (match($0,/type="[^"]*/) || match($0,/type='"'"'[^'"'"']*/)) {
+ print "X-KDE-IsAlso=" substr($0,RSTART+6,RLENGTH-6)
+ }
+ else {
+ print "Error: '"'"'type'"'"' argument missing in " RS $0
+ exit 1
+ }
+ }
+ if (match($0,/^glob/)) {
+ if (match($0,/pattern="[^"]*/) || match($0,/pattern='"'"'[^'"'"']*/)) {
+ glob_patterns = glob_patterns substr($0,RSTART+9,RLENGTH-9) ";"
+ }
+ else {
+ print "Error: '"'"'pattern'"'"' argument missing in " RS $0
+ exit 1
+ }
+ }
+ if (match($0,/^comment/)) {
+ if (match($0,/xml:lang="[^"]*/) || match($0,/xml:lang='"'"'[^'"'"']*/)) {
+ lang=substr($0,RSTART+10,RLENGTH-10)
+ }
+ else {
+ lang=""
+ }
+ if (match($0,/>/)) {
+ comment=substr($0,RSTART+1)
+ sub("&lt;", "<", comment)
+ sub("&gt;", ">", comment)
+ sub("&amp;", "\\&", comment)
+ if (lang)
+ print "Comment[" lang "]=" comment
+ else
+ print "Comment=" comment
+ }
+ }
+ }
+}
+END {
+ if (!found) {
+ print "Error: Mimetype '"'"'" the_type "'"'"' not found"
+ exit 1
+ }
+}
+' $x $basefile
+ if [ "$?" = "1" ] ; then
+ grep -A 10 "^Error:" $kde_dir/$x.desktop >&2
+ rm $kde_dir/$x.desktop
+ exit 1
+ fi
+ done
+ fi
+
+ umask $save_umask
+ ;;
+
+ uninstall)
+ for x in $xdg_dir ; do
+ rm -f $x/$basefile
+ done
+
+ # No quotes around $mimetypes
+ for x in $mimetypes ; do
+ if grep '^# Installed by xdg-mime' $kde_dir/$x.desktop >/dev/null 2>&1; then
+ DEBUG 1 "Removing $kde_dir/$x.desktop (KDE 3.x support)"
+ rm -f $kde_dir/$x.desktop
+ fi
+ done
+ ;;
+esac
+
+update_mime_database $xdg_base_dir
+
+exit_success
+
diff --git a/scripts/xdg-open b/scripts/xdg-open
new file mode 100755
index 0000000..fee4204
--- /dev/null
+++ b/scripts/xdg-open
@@ -0,0 +1,558 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-open
+#
+# Utility script to open a URL in the registered default application.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-open - opens a file or URL in the user's preferred application
+
+Synopsis
+
+xdg-open { file | URL }
+
+xdg-open { --help | --manual | --version }
+
+Description
+
+xdg-open opens a file or URL in the user's preferred application. If a URL is
+provided the URL will be opened in the user's preferred web browser. If a file
+is provided the file will be opened in the preferred application for files of
+that type. xdg-open supports file, ftp, http and https URLs.
+
+xdg-open is for use inside a desktop session only. It is not recommended to use
+xdg-open as root.
+
+Options
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+
+Examples
+
+xdg-open 'http://www.freedesktop.org/'
+
+Opens the Freedesktop.org website in the user's default browser
+
+xdg-open /tmp/foobar.png
+
+Opens the PNG image file /tmp/foobar.png in the user's default image viewing
+application.
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-open - opens a file or URL in the user's preferred application
+
+Synopsis
+
+xdg-open { file | URL }
+
+xdg-open { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-open: $@" >&2
+ echo "Try 'xdg-open --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-open' or 'xdg-open --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-open: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-open: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-open: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-open: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-open: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-open: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-open --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-open' or 'xdg-open --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-open 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+# This handles backslashes but not quote marks.
+first_word()
+{
+ read first rest
+ echo "$first"
+}
+
+open_kde()
+{
+ if kde-open -v 2>/dev/null 1>&2; then
+ kde-open "$1"
+ else
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ kfmclient openURL "$1"
+ else
+ kfmclient exec "$1"
+ kfmclient_fix_exit_code $?
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_gnome()
+{
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ gvfs-open "$1"
+ else
+ gnome-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_xfce()
+{
+ exo-open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_generic_xdg_mime()
+{
+ filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+ default=`xdg-mime query default "$filetype"`
+ if [ -n "$default" ] ; then
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+
+ xdg_system_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+
+ for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
+ local file="$x/applications/$default"
+ if [ -r "$file" ] ; then
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command_exec=`which $command 2>/dev/null`
+ if [ -x "$command_exec" ] ; then
+ $command_exec "$1"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+ fi
+ done
+ fi
+}
+
+open_generic()
+{
+ # Paths or file:// URLs
+ if (echo "$1" | grep -q '^file://' ||
+ ! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
+
+ local file="$1"
+
+ # Decode URLs
+ if echo "$file" | grep -q '^file:///'; then
+ file=${file#file://}
+ file="$(printf "$(echo "$file" | sed -e 's@%\([a-f0-9A-F]\{2\}\)@\\x\1@g')")"
+ fi
+ check_input_file "$file"
+
+ open_generic_xdg_mime "$file"
+
+ if [ -f /etc/debian_version ] &&
+ which run-mailcap 2>/dev/null 1>&2; then
+ run-mailcap --action=view "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+
+ if mimeopen -v 2>/dev/null 1>&2; then
+ mimeopen -L -n "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+ fi
+
+ IFS=":"
+ for browser in $BROWSER; do
+ if [ x"$browser" != x"" ]; then
+
+ browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
+ if [ $? -ne 0 ]; then
+ browser_with_arg=$browser;
+ fi
+
+ if [ x"$browser_with_arg" = x"$browser" ]; then
+ "$browser" "$1";
+ else eval '$browser_with_arg'$xdg_redirect_output;
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success;
+ fi
+ fi
+ done
+
+ exit_failure_operation_impossible "no method available for opening '$1'"
+}
+
+open_lxde()
+{
+ # pcmanfm only knows how to handle file:// urls and filepaths, it seems.
+ if (echo "$1" | grep -q '^file://' ||
+ ! echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:')
+ then
+ local file="$(echo "$1" | sed 's%^file://%%')"
+
+ # handle relative paths
+ if ! echo "$file" | grep -q '^/'; then
+ file="$(pwd)/$file"
+ fi
+
+ pcmanfm "$file"
+
+ else
+ open_generic "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+url=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$url" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ url="$parm"
+ ;;
+ esac
+done
+
+if [ -z "${url}" ] ; then
+ exit_failure_syntax "file or URL argument missing"
+fi
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ DE=generic
+fi
+
+# if BROWSER variable is not set, check some well known browsers instead
+if [ x"$BROWSER" = x"" ]; then
+ BROWSER=links2:links:lynx:w3m
+ if [ -n "$DISPLAY" ]; then
+ BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
+ fi
+fi
+
+case "$DE" in
+ kde)
+ open_kde "$url"
+ ;;
+
+ gnome)
+ open_gnome "$url"
+ ;;
+
+ xfce)
+ open_xfce "$url"
+ ;;
+
+ lxde)
+ open_lxde "$url"
+ ;;
+
+ generic)
+ open_generic "$url"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening '$url'"
+ ;;
+esac
diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
new file mode 100644
index 0000000..771cc6b
--- /dev/null
+++ b/scripts/xdg-open.in
@@ -0,0 +1,348 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-open
+#
+# Utility script to open a URL in the registered default application.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+# This handles backslashes but not quote marks.
+first_word()
+{
+ read first rest
+ echo "$first"
+}
+
+last_word()
+{
+ read first rest
+ echo "$rest"
+}
+
+open_darwin()
+{
+ open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_kde()
+{
+ if kde-open -v 2>/dev/null 1>&2; then
+ kde-open "$1"
+ else
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ kfmclient openURL "$1"
+ else
+ kfmclient exec "$1"
+ kfmclient_fix_exit_code $?
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_gnome()
+{
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ gvfs-open "$1"
+ else
+ gnome-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_mate()
+{
+ if gvfs-open --help 2>/dev/null 1>&2; then
+ gvfs-open "$1"
+ else
+ mate-open "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+open_xfce()
+{
+ exo-open "$1"
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+#-----------------------------------------
+# Recursively search .desktop file
+
+search_desktop_file()
+{
+ local default="$1"
+ local dir="$2"
+ local arg="$3"
+
+ local file=""
+ # look for both vendor-app.desktop, vendor/app.desktop
+ if [ -r "$dir/$default" ]; then
+ file="$dir/$default"
+ elif [ -r "$dir/`echo $default | sed -e 's|-|/|'`" ]; then
+ file="$dir/`echo $default | sed -e 's|-|/|'`"
+ fi
+
+ if [ -r "$file" ] ; then
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command_exec=`which $command 2>/dev/null`
+ arguments="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | last_word`"
+ arg_one="`echo $arg | sed 's/&/\\\\&/g'`"
+ arguments_exec="`echo $arguments | sed -e 's*%[fFuU]*"'"$arg_one"'"*g'`"
+
+ if [ -x "$command_exec" ] ; then
+ if echo $arguments | grep -iq '%[fFuU]' ; then
+ echo START $command_exec $arguments_exec
+ eval $command_exec $arguments_exec
+ else
+ echo START $command_exec $arguments_exec "$arg"
+ eval $command_exec $arguments_exec "$arg"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+ fi
+
+ for d in $dir/*/; do
+ [ -d "$d" ] && search_desktop_file "$default" "$d" "$arg"
+ done
+}
+
+
+open_generic_xdg_mime()
+{
+ filetype="$2"
+ default=`xdg-mime query default "$filetype"`
+ if [ -n "$default" ] ; then
+ xdg_user_dir="$XDG_DATA_HOME"
+ [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"
+
+ xdg_system_dirs="$XDG_DATA_DIRS"
+ [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/
+
+DEBUG 3 "$xdg_user_dir:$xdg_system_dirs"
+ for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
+ search_desktop_file "$default" "$x/applications/" "$1"
+ done
+ fi
+}
+
+open_generic_xdg_file_mime()
+{
+ filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+ open_generic_xdg_mime "$1" "$filetype"
+}
+
+open_generic_xdg_x_scheme_handler()
+{
+ scheme="`echo $1 | sed -n 's/\(^[[:alnum:]+\.-]*\):.*$/\1/p'`"
+ if [ -n $scheme ]; then
+ filetype="x-scheme-handler/$scheme"
+ open_generic_xdg_mime "$1" "$filetype"
+ fi
+}
+
+open_generic()
+{
+ # Paths or file:// URLs
+ if (echo "$1" | grep -q '^file://' ||
+ ! echo "$1" | egrep -q '^[[:alpha:]+\.\-]+:'); then
+
+ local file="$1"
+
+ # Decode URLs
+ if echo "$file" | grep -q '^file:///'; then
+ file=${file#file://}
+ file="$(printf "$(echo "$file" | sed -e 's@%\([a-f0-9A-F]\{2\}\)@\\x\1@g')")"
+ fi
+ check_input_file "$file"
+
+ open_generic_xdg_file_mime "$file"
+
+ if [ -f /etc/debian_version ] &&
+ which run-mailcap 2>/dev/null 1>&2; then
+ run-mailcap --action=view "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+
+ if mimeopen -v 2>/dev/null 1>&2; then
+ mimeopen -L -n "$file"
+ if [ $? -eq 0 ]; then
+ exit_success
+ fi
+ fi
+ fi
+
+ open_generic_xdg_x_scheme_handler "$1"
+
+ IFS=":"
+ for browser in $BROWSER; do
+ if [ x"$browser" != x"" ]; then
+
+ browser_with_arg=`printf "$browser" "$1" 2>/dev/null`
+ if [ $? -ne 0 ]; then
+ browser_with_arg=$browser;
+ fi
+
+ if [ x"$browser_with_arg" = x"$browser" ]; then
+ eval '$browser $1'$xdg_redirect_output;
+ else eval '$browser_with_arg'$xdg_redirect_output;
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success;
+ fi
+ fi
+ done
+
+ exit_failure_operation_impossible "no method available for opening '$1'"
+}
+
+open_lxde()
+{
+ # pcmanfm only knows how to handle file:// urls and filepaths, it seems.
+ if (echo "$1" | grep -q '^file://' ||
+ ! echo "$1" | egrep -q '^[[:alpha:]+\.\-]+:')
+ then
+ local file="$(echo "$1" | sed 's%^file://%%')"
+
+ # handle relative paths
+ if ! echo "$file" | grep -q '^/'; then
+ file="$(pwd)/$file"
+ fi
+
+ pcmanfm "$file"
+
+ else
+ open_generic "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+url=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$url" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ url="$parm"
+ ;;
+ esac
+done
+
+if [ -z "${url}" ] ; then
+ exit_failure_syntax "file or URL argument missing"
+fi
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ DE=generic
+fi
+
+DEBUG 2 "Selected DE $DE"
+
+# if BROWSER variable is not set, check some well known browsers instead
+if [ x"$BROWSER" = x"" ]; then
+ BROWSER=links2:elinks:links:lynx:w3m
+ if [ -n "$DISPLAY" ]; then
+ BROWSER=x-www-browser:firefox:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
+ fi
+fi
+
+case "$DE" in
+ kde)
+ open_kde "$url"
+ ;;
+
+ gnome*)
+ open_gnome "$url"
+ ;;
+
+ mate)
+ open_mate "$url"
+ ;;
+
+ xfce)
+ open_xfce "$url"
+ ;;
+
+ lxde)
+ open_lxde "$url"
+ ;;
+
+ generic)
+ open_generic "$url"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no method available for opening '$url'"
+ ;;
+esac
diff --git a/scripts/xdg-screensaver b/scripts/xdg-screensaver
new file mode 100755
index 0000000..2757c5b
--- /dev/null
+++ b/scripts/xdg-screensaver
@@ -0,0 +1,938 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-screensaver
+#
+# Utility script to control screensaver.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2006, Bryce Harrington <bryce@osdl.org>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-screensaver - command line tool for controlling the screensaver
+
+Synopsis
+
+xdg-screensaver suspend WindowID
+
+xdg-screensaver resume WindowID
+
+xdg-screensaver { activate | lock | reset | status }
+
+xdg-screensaver { --help | --manual | --version }
+
+Description
+
+xdg-screensaver provides commands to control the screensaver.
+
+xdg-screensaver is for use inside a desktop session only. It is not recommended
+to use xdg-screensaver as root.
+
+Commands
+
+suspend WindowID
+
+ Suspends the screensaver and monitor power management. WindowID must be the
+ X Window ID of an existing window of the calling application. The window
+ must remain in existance for the duration of the suspension.
+
+ WindowID can be represented as either a decimal number or as a hexadecimal
+ number consisting of the prefix 0x followed by one or more hexadecimal
+ digits.
+
+ The screensaver can be suspended in relation to multiple windows at the
+ same time. In that case screensaver operation is only restored once the
+ screensaver has been resumed in relation to each of the windows
+
+resume WindowID
+ Resume the screensaver and monitor power management after being suspended.
+ WindowID must be the same X Window ID that was passed to a previous call of
+ xdg-screensaver suspend
+activate
+ Turns the screensaver on immediately. This may result in the screen getting
+ locked, depending on existing system policies.
+lock
+ Lock the screen immediately.
+reset
+ Turns the screensaver off immediately. If the screen was locked the user
+ may be asked to authenticate first.
+status
+ Prints enabled to stdout if the screensaver is enabled to turn on after a
+ period of inactivity and prints disabled if the screensaver is not enabled.
+
+Options
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+3
+ A required tool could not be found.
+4
+ The action failed.
+
+Examples
+
+xdg-screensaver suspend 0x1c00007
+
+Causes the screensaver to be disabled till xdg-screensaver resume 0x1c00007 is
+called. 0x1c00007 must be the X Window ID of an existing window.
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-screensaver - command line tool for controlling the screensaver
+
+Synopsis
+
+xdg-screensaver suspend WindowID
+
+xdg-screensaver resume WindowID
+
+xdg-screensaver { activate | lock | reset | status }
+
+xdg-screensaver { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-screensaver: $@" >&2
+ echo "Try 'xdg-screensaver --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-screensaver' or 'xdg-screensaver --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-screensaver: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-screensaver: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-screensaver: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-screensaver: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-screensaver: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-screensaver: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-screensaver --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-screensaver' or 'xdg-screensaver --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-screensaver 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+# Check if we can use "mv -T"
+if mv -T ... ... 2>&1 | grep '\.\.\.' > /dev/null ; then
+ # We can securely move files in /tmp with mv -T
+ DEBUG 1 "mv -T available"
+ MV="mv -T"
+ screensaver_file="/tmp/xdg-screensaver-$USER-"`echo $DISPLAY | sed 's/:/-/g'`
+else
+ # No secure moves available, use home dir
+ DEBUG 1 "mv -T not available"
+ MV="mv"
+ screensaver_file="$HOME/.xdg-screensaver-"`echo $(hostname)-$DISPLAY | sed 's/:/-/g'`
+fi
+lockfile_command=`which lockfile 2> /dev/null`
+
+lockfile()
+{
+ if [ -n "$lockfile_command" ] ; then
+ $lockfile_command -1 -l 10 -s 3 "$screensaver_file".lock
+ else
+ # Poor man's attempt at doing a lockfile
+ # Be careful not to facilitate a symlink attack
+ local try
+ try=0
+ while ! ln -s "$screensaver_file".lock "$screensaver_file".lock 2> /dev/null;
+ do
+ sleep 1
+ try=$(($try+1))
+ if [ $try -eq 3 ] ; then
+ rm -f "$screensaver_file".lock || return # Can't remove lockfile
+ try=0
+ fi
+ done
+ fi
+}
+
+unlockfile()
+{
+ rm -f "$screensaver_file".lock
+}
+
+perform_action()
+{
+ result=1
+
+ if [ "$1" = "resume" ] ; then
+ # Restore DPMS state
+ if [ -f "$screensaver_file.dpms" ]; then
+ rm "$screensaver_file.dpms"
+ # Re-enable DPMS
+ xset +dpms
+ fi
+ fi
+ if [ "$1" = "reset" ] ; then
+ if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
+ xset dpms force on
+ fi
+ fi
+
+ case "$DE" in
+ kde)
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ screensaver_freedesktop "$1"
+ else
+ screensaver_kde "$1"
+ fi
+ ;;
+
+ gnome_screensaver)
+ screensaver_gnome_screensaver "$1"
+ ;;
+
+ xscreensaver)
+ screensaver_xscreensaver "$1"
+ ;;
+
+ '')
+ screensaver_xserver "$1"
+ ;;
+ esac
+
+ if [ "$1" = "suspend" ] ; then
+ # Save DPMS state
+ if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ $MV "$tmpfile" "$screensaver_file.dpms"
+ # Disable DPMS
+ xset -dpms
+ fi
+ fi
+
+}
+
+cleanup_suspend()
+{
+ lockfile
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ grep -v "$window_id:$xprop_pid\$" "$screensaver_file" > "$tmpfile" 2> /dev/null
+ $MV "$tmpfile" "$screensaver_file"
+ if [ ! -s "$screensaver_file" ] ; then
+ rm "$screensaver_file"
+ unlockfile
+ # $screensaver_file is empty, do resume
+ perform_action resume
+ else
+ unlockfile
+ fi
+}
+
+do_resume()
+{
+ lockfile # Obtain lockfile
+ # Find the PID of the trackingprocess
+ xprop_pid=`grep "$window_id:" "$screensaver_file" 2> /dev/null | cut -d ':' -f 2`
+ unlockfile # Free lockfile
+ if [ -n "$xprop_pid" ] && ps -p "$xprop_pid" 2> /dev/null | grep xprop > /dev/null; then
+ # Kill the tracking process
+ kill -s TERM $xprop_pid
+ fi
+ cleanup_suspend
+}
+
+XPROP=`which xprop 2> /dev/null`
+
+check_window_id()
+{
+ if [ -z "$XPROP" ]; then
+ DEBUG 3 "xprop not found"
+ return
+ fi
+ DEBUG 2 "Running $XPROP -id $window_id"
+ if $XPROP -id $window_id > /dev/null 2> /dev/null; then
+ DEBUG 3 Window $window_id exists
+ else
+ DEBUG 3 Window $window_id does not exist
+ exit_failure_operation_failed "Window $window_id does not exist"
+ fi
+}
+
+track_window()
+{
+ if [ -z "$XPROP" ]; then
+ # Don't track window if we don't have xprop
+ return
+ fi
+ lockfile
+
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ # Filter stale entries from the xdg-screensaver status file
+ # Return if $window_id is being tracked already
+ (
+ already_tracked=1
+ IFS_save="$IFS"
+ IFS=":"
+ while read wid pid; do
+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
+ echo "$wid:$pid"
+ if [ $wid = $window_id ] ; then
+ already_tracked=0
+ fi
+ fi
+ done
+ IFS="$IFS_save"
+ exit $already_tracked
+ ) < $screensaver_file > $tmpfile
+ already_tracked=$?
+
+ if [ "$already_tracked" -eq "0" ] ; then
+ $MV "$tmpfile" "$screensaver_file"
+ # We are already tracking $window_id, don't do anything
+ unlockfile
+ return
+ fi
+
+ # Start tracking $window_id
+ $XPROP -id $window_id -spy > /dev/null &
+ xprop_pid=$!
+ # Add window_id and xprop_pid to the xdg-screensave status file
+ echo "$window_id:$xprop_pid" >> $tmpfile
+ $MV "$tmpfile" "$screensaver_file"
+ unlockfile
+ # Wait for xprop to edit, it means that the window disappeared
+ wait $xprop_pid
+ # Clean up the administration and resume the screensaver
+ cleanup_suspend
+}
+
+screensaver_freedesktop()
+{
+ case "$1" in
+ suspend)
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ --print-reply \
+ --reply-timeout=2000 \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.Inhibit \
+ string:$window_id \
+ string:xdg-screensaver \
+ | grep uint32 | cut -d ' ' -f 5 >| "$screensaver_file.cookie" \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ resume)
+ if [ -f "$screensaver_file.cookie" ] ; then
+ value=`cat "$screensaver_file.cookie"`
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.UnInhibit \
+ uint32:$value \
+ 2> /dev/null
+ rm -f "$screensaver_file.cookie"
+ fi
+ result=$?
+ ;;
+
+ activate)
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.SetActive \
+ boolean:true \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ lock)
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.Lock \
+ 2> /dev/null
+ ;;
+
+ reset)
+ if [ -f "$screensaver_file.cookie" ] ; then
+ value=`cat "$screensaver_file.cookie"`
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.UnInhibit \
+ uint32:$value \
+ 2> /dev/null
+ rm -f "$screensaver_file.cookie"
+ fi
+ result=$?
+ ;;
+
+ status)
+ status=`dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ --print-reply \
+ --reply-timeout=2000 \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.GetActive \
+ | grep boolean | cut -d ' ' -f 5`
+ result=$?
+ if [ x"$status" = "xtrue" ]; then
+ echo "enabled"
+ elif [ x"$status" = "xfalse" ]; then
+ echo "disabled"
+ else
+ echo "ERROR: dbus org.freedesktop.ScreenSaver.GetActive returned '$status'" >&2
+ return 1
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1'" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_kde()
+{
+ case "$1" in
+ suspend)
+ dcop kdesktop KScreensaverIface enable false > /dev/null
+ result=$?
+ ;;
+
+ resume)
+ dcop kdesktop KScreensaverIface configure > /dev/null
+ result=$?
+ ;;
+
+ activate)
+ dcop kdesktop KScreensaverIface save > /dev/null
+ result=$?
+ ;;
+
+ lock)
+ dcop kdesktop KScreensaverIface lock > /dev/null
+ result=$?
+ ;;
+
+ reset)
+ # Turns the screensaver off right now
+ dcop kdesktop KScreensaverIface quit > /dev/null
+ result=$?
+ ;;
+
+ status)
+ status=`dcop kdesktop KScreensaverIface isEnabled`
+ result=$?
+ if [ x"$status" = "xtrue" ]; then
+ echo "enabled"
+ elif [ x"$status" = "xfalse" ]; then
+ echo "disabled"
+ else
+ echo "ERROR: kdesktop KScreensaverIface isEnabled returned '$status'" >&2
+ return 1
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1'" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_xserver()
+{
+ case "$1" in
+ suspend)
+ xset s off > /dev/null
+ result=$?
+ ;;
+
+ resume)
+ xset s default > /dev/null
+ result=$?
+ ;;
+
+ activate)
+ xset s activate > /dev/null
+ result=$?
+ ;;
+
+ reset)
+ xset s reset > /dev/null
+ result=$?
+ ;;
+
+ status)
+ timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
+ result=$?
+ if [ "$timeout" -gt 0 ]; then
+ echo "enabled"
+ elif [ "$timeout" -eq 0 ]; then
+ echo "disabled"
+ else
+ echo "ERROR: xset q did not report the screensaver timeout" >&2
+ return 1
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1'" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_suspend_loop()
+{
+ lockfile
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ # Filter stale entries from the xdg-screensaver status file
+ cat "$screensaver_file" 2> /dev/null | (
+ IFS_save="$IFS"
+ IFS=":"
+ while read wid pid; do
+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
+ echo "$wid:$pid"
+ fi
+ done
+ IFS="$IFS_save"
+ ) > $tmpfile
+ if [ -s "$tmpfile" ] ; then
+ # Suspend pending, don't do a thing
+ $MV "$tmpfile" "$screensaver_file"
+ unlockfile
+ return
+ fi
+ $MV "$tmpfile" "$screensaver_file"
+ unlockfile
+ (while [ -f "$screensaver_file" ]; do $*; sleep 50; done) > /dev/null 2> /dev/null &
+}
+
+screensaver_gnome_screensaver()
+{
+# TODO
+# There seems to be a DBUS interface for gnome-screensaver
+# See http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-April/042579.html and
+# http://cvs.gnome.org/viewcvs/gnome-screensaver/src/gs-listener-dbus.c?rev=1.36&view=log
+# A problem seems to be that Inhibit is tied to the lifetime of the DBUS appname and
+# this can not be used from a script
+ case "$1" in
+ suspend)
+ screensaver_suspend_loop gnome-screensaver-command --poke
+ result=0
+ ;;
+
+ resume)
+ # Automatic resume when $screensaver_file disappears
+ result=0
+ ;;
+
+ activate)
+ gnome-screensaver-command --activate > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ lock)
+ gnome-screensaver-command --lock > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ reset)
+ # Turns the screensaver off right now
+ gnome-screensaver-command --deactivate > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ status)
+ result=0
+ if [ -f "$screensaver_file" ] ; then
+ echo "disabled"
+ elif gnome-screensaver-command --query > /dev/null 2> /dev/null; then
+ echo "enabled"
+ else
+ # Something is wrong
+ echo "disabled"
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_xscreensaver()
+{
+ case "$1" in
+ suspend)
+ screensaver_suspend_loop xscreensaver-command -deactivate
+ result=0
+ ;;
+
+ resume)
+ # Automatic resume when $screensaver_file disappears
+ result=0
+ ;;
+
+ activate)
+ xscreensaver-command -activate > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ lock)
+ xscreensaver-command -lock > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ reset)
+ # Turns the screensaver off right now
+ xscreensaver-command -deactivate > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ status)
+ result=0
+ if [ -f "$screensaver_file" ] ; then
+ echo "disabled"
+ else
+ echo "enabled"
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1" >&2
+ return 1
+ ;;
+ esac
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+action=
+window_id=
+
+case $1 in
+ suspend)
+ action="$1"
+
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "WindowID argument missing"
+ fi
+
+ window_id="$1"
+ check_window_id
+ ;;
+
+ resume)
+ action="$1"
+
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "WindowID argument missing"
+ fi
+
+ window_id="$1"
+ check_window_id
+ ;;
+
+ activate)
+ action="$1"
+ ;;
+
+ lock)
+ action="$1"
+ ;;
+
+ reset)
+ action="$1"
+ ;;
+
+ status)
+ action="$1"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+detectDE
+# Consider "xscreensaver" a separate DE
+xscreensaver-command -version 2> /dev/null | grep XScreenSaver > /dev/null && DE="xscreensaver"
+# Consider "gnome-screensaver" a separate DE
+gnome-screensaver-command -q > /dev/null 2>&1 && DE="gnome_screensaver"
+
+if [ "$action" = "resume" ] ; then
+ do_resume
+ exit_success
+fi
+
+perform_action "$action"
+
+if [ "$action" = "suspend" ] ; then
+ # Start tracking $window_id and resume the screensaver once it disappears
+ ( track_window ) 2> /dev/null > /dev/null &
+fi
+
+if [ $result -eq 0 ]; then
+ exit_success
+else
+ exit_failure_operation_failed
+fi
diff --git a/scripts/xdg-screensaver.in b/scripts/xdg-screensaver.in
new file mode 100644
index 0000000..07c3fc1
--- /dev/null
+++ b/scripts/xdg-screensaver.in
@@ -0,0 +1,627 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-screensaver
+#
+# Utility script to control screensaver.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2006, Bryce Harrington <bryce@osdl.org>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+# Check if we can use "mv -T"
+if mv -T ... ... 2>&1 | grep '\.\.\.' > /dev/null ; then
+ # We can securely move files in /tmp with mv -T
+ DEBUG 1 "mv -T available"
+ MV="mv -T"
+ screensaver_file="/tmp/xdg-screensaver-$USER-"`echo $DISPLAY | sed 's/:/-/g'`
+else
+ # No secure moves available, use home dir
+ DEBUG 1 "mv -T not available"
+ MV="mv"
+ screensaver_file="$HOME/.xdg-screensaver-"`echo $(hostname)-$DISPLAY | sed 's/:/-/g'`
+fi
+lockfile_command=`which lockfile 2> /dev/null`
+
+lockfile()
+{
+ if [ -n "$lockfile_command" ] ; then
+ $lockfile_command -1 -l 10 -s 3 "$screensaver_file".lock
+ else
+ # Poor man's attempt at doing a lockfile
+ # Be careful not to facilitate a symlink attack
+ local try
+ try=0
+ while ! ln -s "$screensaver_file".lock "$screensaver_file".lock 2> /dev/null;
+ do
+ sleep 1
+ try=$(($try+1))
+ if [ $try -eq 3 ] ; then
+ rm -f "$screensaver_file".lock || return # Can't remove lockfile
+ try=0
+ fi
+ done
+ fi
+}
+
+unlockfile()
+{
+ rm -f "$screensaver_file".lock
+}
+
+perform_action()
+{
+ result=1
+
+ if [ "$1" = "resume" ] ; then
+ # Restore DPMS state
+ if [ -f "$screensaver_file.dpms" ]; then
+ rm "$screensaver_file.dpms"
+ # Re-enable DPMS
+ xset +dpms
+ fi
+ fi
+ if [ "$1" = "reset" ] ; then
+ if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
+ xset dpms force on
+ fi
+ fi
+
+ case "$DE" in
+ kde)
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ screensaver_freedesktop "$1"
+ else
+ screensaver_kde "$1"
+ fi
+ ;;
+
+ gnome_screensaver)
+ screensaver_gnome_screensaver "$1"
+ ;;
+
+ xscreensaver)
+ screensaver_xscreensaver "$1"
+ ;;
+
+ '')
+ screensaver_xserver "$1"
+ ;;
+ esac
+
+ if [ "$1" = "suspend" ] ; then
+ # Save DPMS state
+ if xset -q | grep 'DPMS is Enabled' > /dev/null 2> /dev/null; then
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ $MV "$tmpfile" "$screensaver_file.dpms"
+ # Disable DPMS
+ xset -dpms
+ fi
+ fi
+
+}
+
+cleanup_suspend()
+{
+ lockfile
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ grep -v "$window_id:$xprop_pid\$" "$screensaver_file" > "$tmpfile" 2> /dev/null
+ $MV "$tmpfile" "$screensaver_file"
+ if [ ! -s "$screensaver_file" ] ; then
+ rm "$screensaver_file"
+ unlockfile
+ # $screensaver_file is empty, do resume
+ perform_action resume
+ else
+ unlockfile
+ fi
+}
+
+do_resume()
+{
+ lockfile # Obtain lockfile
+ # Find the PID of the trackingprocess
+ xprop_pid=`grep "$window_id:" "$screensaver_file" 2> /dev/null | cut -d ':' -f 2`
+ unlockfile # Free lockfile
+ if [ -n "$xprop_pid" ] && ps -p "$xprop_pid" 2> /dev/null | grep xprop > /dev/null; then
+ # Kill the tracking process
+ kill -s TERM $xprop_pid
+ fi
+ cleanup_suspend
+}
+
+XPROP=`which xprop 2> /dev/null`
+
+check_window_id()
+{
+ if [ -z "$XPROP" ]; then
+ DEBUG 3 "xprop not found"
+ return
+ fi
+ DEBUG 2 "Running $XPROP -id $window_id"
+ if $XPROP -id $window_id > /dev/null 2> /dev/null; then
+ DEBUG 3 Window $window_id exists
+ else
+ DEBUG 3 Window $window_id does not exist
+ exit_failure_operation_failed "Window $window_id does not exist"
+ fi
+}
+
+track_window()
+{
+ if [ -z "$XPROP" ]; then
+ # Don't track window if we don't have xprop
+ return
+ fi
+ lockfile
+
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ # Filter stale entries from the xdg-screensaver status file
+ # Return if $window_id is being tracked already
+ (
+ already_tracked=1
+ IFS_save="$IFS"
+ IFS=":"
+ while read wid pid; do
+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
+ echo "$wid:$pid"
+ if [ $wid = $window_id ] ; then
+ already_tracked=0
+ fi
+ fi
+ done
+ IFS="$IFS_save"
+ exit $already_tracked
+ ) < $screensaver_file > $tmpfile
+ already_tracked=$?
+
+ if [ "$already_tracked" -eq "0" ] ; then
+ $MV "$tmpfile" "$screensaver_file"
+ # We are already tracking $window_id, don't do anything
+ unlockfile
+ return
+ fi
+
+ # Start tracking $window_id
+ $XPROP -id $window_id -spy > /dev/null &
+ xprop_pid=$!
+ # Add window_id and xprop_pid to the xdg-screensave status file
+ echo "$window_id:$xprop_pid" >> $tmpfile
+ $MV "$tmpfile" "$screensaver_file"
+ unlockfile
+ # Wait for xprop to edit, it means that the window disappeared
+ wait $xprop_pid
+ # Clean up the administration and resume the screensaver
+ cleanup_suspend
+}
+
+screensaver_freedesktop()
+{
+ case "$1" in
+ suspend)
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ --print-reply \
+ --reply-timeout=2000 \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.Inhibit \
+ string:$window_id \
+ string:xdg-screensaver \
+ | grep uint32 | cut -d ' ' -f 5 >| "$screensaver_file.cookie" \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ resume)
+ if [ -f "$screensaver_file.cookie" ] ; then
+ value=`cat "$screensaver_file.cookie"`
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.UnInhibit \
+ uint32:$value \
+ 2> /dev/null
+ rm -f "$screensaver_file.cookie"
+ fi
+ result=$?
+ ;;
+
+ activate)
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.SetActive \
+ boolean:true \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ lock)
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.Lock \
+ 2> /dev/null
+ ;;
+
+ reset)
+ if [ -f "$screensaver_file.cookie" ] ; then
+ value=`cat "$screensaver_file.cookie"`
+ dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.UnInhibit \
+ uint32:$value \
+ 2> /dev/null
+ rm -f "$screensaver_file.cookie"
+ fi
+ result=$?
+ ;;
+
+ status)
+ status=`dbus-send --session \
+ --dest=org.freedesktop.ScreenSaver \
+ --type=method_call \
+ --print-reply \
+ --reply-timeout=2000 \
+ /ScreenSaver \
+ org.freedesktop.ScreenSaver.GetActive \
+ | grep boolean | cut -d ' ' -f 5`
+ result=$?
+ if [ x"$status" = "xtrue" ]; then
+ echo "enabled"
+ elif [ x"$status" = "xfalse" ]; then
+ echo "disabled"
+ else
+ echo "ERROR: dbus org.freedesktop.ScreenSaver.GetActive returned '$status'" >&2
+ return 1
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1'" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_kde()
+{
+ case "$1" in
+ suspend)
+ dcop kdesktop KScreensaverIface enable false > /dev/null
+ result=$?
+ ;;
+
+ resume)
+ dcop kdesktop KScreensaverIface configure > /dev/null
+ result=$?
+ ;;
+
+ activate)
+ dcop kdesktop KScreensaverIface save > /dev/null
+ result=$?
+ ;;
+
+ lock)
+ dcop kdesktop KScreensaverIface lock > /dev/null
+ result=$?
+ ;;
+
+ reset)
+ # Turns the screensaver off right now
+ dcop kdesktop KScreensaverIface quit > /dev/null
+ result=$?
+ ;;
+
+ status)
+ status=`dcop kdesktop KScreensaverIface isEnabled`
+ result=$?
+ if [ x"$status" = "xtrue" ]; then
+ echo "enabled"
+ elif [ x"$status" = "xfalse" ]; then
+ echo "disabled"
+ else
+ echo "ERROR: kdesktop KScreensaverIface isEnabled returned '$status'" >&2
+ return 1
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1'" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_xserver()
+{
+ case "$1" in
+ suspend)
+ xset s off > /dev/null
+ result=$?
+ ;;
+
+ resume)
+ xset s default > /dev/null
+ result=$?
+ ;;
+
+ activate)
+ xset s activate > /dev/null
+ result=$?
+ ;;
+
+ reset)
+ xset s reset > /dev/null
+ result=$?
+ ;;
+
+ status)
+ timeout=`xset q | sed '/^Screen Saver:/,/^[^ ]/ { s/.*timeout: *\([0-9]*\).*/\1/; t }; d'`
+ result=$?
+ if [ "$timeout" -gt 0 ]; then
+ echo "enabled"
+ elif [ "$timeout" -eq 0 ]; then
+ echo "disabled"
+ else
+ echo "ERROR: xset q did not report the screensaver timeout" >&2
+ return 1
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1'" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_suspend_loop()
+{
+ lockfile
+ test "${TMPDIR+set}" = set || TMPDIR=/tmp
+ tmpfile=`mktemp $TMPDIR/tmp.XXXXXXXXXX`
+ # Filter stale entries from the xdg-screensaver status file
+ cat "$screensaver_file" 2> /dev/null | (
+ IFS_save="$IFS"
+ IFS=":"
+ while read wid pid; do
+ if ps -p "$pid" 2> /dev/null | grep xprop > /dev/null; then
+ echo "$wid:$pid"
+ fi
+ done
+ IFS="$IFS_save"
+ ) > $tmpfile
+ if [ -s "$tmpfile" ] ; then
+ # Suspend pending, don't do a thing
+ $MV "$tmpfile" "$screensaver_file"
+ unlockfile
+ return
+ fi
+ $MV "$tmpfile" "$screensaver_file"
+ unlockfile
+ (while [ -f "$screensaver_file" ]; do $*; sleep 50; done) > /dev/null 2> /dev/null &
+}
+
+screensaver_gnome_screensaver()
+{
+# DBUS interface for gnome-screensaver
+# http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html
+ case "$1" in
+ suspend)
+ screensaver_suspend_loop \
+ dbus-send --session \
+ --dest=org.gnome.ScreenSaver \
+ --type=method_call \
+ /org/gnome/ScreenSaver \
+ org.gnome.ScreenSaver.SimulateUserActivity \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ resume)
+ # Automatic resume when $screensaver_file disappears
+ result=0
+ ;;
+
+ activate)
+ dbus-send --session \
+ --dest=org.gnome.ScreenSaver \
+ --type=method_call \
+ /org/gnome/ScreenSaver \
+ org.gnome.ScreenSaver.SetActive \
+ boolean:true \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ lock)
+ gnome-screensaver-command --lock > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ reset)
+ # Turns the screensaver off right now
+ dbus-send --session \
+ --dest=org.gnome.ScreenSaver \
+ --type=method_call \
+ /org/gnome/ScreenSaver \
+ org.gnome.ScreenSaver.SimulateUserActivity \
+ 2> /dev/null
+ result=$?
+ ;;
+
+ status)
+ status=`dbus-send --session \
+ --dest=org.gnome.ScreenSaver \
+ --type=method_call \
+ --print-reply \
+ --reply-timeout=2000 \
+ /org/gnome/ScreenSaver \
+ org.gnome.ScreenSaver.GetActive \
+ | grep boolean | cut -d ' ' -f 5`
+ result=$?
+ if [ x"$status" = "xtrue" -o x"$status" = "xfalse" ]; then
+ echo "enabled"
+ elif [ x"$result" != "x0" ]; then
+ echo "ERROR: dbus org.gnome.ScreenSaver.GetActive returned '$status'" >&2
+ return 1
+ else
+ echo "disabled"
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1" >&2
+ return 1
+ ;;
+ esac
+}
+
+screensaver_xscreensaver()
+{
+ case "$1" in
+ suspend)
+ screensaver_suspend_loop xscreensaver-command -deactivate
+ result=0
+ ;;
+
+ resume)
+ # Automatic resume when $screensaver_file disappears
+ result=0
+ ;;
+
+ activate)
+ xscreensaver-command -activate > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ lock)
+ xscreensaver-command -lock > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ reset)
+ # Turns the screensaver off right now
+ xscreensaver-command -deactivate > /dev/null 2> /dev/null
+ result=$?
+ ;;
+
+ status)
+ result=0
+ if [ -f "$screensaver_file" ] ; then
+ echo "disabled"
+ else
+ echo "enabled"
+ fi
+ ;;
+
+ *)
+ echo "ERROR: Unknown command '$1" >&2
+ return 1
+ ;;
+ esac
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+action=
+window_id=
+
+case $1 in
+ suspend)
+ action="$1"
+
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "WindowID argument missing"
+ fi
+
+ window_id="$1"
+ check_window_id
+ ;;
+
+ resume)
+ action="$1"
+
+ shift
+
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "WindowID argument missing"
+ fi
+
+ window_id="$1"
+ check_window_id
+ ;;
+
+ activate)
+ action="$1"
+ ;;
+
+ lock)
+ action="$1"
+ ;;
+
+ reset)
+ action="$1"
+ ;;
+
+ status)
+ action="$1"
+ ;;
+
+ *)
+ exit_failure_syntax "unknown command '$1'"
+ ;;
+esac
+
+detectDE
+# Consider "xscreensaver" a separate DE
+xscreensaver-command -version 2> /dev/null | grep XScreenSaver > /dev/null && DE="xscreensaver"
+# Consider "gnome-screensaver" a separate DE
+dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.ScreenSaver > /dev/null 2>&1 && DE="gnome_screensaver"
+
+if [ "$action" = "resume" ] ; then
+ do_resume
+ exit_success
+fi
+
+perform_action "$action"
+
+if [ "$action" = "suspend" ] ; then
+ # Start tracking $window_id and resume the screensaver once it disappears
+ ( track_window ) 2> /dev/null > /dev/null &
+fi
+
+if [ $result -eq 0 ]; then
+ exit_success
+else
+ exit_failure_operation_failed
+fi
diff --git a/scripts/xdg-settings b/scripts/xdg-settings
new file mode 100755
index 0000000..6a301f8
--- /dev/null
+++ b/scripts/xdg-settings
@@ -0,0 +1,1078 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-settings
+#
+# Utility script to get various settings from the desktop environment.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009, Google Inc.
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-settings - get various settings from the desktop environment
+
+Synopsis
+
+xdg-settings { get | check | set } {property} [subproperty] [value]
+
+xdg-settings { --help | --list | --manual | --version }
+
+Description
+
+xdg-settings gets various settings from the desktop environment. For instance,
+desktop environments often provide proxy configuration and default web browser
+settings. Using xdg-settings these parameters can be extracted for use by
+applications that do not use the desktop environment's libraries (which would
+use the settings natively).
+
+xdg-settings is for use inside a desktop session only. It is not recommended to
+use xdg-settings as root.
+
+Options
+
+--help
+ Show command synopsis.
+--list
+ List all properties xdg-settings knows about.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Properties
+
+When using xdg-settings to get, check or set a destkop setting, properties and
+possibly sub-properties are used to specify the setting to be changed.
+
+Some properties (such as default-web-browser) fully describe the setting to be
+changed. Other properties (such as default-url-scheme-handler) require more
+information (in this case the actual scheme to set the default handler for)
+which must be provided in a sub-property.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+
+Examples
+
+Get the desktop file name of the current default web browser
+
+ xdg-settings get default-web-browser
+
+
+Check whether the default web browser is firefox.desktop, which can be false
+even if "get default-web-browser" says that is the current value (if only some
+of the underlying settings actually reflect that value)
+
+ xdg-settings check default-web-browser firefox.desktop
+
+
+Set the default web browser to google-chrome.desktop
+
+ xdg-settings set default-web-browser google-chrome.desktop
+
+
+Set the default mailto URL scheme handler to be evolution.desktop
+
+ xdg-settings set default-url-scheme-handler mailto evolution.desktop
+
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-settings - get various settings from the desktop environment
+
+Synopsis
+
+xdg-settings { get | check | set } {property} [subproperty] [value]
+
+xdg-settings { --help | --list | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-settings: $@" >&2
+ echo "Try 'xdg-settings --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-settings' or 'xdg-settings --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-settings: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-settings: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-settings: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-settings: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-settings: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-settings: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-settings --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-settings' or 'xdg-settings --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-settings 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0;
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+check_desktop_filename()
+{
+ case "$1" in
+ */*)
+ exit_failure_syntax "invalid application name"
+ ;;
+ *.desktop)
+ return
+ ;;
+ *)
+ exit_failure_syntax "invalid application name"
+ ;;
+ esac
+}
+
+# {{{ default browser
+# {{{ utility functions
+
+# This handles backslashes but not quote marks.
+first_word()
+{
+ read first rest
+ echo "$first"
+}
+
+binary_to_desktop_file()
+{
+ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ binary="`which "$1"`"
+ binary="`readlink -f "$binary"`"
+ base="`basename "$binary"`"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" ] || continue
+ [ -d "$dir/applications" -o -d "$dir/applnk" ] || continue
+ for file in "$dir"/applications/*.desktop "$dir"/applnk/*.desktop; do
+ [ -r "$file" ] || continue
+ # Check to make sure it's worth the processing.
+ grep -q "^Exec.*$base" "$file" || continue
+ # Make sure it's a visible desktop file (e.g. not "preferred-web-browser.desktop").
+ grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command="`which "$command"`"
+ if [ x"`readlink -f "$command"`" = x"$binary" ]; then
+ # Fix any double slashes that got added path composition
+ echo "$file" | sed -e 's,//*,/,g'
+ return
+ fi
+ done
+ done
+}
+
+desktop_file_to_binary()
+{
+ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ desktop="`basename "$1"`"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" -a -d "$dir/applications" ] || continue
+ file="$dir/applications/$desktop"
+ [ -r "$file" ] || continue
+ # Remove any arguments (%F, %f, %U, %u, etc.).
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command="`which "$command"`"
+ readlink -f "$command"
+ return
+ done
+}
+
+# In order to remove an application from the automatically-generated list of
+# applications for handling a given MIME type, the desktop environment may copy
+# the global .desktop file into the user's .local directory, and remove that
+# MIME type from its list. In that case, we must restore the MIME type to the
+# application's list of MIME types before we can set it as the default for that
+# MIME type. (We can't just delete the local version, since the user may have
+# made other changes to it as well. So, tweak the existing file.)
+# This function is hard-coded for text/html but it could be adapted if needed.
+fix_local_desktop_file()
+{
+ apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
+ # No local desktop file?
+ [ ! -f "$apps/$1" ] && return
+ MIME="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`"
+ case "$MIME" in
+ text/html\;*|*\;text/html\;*|*\;text/html\;|*\;text/html)
+ # Already has text/html? Great!
+ return 0
+ ;;
+ esac
+
+ # Add text/html to the list
+ temp="`mktemp "$apps/$1.XXXXXX"`" || return
+ grep -v "^MimeType=" "$apps/$1" >> "$temp"
+ echo "MimeType=text/html;$MIME" >> "$temp"
+
+ oldlines="`wc -l < "$apps/$1"`"
+ newlines="`wc -l < "$temp"`"
+ # The new file should have at least as many lines as the old.
+ if [ $oldlines -le $newlines ]; then
+ mv "$temp" "$apps/$1"
+ # This can take a little bit to get noticed.
+ sleep 4
+ else
+ rm -f "$temp"
+ return 1
+ fi
+}
+
+# }}} utility functions
+# {{{ MIME utilities
+
+xdg_mime_fixup()
+{
+ # xdg-mime may use ktradertest, which will fork off a copy of kdeinit if
+ # one does not already exist. It will exit after about 15 seconds if no
+ # further processes need it around. But since it does not close its stdout,
+ # the shell (via grep) will wait around for kdeinit to exit. If we start a
+ # copy here, that copy will be used in xdg-mime and we will avoid waiting.
+ if [ "$DE" = kde -a -z "$XDG_MIME_FIXED" ]; then
+ ktradertest text/html Application > /dev/null 2>&1
+ # Only do this once, as we only need it once.
+ XDG_MIME_FIXED=yes
+ fi
+}
+
+get_browser_mime()
+{
+ xdg_mime_fixup
+ xdg-mime query default text/html
+}
+
+set_browser_mime()
+{
+ xdg_mime_fixup
+ orig="`get_browser_mime`"
+ # Fixing the local desktop file can actually change the default browser all
+ # by itself, so we fix it only after querying to find the current default.
+ fix_local_desktop_file "$1" || return
+ mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications"
+ xdg-mime default "$1" text/html || return
+ if [ x"`get_browser_mime`" != x"$1" ]; then
+ # Put back the original value
+ xdg-mime default "$orig" text/html
+ exit_failure_operation_failed
+ fi
+}
+
+# }}} MIME utilities
+# {{{ KDE utilities
+
+# Reads the KDE configuration setting, compensating for a bug in some versions of kreadconfig.
+read_kde_config()
+{
+ configfile="$1"
+ configsection="$2"
+ configkey="$3"
+ application="`kreadconfig --file $configfile --group $configsection --key $configkey`"
+ if [ x"$application" != x ]; then
+ echo "$application"
+ else
+ # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
+ # check by hand if it didn't find anything (oddly kwriteconfig works
+ # fine though).
+ configfile_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
+ configfile_path="$configfile_dir/$configfile"
+ [ ! -f "$configfile_path" ] && return
+ # This will only take the first value if there is more than one.
+ grep "^$configkey"'\[$[^]=]*\]=' "$configfile_path" | head -n 1 | cut -d= -f 2-
+ fi
+}
+
+# }}} KDE utilities
+# {{{ KDE
+
+# Resolves the KDE browser setting to a binary: if prefixed with !, simply removes it;
+# otherwise, uses desktop_file_to_binary to get the binary out of the desktop file.
+resolve_kde_browser()
+{
+ [ -z "$browser" ] && return
+ case "$browser" in
+ !*)
+ echo "${browser#!}"
+ ;;
+ *)
+ desktop_file_to_binary "$browser"
+ ;;
+ esac
+}
+
+# Does the opposite of resolve_kde_browser: if prefixed with !, tries to find a desktop
+# file corresponding to the binary, otherwise just returns the desktop file name.
+resolve_kde_browser_desktop()
+{
+ [ -z "$browser" ] && return
+ case "$browser" in
+ !*)
+ desktop="`binary_to_desktop_file "${browser#!}"`"
+ basename "$desktop"
+ ;;
+ *)
+ echo "$browser"
+ ;;
+ esac
+}
+
+read_kde_browser()
+{
+ read_kde_config kdeglobals General BrowserApplication
+}
+
+get_browser_kde()
+{
+ browser="`read_kde_browser`"
+ if [ x"$browser" = x ]; then
+ # No explicit default browser; KDE will use the MIME type text/html.
+ get_browser_mime
+ else
+ resolve_kde_browser_desktop
+ fi
+}
+
+check_browser_kde()
+{
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ browser="`read_kde_browser`"
+ binary="`resolve_kde_browser`"
+ # Because KDE will use the handler for MIME type text/html if this value
+ # is empty, we allow either the empty string or a match to $check here.
+ if [ x"$binary" != x -a x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ browser="`get_browser_mime`"
+ binary="`desktop_file_to_binary "$browser"`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_browser_kde()
+{
+ set_browser_mime "$1" || return
+ kwriteconfig --file kdeglobals --group General --key BrowserApplication "$1"
+}
+
+# }}} KDE
+# {{{ GNOME
+
+get_browser_gnome()
+{
+ binary="`gconftool-2 --get /desktop/gnome/applications/browser/exec | first_word`"
+ if [ x"$binary" = x ]; then
+ # No default browser; GNOME might use the MIME type text/html.
+ get_browser_mime
+ else
+ # gconftool gives the binary (maybe with %s etc. afterward),
+ # but we want the desktop file name, not the binary. So, we
+ # have to find the desktop file to which it corresponds.
+ desktop="`binary_to_desktop_file "$binary"`"
+ basename "$desktop"
+ fi
+}
+
+check_browser_gnome()
+{
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ binary="`gconftool-2 --get /desktop/gnome/applications/browser/exec | first_word`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ # Check HTTP and HTTPS, but not about: and unknown:.
+ for protocol in http https; do
+ binary="`gconftool-2 --get /desktop/gnome/url-handlers/$protocol/command | first_word`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ done
+ browser="`get_browser_mime`"
+ binary="`desktop_file_to_binary "$browser"`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_browser_gnome()
+{
+ binary="`desktop_file_to_binary "$1"`"
+ [ "$binary" ] || exit_failure_file_missing
+ set_browser_mime "$1" || return
+
+ # Set the default browser.
+ gconftool-2 --type string --set /desktop/gnome/applications/browser/exec "$binary"
+ gconftool-2 --type bool --set /desktop/gnome/applications/browser/needs_term false
+ gconftool-2 --type bool --set /desktop/gnome/applications/browser/nremote true
+ # Set the handler for HTTP and HTTPS.
+ for protocol in http https; do
+ gconftool-2 --type string --set /desktop/gnome/url-handlers/$protocol/command "$binary %s"
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$protocol/needs_terminal false
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$protocol/enabled true
+ done
+ # Set the handler for about: and unknown URL types.
+ for protocol in about unknown; do
+ gconftool-2 --type string --set /desktop/gnome/url-handlers/$protocol/command "$binary %s"
+ done
+}
+
+# }}} GNOME
+# {{{ xfce
+
+get_browser_xfce()
+{
+ search="${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" -a -d "$dir/xfce4" ] || continue
+ file="$dir/xfce4/helpers.rc"
+ [ -r "$file" ] || continue
+ grep -q "^WebBrowser=" "$file" || continue
+ desktop="`grep "^WebBrowser=" "$file" | cut -d= -f 2-`"
+ echo "$desktop.desktop"
+ return
+ done
+ exit_failure_operation_failed
+}
+
+check_browser_xfce()
+{
+ browser="`get_browser_xfce`"
+ if [ x"$browser" != x"$1" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+check_xfce_desktop_file()
+{
+ # Annoyingly, xfce wants its .desktop files in a separate directory instead
+ # of the standard locations, and requires a few custom tweaks to them:
+ # "Type" must be "X-XFCE-Helper"
+ # "X-XFCE-Category" must be "WebBrowser" (for web browsers, anyway)
+ # "X-XFCE-Commands" and "X-XFCE-CommandsWithParameter" must be set
+ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" -a -d "$dir/xfce4/helpers" ] || continue
+ file="$dir/xfce4/helpers/$1"
+ # We have the file, no need to create it.
+ [ -r "$file" ] && return
+ done
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" -a -d "$dir/applications" ] || continue
+ file="$dir/applications/$1"
+ if [ -r "$file" ]; then
+ # Found a file to convert.
+ target="${XDG_DATA_HOME:-$HOME/.local/share}/xfce4/helpers"
+ mkdir -p "$target"
+ grep -v "^Type=" "$file" > "$target/$1"
+ echo "Type=X-XFCE-Helper" >> "$target/$1"
+ echo "X-XFCE-Category=WebBrowser" >> "$target/$1"
+ # Change %F, %f, %U, and %u to "%s".
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | sed -e 's/%[FfUu]/"%s"/g'`"
+ echo "X-XFCE-Commands=`echo "$command" | first_word`" >> "$target/$1"
+ echo "X-XFCE-CommandsWithParameter=$command" >> "$target/$1"
+ return
+ fi
+ done
+ return 1
+}
+
+set_browser_xfce()
+{
+ check_xfce_desktop_file "$1" || exit_failure_operation_failed
+
+ helper_dir="${XDG_CONFIG_HOME:-$HOME/.config}/xfce4"
+ if [ ! -d "$helper_dir" ]; then
+ mkdir -p "$helper_dir" || exit_failure_operation_failed
+ fi
+
+ helpers_rc="$helper_dir/helpers.rc"
+ # Create the file if it does not exist to avoid special cases below.
+ if [ ! -r "$helpers_rc" ]; then
+ touch "$helpers_rc" || exit_failure_operation_failed
+ fi
+
+ temp="`mktemp "$helpers_rc.XXXXXX"`" || return
+ grep -v "^WebBrowser=" "$helpers_rc" >> "$temp"
+ echo "WebBrowser=${1%.desktop}" >> "$temp"
+
+ oldlines="`wc -l < "$helpers_rc"`"
+ newlines="`wc -l < "$temp"`"
+ # The new file should have at least as many lines as the old.
+ if [ $oldlines -le $newlines ]; then
+ mv "$temp" "$helpers_rc"
+ else
+ rm -f "$temp"
+ return 1
+ fi
+}
+
+# }}} xfce
+# }}} default browser
+
+# {{{ default url scheme handler
+
+exit_unimplemented_default_handler()
+{
+ exit_failure_operation_impossible "default-url-scheme-handler not implemented for $DE"
+}
+
+# {{{ KDE
+
+# Recent versions of KDE support default scheme handler applications using the
+# mime type of x-scheme-handler/scheme. Older versions will not support this
+# but do have support for setting a default mail handler. There is also a
+# system in KDE where .protocol files can be used, however this is not
+# supported by this script. When reading a scheme handler we will use the
+# default mail handler for the mailto scheme, otherwise we will use the mime
+# type x-scheme-handler/scheme.
+
+get_url_scheme_handler_kde()
+{
+ if [ "$1" = "mailto" ]; then
+ handler="`read_kde_config emaildefaults PROFILE_Default EmailClient | first_word`"
+ echo "handler is $handler"
+ if [ x"$handler" != x ]; then
+ binary_to_desktop_file "$handler"
+ else
+ get_browser_mime "x-scheme-handler/$1"
+ fi
+ else
+ get_browser_mime "x-scheme-handler/$1"
+ fi
+}
+
+check_url_scheme_handler_kde()
+{
+ check="`desktop_file_to_binary "$2"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ if [ x"$1" = "mailto" ]; then
+ binary="`read_kde_config emaildefaults PROFILE_Default EmailClient`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ fi
+ handler="`get_browser_mime x-scheme-handler/$1`"
+ binary="`desktop_file_to_binary "$handler"`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_url_scheme_handler_kde()
+{
+ set_browser_mime "$2" "x-scheme-handler/$1" || return
+ if [ "$1" = "mailto" ]; then
+ binary="`desktop_file_to_binary "$2"`"
+ kwriteconfig --file emaildefaults --group PROFILE_Default --key EmailClient "$binary"
+ fi
+}
+
+# }}} KDE
+# {{{ GNOME
+
+get_url_scheme_handler_gnome()
+{
+ binary="`gconftool-2 --get /desktop/gnome/url-handlers/$1/command | first_word`"
+ if [ x"$binary" != x"" ]; then
+ # gconftool gives the binary (maybe with %s etc. afterward),
+ # but we want the desktop file name, not the binary. So, we
+ # have to find the desktop file to which it corresponds.
+ desktop="`binary_to_desktop_file "$binary"`"
+ basename "$desktop"
+ fi
+}
+
+check_url_scheme_handler_gnome()
+{
+ check="`desktop_file_to_binary "$2"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ binary="`gconftool-2 --get /desktop/gnome/url-handlers/$1/command | first_word`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_url_scheme_handler_gnome()
+{
+ binary="`desktop_file_to_binary "$2"`"
+ [ "$binary" ] || exit_failure_file_missing
+
+ gconftool-2 --type string --set /desktop/gnome/url-handlers/$1/command "$binary %s"
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$1/needs_terminal false
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$1/enabled true
+}
+
+# }}} GNOME
+# {{{ GNOME 3.x
+
+get_url_scheme_handler_gnome3()
+{
+ get_browser_mime "x-scheme-handler/$1"
+}
+
+check_url_scheme_handler_gnome3()
+{
+ desktop="$2"
+ check="`desktop_file_to_binary "$2"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ browser="`get_browser_mime "x-scheme-handler/$1"`"
+ if [ x"$browser" != x"$desktop" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_url_scheme_handler_gnome3()
+{
+ binary="`desktop_file_to_binary "$2"`"
+ [ "$binary" ] || exit_failure_file_missing
+ set_browser_mime "$2" || return
+
+ # Set the default browser.
+ set_browser_mime "$2" "x-scheme-handler/$1" || return
+}
+
+# }}} GNOME 3.x
+# {{{ xfce
+
+get_url_scheme_handler_xfce()
+{
+ exit_unimplemented_default_handler "$1"
+}
+
+check_url_scheme_handler_xfce()
+{
+ exit_unimplemented_default_handler "$1"
+}
+
+set_url_scheme_handler_xfce()
+{
+ exit_unimplemented_default_handler "$1"
+}
+
+# }}} xfce
+# }}} default protocol handler
+
+dispatch_specific()
+{
+ # The PROP comments in this function are used to generate the output of
+ # the --list option. The formatting is important. Make sure to line up the
+ # property descriptions with spaces so that it will look nice.
+ if [ x"$op" = x"get" ]; then
+ case "$parm" in
+ default-web-browser) # PROP: Default web browser
+ get_browser_$DE
+ ;;
+
+ default-url-scheme-handler) # PROP: Default handler for URL scheme
+ get_url_scheme_handler_$DE "$1"
+ ;;
+
+ *)
+ exit_failure_syntax
+ ;;
+ esac
+ elif [ x"$op" = x"check" ]; then
+ case "$parm" in
+ default-web-browser)
+ check_desktop_filename "$1"
+ check_browser_$DE "$1"
+ ;;
+
+ default-url-scheme-handler)
+ check_desktop_filename "$2"
+ check_url_scheme_handler_$DE "$1" "$2"
+ ;;
+
+ *)
+ exit_failure_syntax
+ ;;
+ esac
+ else # set
+ case "$parm" in
+ default-web-browser)
+ [ $# -eq 1 ] || exit_failure_syntax "unexpected/missing argument"
+ check_desktop_filename "$1"
+ set_browser_$DE "$1"
+ ;;
+
+ default-url-scheme-handler)
+ [ $# -eq 2 ] || exit_failure_syntax "unexpected/missing argument"
+ check_desktop_filename "$2"
+ set_url_scheme_handler_$DE "$1" "$2"
+ ;;
+
+ *)
+ exit_failure_syntax
+ ;;
+ esac
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+dispatch_generic()
+{
+ # We only know how to get or check the default web browser.
+ [ x"$op" != x"get" -a x"$op" != x"check" ] && exit_failure_operation_impossible
+ [ x"$parm" != x"default-web-browser" ] && exit_failure_operation_impossible
+
+ # First look in $BROWSER
+ if [ x"$BROWSER" != x ]; then
+ binary="`which "${BROWSER%%:*}"`"
+ else
+ # Debian and Ubuntu (and others?) have x-www-browser.
+ binary="`which x-www-browser`"
+ fi
+
+ [ "$binary" ] || exit_failure_operation_failed
+
+ binary="`readlink -f "$binary"`"
+
+ [ "$binary" ] || exit_failure_operation_failed
+
+ if [ x"$op" = x"get" ]; then
+ desktop="`binary_to_desktop_file "$binary"`"
+ basename "$desktop"
+ else
+ # $op = "check"
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ fi
+ exit_success
+}
+
+if [ x"$1" = x"--list" ]; then
+ echo "Known properties:"
+ # Extract the property names from dispatch_specific() above.
+ grep "^[ ]*[^)]*) # PROP:" "$0" | sed -e 's/^[ ]*\([^)]*\)) # PROP: \(.*\)$/ \1 \2/' | sort
+ exit_success
+fi
+
+[ x"$1" != x ] || exit_failure_syntax "no operation given"
+[ x"$2" != x ] || exit_failure_syntax "no parameter name given"
+[ x"$1" = x"get" -o x"$3" != x ] || exit_failure_syntax "no parameter value given"
+
+op="$1"
+parm="$2"
+shift 2
+
+if [ x"$op" != x"get" -a x"$op" != x"check" -a x"$op" != x"set" ]; then
+ exit_failure_syntax "invalid operation"
+fi
+
+detectDE
+
+case "$DE" in
+ kde|gnome|xfce)
+ dispatch_specific "$@"
+ ;;
+
+ generic)
+ dispatch_generic "$@"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "unknown desktop environment"
+ ;;
+esac
diff --git a/scripts/xdg-settings.in b/scripts/xdg-settings.in
new file mode 100644
index 0000000..eaed991
--- /dev/null
+++ b/scripts/xdg-settings.in
@@ -0,0 +1,752 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-settings
+#
+# Utility script to get various settings from the desktop environment.
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009, Google Inc.
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+check_desktop_filename()
+{
+ case "$1" in
+ */*)
+ exit_failure_syntax "invalid application name"
+ ;;
+ *.desktop)
+ return
+ ;;
+ *)
+ exit_failure_syntax "invalid application name"
+ ;;
+ esac
+}
+
+# {{{ default browser
+# {{{ utility functions
+
+# In order to remove an application from the automatically-generated list of
+# applications for handling a given MIME type, the desktop environment may copy
+# the global .desktop file into the user's .local directory, and remove that
+# MIME type from its list. In that case, we must restore the MIME type to the
+# application's list of MIME types before we can set it as the default for that
+# MIME type. (We can't just delete the local version, since the user may have
+# made other changes to it as well. So, tweak the existing file.)
+# This function is hard-coded for text/html but it could be adapted if needed.
+fix_local_desktop_file()
+{
+ if test -z "$2" ; then
+ MIME="text/html"
+ else
+ MIME="$2"
+ fi
+ apps="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
+ # No local desktop file?
+ [ ! -f "$apps/$1" ] && return
+ MIMETYPES="`grep "^MimeType=" "$apps/$1" | cut -d= -f 2-`"
+ case "$MIMETYPES" in
+ $MIME\;*|*\;$MIME\;*|*\;$MIME\;|*\;$MIME)
+ # Already has the mime-type? Great!
+ return 0
+ ;;
+ esac
+
+ # Add the mime-type to the list
+ temp="`mktemp "$apps/$1.XXXXXX"`" || return
+ grep -v "^MimeType=" "$apps/$1" >> "$temp"
+ echo "MimeType=$MIME;$MIMETYPES" >> "$temp"
+
+ oldlines="`wc -l < "$apps/$1"`"
+ newlines="`wc -l < "$temp"`"
+ # The new file should have at least as many lines as the old.
+ if [ $oldlines -le $newlines ]; then
+ mv "$temp" "$apps/$1"
+ # This can take a little bit to get noticed.
+ sleep 4
+ else
+ rm -f "$temp"
+ return 1
+ fi
+}
+
+# }}} utility functions
+# {{{ MIME utilities
+
+xdg_mime_fixup()
+{
+ # xdg-mime may use ktradertest, which will fork off a copy of kdeinit if
+ # one does not already exist. It will exit after about 15 seconds if no
+ # further processes need it around. But since it does not close its stdout,
+ # the shell (via grep) will wait around for kdeinit to exit. If we start a
+ # copy here, that copy will be used in xdg-mime and we will avoid waiting.
+ if [ "$DE" = kde -a -z "$XDG_MIME_FIXED" ]; then
+ ktradertest text/html Application > /dev/null 2>&1
+ # Only do this once, as we only need it once.
+ XDG_MIME_FIXED=yes
+ fi
+}
+
+get_browser_mime()
+{
+ if test -z "$1" ; then
+ MIME="text/html"
+ else
+ MIME="$1"
+ fi
+ xdg_mime_fixup
+ xdg-mime query default "$MIME"
+}
+
+set_browser_mime()
+{
+ xdg_mime_fixup
+ if test -z "$2" ; then
+ MIME="text/html"
+ else
+ MIME="$2"
+ fi
+ orig="`get_browser_mime $MIME`"
+ # Fixing the local desktop file can actually change the default browser all
+ # by itself, so we fix it only after querying to find the current default.
+ fix_local_desktop_file "$1" "$MIME" || return
+ mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/applications"
+ xdg-mime default "$1" "$MIME" || return
+ if [ x"`get_browser_mime`" != x"$1" ]; then
+ # Put back the original value
+ xdg-mime default "$orig" "$MIME"
+ exit_failure_operation_failed
+ fi
+}
+
+# }}} MIME utilities
+# {{{ KDE utilities
+
+# Reads the KDE configuration setting, compensating for a bug in some versions of kreadconfig.
+read_kde_config()
+{
+ configfile="$1"
+ configsection="$2"
+ configkey="$3"
+ application="`kreadconfig --file $configfile --group $configsection --key $configkey`"
+ if [ x"$application" != x ]; then
+ echo "$application"
+ else
+ # kreadconfig in KDE 4 may not notice Key[$*]=... localized settings, so
+ # check by hand if it didn't find anything (oddly kwriteconfig works
+ # fine though).
+ configfile_dir=`kde${KDE_SESSION_VERSION}-config --path config | cut -d ':' -f 1`
+ configfile_path="$configfile_dir/$configfile"
+ [ ! -f "$configfile_path" ] && return
+ # This will only take the first value if there is more than one.
+ grep "^$configkey"'\[$[^]=]*\]=' "$configfile_path" | head -n 1 | cut -d= -f 2-
+ fi
+}
+
+# }}} KDE utilities
+# {{{ KDE
+
+# Resolves the KDE browser setting to a binary: if prefixed with !, simply removes it;
+# otherwise, uses desktop_file_to_binary to get the binary out of the desktop file.
+resolve_kde_browser()
+{
+ [ -z "$browser" ] && return
+ case "$browser" in
+ !*)
+ echo "${browser#!}"
+ ;;
+ *)
+ desktop_file_to_binary "$browser"
+ ;;
+ esac
+}
+
+# Does the opposite of resolve_kde_browser: if prefixed with !, tries to find a desktop
+# file corresponding to the binary, otherwise just returns the desktop file name.
+resolve_kde_browser_desktop()
+{
+ [ -z "$browser" ] && return
+ case "$browser" in
+ !*)
+ desktop="`binary_to_desktop_file "${browser#!}"`"
+ basename "$desktop"
+ ;;
+ *)
+ echo "$browser"
+ ;;
+ esac
+}
+
+read_kde_browser()
+{
+ read_kde_config kdeglobals General BrowserApplication
+}
+
+get_browser_kde()
+{
+ browser="`read_kde_browser`"
+ if [ x"$browser" = x ]; then
+ # No explicit default browser; KDE will use the MIME type text/html.
+ get_browser_mime
+ else
+ resolve_kde_browser_desktop
+ fi
+}
+
+check_browser_kde()
+{
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ browser="`read_kde_browser`"
+ binary="`resolve_kde_browser`"
+ # Because KDE will use the handler for MIME type text/html if this value
+ # is empty, we allow either the empty string or a match to $check here.
+ if [ x"$binary" != x -a x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ browser="`get_browser_mime`"
+ binary="`desktop_file_to_binary "$browser"`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_browser_kde()
+{
+ set_browser_mime "$1" || return
+ kwriteconfig --file kdeglobals --group General --key BrowserApplication "$1"
+}
+
+# }}} KDE
+# {{{ GNOME
+
+get_browser_gnome()
+{
+ binary="`gconftool-2 --get /desktop/gnome/applications/browser/exec | first_word`"
+ if [ x"$binary" = x ]; then
+ # No default browser; GNOME might use the MIME type text/html.
+ get_browser_mime
+ else
+ # gconftool gives the binary (maybe with %s etc. afterward),
+ # but we want the desktop file name, not the binary. So, we
+ # have to find the desktop file to which it corresponds.
+ desktop="`binary_to_desktop_file "$binary"`"
+ basename "$desktop"
+ fi
+}
+
+check_browser_gnome()
+{
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ binary="`gconftool-2 --get /desktop/gnome/applications/browser/exec | first_word`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ # Check HTTP and HTTPS, but not about: and unknown:.
+ for protocol in http https; do
+ binary="`gconftool-2 --get /desktop/gnome/url-handlers/$protocol/command | first_word`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ done
+ browser="`get_browser_mime`"
+ binary="`desktop_file_to_binary "$browser"`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_browser_gnome()
+{
+ binary="`desktop_file_to_binary "$1"`"
+ [ "$binary" ] || exit_failure_file_missing
+ set_browser_mime "$1" || return
+
+ # Set the default browser.
+ gconftool-2 --type string --set /desktop/gnome/applications/browser/exec "$binary"
+ gconftool-2 --type bool --set /desktop/gnome/applications/browser/needs_term false
+ gconftool-2 --type bool --set /desktop/gnome/applications/browser/nremote true
+ # Set the handler for HTTP and HTTPS.
+ for protocol in http https; do
+ gconftool-2 --type string --set /desktop/gnome/url-handlers/$protocol/command "$binary %s"
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$protocol/needs_terminal false
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$protocol/enabled true
+ done
+ # Set the handler for about: and unknown URL types.
+ for protocol in about unknown; do
+ gconftool-2 --type string --set /desktop/gnome/url-handlers/$protocol/command "$binary %s"
+ done
+}
+
+# }}} GNOME
+# {{{ GNOME 3.x
+
+get_browser_gnome3()
+{
+ get_browser_mime "x-scheme-handler/http"
+}
+
+check_browser_gnome3()
+{
+ desktop="$1"
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ # Check HTTP and HTTPS, but not about: and unknown:.
+ for protocol in http https; do
+ browser="`get_browser_mime "x-scheme-handler/$protocol"`"
+ if [ x"$browser" != x"$desktop" ]; then
+ echo no
+ exit_success
+ fi
+ done
+ echo yes
+ exit_success
+}
+
+set_browser_gnome3()
+{
+ binary="`desktop_file_to_binary "$1"`"
+ [ "$binary" ] || exit_failure_file_missing
+ set_browser_mime "$1" || return
+
+ # Set the default browser.
+ for protocol in http https about unknown; do
+ set_browser_mime "$1" "x-scheme-handler/$protocol" || return
+ done
+}
+# }}} GNOME 3.x
+# {{{ xfce
+
+get_browser_xfce()
+{
+ search="${XDG_CONFIG_HOME:-$HOME/.config}:${XDG_CONFIG_DIRS:-/etc/xdg}"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" ] && [ -d "$dir/xfce4" ] || continue
+ file="$dir/xfce4/helpers.rc"
+ [ -r "$file" ] || continue
+ grep -q "^WebBrowser=" "$file" || continue
+ desktop="`grep "^WebBrowser=" "$file" | cut -d= -f 2-`"
+ echo "$desktop.desktop"
+ return
+ done
+ exit_failure_operation_failed
+}
+
+check_browser_xfce()
+{
+ browser="`get_browser_xfce`"
+ if [ x"$browser" != x"$1" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+check_xfce_desktop_file()
+{
+ # Annoyingly, xfce wants its .desktop files in a separate directory instead
+ # of the standard locations, and requires a few custom tweaks to them:
+ # "Type" must be "X-XFCE-Helper"
+ # "X-XFCE-Category" must be "WebBrowser" (for web browsers, anyway)
+ # "X-XFCE-Commands" and "X-XFCE-CommandsWithParameter" must be set
+ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" ] && [ -d "$dir/xfce4/helpers" ] || continue
+ file="$dir/xfce4/helpers/$1"
+ # We have the file, no need to create it.
+ [ -r "$file" ] && return
+ done
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" ] && [ -d "$dir/applications" ] || continue
+ file="$dir/applications/$1"
+ if [ -r "$file" ]; then
+ # Found a file to convert.
+ target="${XDG_DATA_HOME:-$HOME/.local/share}/xfce4/helpers"
+ mkdir -p "$target"
+ grep -v "^Type=" "$file" > "$target/$1"
+ echo "Type=X-XFCE-Helper" >> "$target/$1"
+ echo "X-XFCE-Category=WebBrowser" >> "$target/$1"
+ # Change %F, %f, %U, and %u to "%s".
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | sed -e 's/%[FfUu]/"%s"/g'`"
+ echo "X-XFCE-Commands=`echo "$command" | first_word`" >> "$target/$1"
+ echo "X-XFCE-CommandsWithParameter=$command" >> "$target/$1"
+ return
+ fi
+ done
+ return 1
+}
+
+set_browser_xfce()
+{
+ check_xfce_desktop_file "$1" || exit_failure_operation_failed
+
+ helper_dir="${XDG_CONFIG_HOME:-$HOME/.config}/xfce4"
+ if [ ! -d "$helper_dir" ]; then
+ mkdir -p "$helper_dir" || exit_failure_operation_failed
+ fi
+
+ helpers_rc="$helper_dir/helpers.rc"
+ # Create the file if it does not exist to avoid special cases below.
+ if [ ! -r "$helpers_rc" ]; then
+ touch "$helpers_rc" || exit_failure_operation_failed
+ fi
+
+ temp="`mktemp "$helpers_rc.XXXXXX"`" || return
+ grep -v "^WebBrowser=" "$helpers_rc" >> "$temp"
+ echo "WebBrowser=${1%.desktop}" >> "$temp"
+
+ oldlines="`wc -l < "$helpers_rc"`"
+ newlines="`wc -l < "$temp"`"
+ # The new file should have at least as many lines as the old.
+ if [ $oldlines -le $newlines ]; then
+ mv "$temp" "$helpers_rc"
+ else
+ rm -f "$temp"
+ return 1
+ fi
+}
+
+# }}} xfce
+# }}} default browser
+
+# {{{ default url scheme handler
+
+exit_unimplemented_default_handler()
+{
+ exit_failure_operation_impossible "default-url-scheme-handler not implemented for $DE"
+}
+
+# {{{ KDE
+
+# Recent versions of KDE support default scheme handler applications using the
+# mime type of x-scheme-handler/scheme. Older versions will not support this
+# but do have support for setting a default mail handler. There is also a
+# system in KDE where .protocol files can be used, however this is not
+# supported by this script. When reading a scheme handler we will use the
+# default mail handler for the mailto scheme, otherwise we will use the mime
+# type x-scheme-handler/scheme.
+
+get_url_scheme_handler_kde()
+{
+ if [ "$1" = "mailto" ]; then
+ handler="`read_kde_config emaildefaults PROFILE_Default EmailClient | first_word`"
+ echo "handler is $handler"
+ if [ x"$handler" != x ]; then
+ binary_to_desktop_file "$handler"
+ else
+ get_browser_mime "x-scheme-handler/$1"
+ fi
+ else
+ get_browser_mime "x-scheme-handler/$1"
+ fi
+}
+
+check_url_scheme_handler_kde()
+{
+ check="`desktop_file_to_binary "$2"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ if [ x"$1" = "mailto" ]; then
+ binary="`read_kde_config emaildefaults PROFILE_Default EmailClient`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ fi
+ handler="`get_browser_mime x-scheme-handler/$1`"
+ binary="`desktop_file_to_binary "$handler"`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_url_scheme_handler_kde()
+{
+ set_browser_mime "$2" "x-scheme-handler/$1" || return
+ if [ "$1" = "mailto" ]; then
+ binary="`desktop_file_to_binary "$2"`"
+ kwriteconfig --file emaildefaults --group PROFILE_Default --key EmailClient "$binary"
+ fi
+}
+
+# }}} KDE
+# {{{ GNOME
+
+get_url_scheme_handler_gnome()
+{
+ binary="`gconftool-2 --get /desktop/gnome/url-handlers/$1/command | first_word`"
+ if [ x"$binary" != x"" ]; then
+ # gconftool gives the binary (maybe with %s etc. afterward),
+ # but we want the desktop file name, not the binary. So, we
+ # have to find the desktop file to which it corresponds.
+ desktop="`binary_to_desktop_file "$binary"`"
+ basename "$desktop"
+ fi
+}
+
+check_url_scheme_handler_gnome()
+{
+ check="`desktop_file_to_binary "$2"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ binary="`gconftool-2 --get /desktop/gnome/url-handlers/$1/command | first_word`"
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_url_scheme_handler_gnome()
+{
+ binary="`desktop_file_to_binary "$2"`"
+ [ "$binary" ] || exit_failure_file_missing
+
+ gconftool-2 --type string --set /desktop/gnome/url-handlers/$1/command "$binary %s"
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$1/needs_terminal false
+ gconftool-2 --type bool --set /desktop/gnome/url-handlers/$1/enabled true
+}
+
+# }}} GNOME
+# {{{ GNOME 3.x
+
+get_url_scheme_handler_gnome3()
+{
+ get_browser_mime "x-scheme-handler/$1"
+}
+
+check_url_scheme_handler_gnome3()
+{
+ desktop="$2"
+ check="`desktop_file_to_binary "$2"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ browser="`get_browser_mime "x-scheme-handler/$1"`"
+ if [ x"$browser" != x"$desktop" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ exit_success
+}
+
+set_url_scheme_handler_gnome3()
+{
+ binary="`desktop_file_to_binary "$2"`"
+ [ "$binary" ] || exit_failure_file_missing
+ set_browser_mime "$2" || return
+
+ # Set the default browser.
+ set_browser_mime "$2" "x-scheme-handler/$1" || return
+}
+
+# }}} GNOME 3.x
+# {{{ xfce
+
+get_url_scheme_handler_xfce()
+{
+ exit_unimplemented_default_handler "$1"
+}
+
+check_url_scheme_handler_xfce()
+{
+ exit_unimplemented_default_handler "$1"
+}
+
+set_url_scheme_handler_xfce()
+{
+ exit_unimplemented_default_handler "$1"
+}
+
+# }}} xfce
+# }}} default protocol handler
+
+dispatch_specific()
+{
+ # The PROP comments in this function are used to generate the output of
+ # the --list option. The formatting is important. Make sure to line up the
+ # property descriptions with spaces so that it will look nice.
+ if [ x"$op" = x"get" ]; then
+ case "$parm" in
+ default-web-browser) # PROP: Default web browser
+ get_browser_$DE
+ ;;
+
+ default-url-scheme-handler) # PROP: Default handler for URL scheme
+ get_url_scheme_handler_$DE "$1"
+ ;;
+
+ *)
+ exit_failure_syntax
+ ;;
+ esac
+ elif [ x"$op" = x"check" ]; then
+ case "$parm" in
+ default-web-browser)
+ check_desktop_filename "$1"
+ check_browser_$DE "$1"
+ ;;
+
+ default-url-scheme-handler)
+ check_desktop_filename "$2"
+ check_url_scheme_handler_$DE "$1" "$2"
+ ;;
+
+ *)
+ exit_failure_syntax
+ ;;
+ esac
+ else # set
+ case "$parm" in
+ default-web-browser)
+ [ $# -eq 1 ] || exit_failure_syntax "unexpected/missing argument"
+ check_desktop_filename "$1"
+ set_browser_$DE "$1"
+ ;;
+
+ default-url-scheme-handler)
+ [ $# -eq 2 ] || exit_failure_syntax "unexpected/missing argument"
+ check_desktop_filename "$2"
+ set_url_scheme_handler_$DE "$1" "$2"
+ ;;
+
+ *)
+ exit_failure_syntax
+ ;;
+ esac
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+dispatch_generic()
+{
+ # We only know how to get or check the default web browser.
+ [ x"$op" != x"get" -a x"$op" != x"check" ] && exit_failure_operation_impossible
+ [ x"$parm" != x"default-web-browser" ] && exit_failure_operation_impossible
+
+ # First look in $BROWSER
+ if [ x"$BROWSER" != x ]; then
+ binary="`which "${BROWSER%%:*}"`"
+ else
+ # Debian and Ubuntu (and others?) have x-www-browser.
+ binary="`which x-www-browser`"
+ fi
+
+ [ "$binary" ] || exit_failure_operation_failed
+
+ binary="`readlink -f "$binary"`"
+
+ [ "$binary" ] || exit_failure_operation_failed
+
+ if [ x"$op" = x"get" ]; then
+ desktop="`binary_to_desktop_file "$binary"`"
+ basename "$desktop"
+ else
+ # $op = "check"
+ check="`desktop_file_to_binary "$1"`"
+ if [ -z "$check" ]; then
+ echo no
+ exit_success
+ fi
+ if [ x"$binary" != x"$check" ]; then
+ echo no
+ exit_success
+ fi
+ echo yes
+ fi
+ exit_success
+}
+
+if [ x"$1" = x"--list" ]; then
+ echo "Known properties:"
+ # Extract the property names from dispatch_specific() above.
+ grep "^[ ]*[^)]*) # PROP:" "$0" | sed -e 's/^[ ]*\([^)]*\)) # PROP: \(.*\)$/ \1 \2/' | sort
+ exit_success
+fi
+
+[ x"$1" != x ] || exit_failure_syntax "no operation given"
+[ x"$2" != x ] || exit_failure_syntax "no parameter name given"
+[ x"$1" = x"get" -o x"$3" != x ] || exit_failure_syntax "no parameter value given"
+
+op="$1"
+parm="$2"
+shift 2
+
+if [ x"$op" != x"get" -a x"$op" != x"check" -a x"$op" != x"set" ]; then
+ exit_failure_syntax "invalid operation"
+fi
+
+detectDE
+
+case "$DE" in
+ kde|gnome*|xfce)
+ dispatch_specific "$@"
+ ;;
+
+ generic)
+ dispatch_generic "$@"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "unknown desktop environment"
+ ;;
+esac
diff --git a/scripts/xdg-su b/scripts/xdg-su
new file mode 100755
index 0000000..88cf228
--- /dev/null
+++ b/scripts/xdg-su
@@ -0,0 +1,438 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-su
+#
+# Utility script to run a command as an alternate user, generally
+# the root user, with a graphical prompt for the root
+# password if needed
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-su - run a GUI program as root after prompting for the root password
+
+Synopsis
+
+xdg-su [-u user] -c command
+
+xdg-su { --help | --manual | --version }
+
+Description
+
+xdg-su provides a graphical dialog that prompts the user for a password to run
+command as user or as root if no user was specified.
+
+xdg-su is for use inside a desktop session only.
+
+xdg-su discards any stdout and stderr output from command.
+
+Options
+
+-u user
+ run command as user. The default is to run as root.
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+2
+ One of the files passed on the command line did not exist.
+3
+ A required tool could not be found.
+4
+ The action failed.
+
+See Also
+
+su(1)
+
+Examples
+
+xdg-su -u root -c "/opt/shinythings/bin/install-GUI --install fast"
+
+Runs the /opt/shinythings/bin/install-GUI command with root permissions.
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-su - run a GUI program as root after prompting for the root password
+
+Synopsis
+
+xdg-su [-u user] -c command
+
+xdg-su { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-su: $@" >&2
+ echo "Try 'xdg-su --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-su' or 'xdg-su --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-su: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-su: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-su: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-su: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-su: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-su: filename '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example filename is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-su --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-su' or 'xdg-su --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-su 1.0beta2"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ fi
+}
+
+#----------------------------------------------------------------------------
+
+
+
+su_kde()
+{
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ KDESU=`kde4-config --locate kdesu --path exe 2>/dev/null`
+ else
+ KDESU=`which kdesu 2>/dev/null`
+ fi
+ if [ $? -eq 0 ] ; then
+ if [ -z "$user" ] ; then
+ $KDESU -c "$cmd"
+ else
+ $KDESU -u "$user" -c "$cmd"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ su_generic
+ fi
+}
+
+su_gnome()
+{
+ GSU=`which gnomesu 2>/dev/null`
+ if [ $? -ne 0 ] ; then
+ GSU=`which xsu 2>/dev/null`
+ fi
+ if [ $? -eq 0 ] ; then
+ if [ -z "$user" ] ; then
+ $GSU -c "$cmd"
+ else
+ $GSU -u "$user" -c "$cmd"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ su_generic
+ fi
+}
+
+su_generic()
+{
+ if [ -z "$user" ] ; then
+ xterm -geom 60x5 -T "xdg-su: $cmd" -e su -c "$cmd"
+ else
+ xterm -geom 60x5 -T "xdg-su: $cmd" -e su -c "$cmd" "$user"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+user=
+cmd=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -u)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "user argument missing for -u"
+ fi
+ user="$1"
+ shift
+ ;;
+
+ -c)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "command argument missing for -c"
+ fi
+ cmd="$1"
+ shift
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ exit_failure_syntax "unexpected argument '$parm'"
+ ;;
+ esac
+done
+
+if [ -z "${cmd}" ] ; then
+ exit_failure_syntax "command missing"
+fi
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ XSU=`which xsu 2>/dev/null`
+ if [ $? -eq 0 ] ; then
+ DE=generic
+ fi
+fi
+
+case "$DE" in
+ kde)
+ su_kde
+ ;;
+
+ gnome)
+ su_gnome
+ ;;
+
+ generic)
+ su_generic
+ ;;
+
+ *)
+ [ x"$user" = x"" ] && user=root
+ exit_failure_operation_impossible "no graphical method available for invoking '$cmd' as '$user'"
+ ;;
+esac
diff --git a/scripts/xdg-su.in b/scripts/xdg-su.in
new file mode 100644
index 0000000..5985e8a
--- /dev/null
+++ b/scripts/xdg-su.in
@@ -0,0 +1,161 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-su
+#
+# Utility script to run a command as an alternate user, generally
+# the root user, with a graphical prompt for the root
+# password if needed
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Jeremy White <jwhite@codeweavers.com>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+su_kde()
+{
+ if [ x"$KDE_SESSION_VERSION" = x"4" ]; then
+ KDESU=`kde4-config --locate kdesu --path exe 2>/dev/null`
+ else
+ KDESU=`which kdesu 2>/dev/null`
+ fi
+ if [ $? -eq 0 ] ; then
+ if [ -z "$user" ] ; then
+ $KDESU -c "$cmd"
+ else
+ $KDESU -u "$user" -c "$cmd"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ su_generic
+ fi
+}
+
+su_gnome()
+{
+ GSU=`which gnomesu 2>/dev/null`
+ if [ $? -ne 0 ] ; then
+ GSU=`which xsu 2>/dev/null`
+ fi
+ if [ $? -eq 0 ] ; then
+ if [ -z "$user" ] ; then
+ $GSU -c "$cmd"
+ else
+ $GSU -u "$user" -c "$cmd"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ su_generic
+ fi
+}
+
+su_generic()
+{
+ if [ -z "$user" ] ; then
+ xterm -geom 60x5 -T "xdg-su: $cmd" -e su -c "$cmd"
+ else
+ xterm -geom 60x5 -T "xdg-su: $cmd" -e su -c "$cmd" "$user"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+[ x"$1" != x"" ] || exit_failure_syntax
+
+user=
+cmd=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -u)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "user argument missing for -u"
+ fi
+ user="$1"
+ shift
+ ;;
+
+ -c)
+ if [ -z "$1" ] ; then
+ exit_failure_syntax "command argument missing for -c"
+ fi
+ cmd="$1"
+ shift
+ ;;
+
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ exit_failure_syntax "unexpected argument '$parm'"
+ ;;
+ esac
+done
+
+if [ -z "${cmd}" ] ; then
+ exit_failure_syntax "command missing"
+fi
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ XSU=`which xsu 2>/dev/null`
+ if [ $? -eq 0 ] ; then
+ DE=generic
+ fi
+fi
+
+case "$DE" in
+ kde)
+ su_kde
+ ;;
+
+ gnome*|lxde)
+ su_gnome
+ ;;
+
+ generic)
+ su_generic
+ ;;
+
+ *)
+ [ x"$user" = x"" ] && user=root
+ exit_failure_operation_impossible "no graphical method available for invoking '$cmd' as '$user'"
+ ;;
+esac
diff --git a/scripts/xdg-terminal b/scripts/xdg-terminal
new file mode 100755
index 0000000..ab7dec7
--- /dev/null
+++ b/scripts/xdg-terminal
@@ -0,0 +1,484 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-terminal
+#
+# Utility script to open the registered terminal emulator
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+#
+# LICENSE:
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+Name
+
+xdg-terminal - opens the user's preferred terminal emulator application
+
+Synopsis
+
+xdg-terminal [command]
+
+xdg-terminal { --help | --manual | --version }
+
+Description
+
+xdg-terminal opens the user's preferred terminal emulator application. If a
+command is provided the command will be executed by the shell within the newly
+opened terminal window.
+
+xdg-terminal is for use inside a desktop session only. It is not recommended to
+use xdg-terminal as root.
+
+Options
+
+--help
+ Show command synopsis.
+--manual
+ Show this manualpage.
+--version
+ Show the xdg-utils version information.
+
+Exit Codes
+
+An exit code of 0 indicates success while a non-zero exit code indicates
+failure. The following failure codes can be returned:
+
+1
+ Error in command line syntax.
+3
+ A required tool could not be found.
+4
+ The action failed.
+
+Examples
+
+xdg-terminal
+
+Opens the user's default terminal emulator, just starting an interactive shell.
+
+xdg-terminal top
+
+Opens the user's default terminal emulator and lets it run the top executable.
+
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+xdg-terminal - opens the user's preferred terminal emulator application
+
+Synopsis
+
+xdg-terminal [command]
+
+xdg-terminal { --help | --manual | --version }
+
+_USAGE
+}
+
+#@xdg-utils-common@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-terminal: $@" >&2
+ echo "Try 'xdg-terminal --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man xdg-terminal' or 'xdg-terminal --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-terminal: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-terminal: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-terminal: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-terminal: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "xdg-terminal: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "xdg-terminal: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or 'xdg-terminal --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" -o ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man xdg-terminal' or 'xdg-terminal --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "xdg-terminal 1.0.2"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
+ else DE=""
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
+
+terminal_kde()
+{
+ terminal=`kreadconfig --file kdeglobals --group General --key TerminalApplication --default konsole`
+
+ terminal_exec=`which $terminal 2>/dev/null`
+
+ if [ -x "$terminal_exec" ]; then
+ if [ x"$1" == x"" ]; then
+ $terminal_exec
+ else
+ $terminal_exec -e "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible "configured terminal program '$terminal' not found or not executable"
+ fi
+}
+
+terminal_gnome()
+{
+ term_exec_key="/desktop/gnome/applications/terminal/exec"
+ term_exec_arg_key="/desktop/gnome/applications/terminal/exec_arg"
+
+ term_exec=`gconftool-2 --get ${term_exec_key}`
+ term_exec_arg=`gconftool-2 --get ${term_exec_arg_key}`
+
+ terminal_exec=`which $term_exec 2>/dev/null`
+
+ if [ -x "$terminal_exec" ]; then
+ if [ x"$1" == x"" ]; then
+ $terminal_exec
+ else
+ if [ x"$term_exec_arg" == x"" ]; then
+ $terminal_exec "$1"
+ else
+ $terminal_exec "$term_exec_arg" "$1"
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
+ fi
+}
+
+terminal_xfce()
+{
+ if [ x"$1" == x"" ]; then
+ exo-open --launch TerminalEmulator
+ else
+ exo-open --launch TerminalEmulator "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+terminal_generic()
+{
+ # if $TERM is not set, try xterm
+ if [ x"$TERM" == x"" ]; then
+ TERM=xterm
+ fi
+
+ terminal_exec=`which $TERM >/dev/null 2>/dev/null`
+
+ if [ -x "$terminal_exec" ]; then
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable"
+ fi
+}
+
+terminal_lxde()
+{
+ if which lxterminal &>/dev/null; then
+ if [ x"$1" == x"" ]; then
+ lxterminal
+ else
+ lxterminal -e "$1"
+ fi
+ else
+ terminal_generic "$1"
+ fi
+}
+
+#[ x"$1" != x"" ] || exit_failure_syntax
+
+command=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$command" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ command="$parm"
+ ;;
+ esac
+done
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ # if TERM variable is not set, try xterm
+ if [ x"$TERM" = x"" ]; then
+ TERM=xterm
+ fi
+ DE=generic
+fi
+
+case "$DE" in
+ kde)
+ terminal_kde "$command"
+ ;;
+
+ gnome)
+ terminal_gnome "$command"
+ ;;
+
+ xfce)
+ terminal_xfce "$command"
+ ;;
+
+ lxde)
+ terminal_lxde "$command"
+ ;;
+
+ generic)
+ terminal_generic "$command"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no terminal emulator available"
+ ;;
+esac
diff --git a/scripts/xdg-terminal.in b/scripts/xdg-terminal.in
new file mode 100644
index 0000000..614dacf
--- /dev/null
+++ b/scripts/xdg-terminal.in
@@ -0,0 +1,200 @@
+#!/bin/sh
+#---------------------------------------------
+# xdg-terminal
+#
+# Utility script to open the registered terminal emulator
+#
+# Refer to the usage() function below for usage.
+#
+# Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
+# Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
+# Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at>
+#
+# LICENSE:
+#
+#---------------------------------------------
+
+manualpage()
+{
+cat << _MANUALPAGE
+_MANUALPAGE
+}
+
+usage()
+{
+cat << _USAGE
+_USAGE
+}
+
+#@xdg-utils-common@
+
+terminal_kde()
+{
+ terminal=`kreadconfig --file kdeglobals --group General --key TerminalApplication --default konsole`
+
+ terminal_exec=`which $terminal 2>/dev/null`
+
+ if [ -x "$terminal_exec" ]; then
+ if [ x"$1" = x"" ]; then
+ $terminal_exec
+ else
+ # screen and urxvt won't do their own parsing of quoted arguments
+ if [ x"$TERM" = x"screen" ]; then
+ # screen has an incompatible meaning for -e
+ sh -c "exec $terminal_exec $1"
+ elif [ x"$TERM" = x"urxvt" ] || [ x"$TERM" = x"rxvt-unicode" ] || [ x"$TERM" = x"rxvt" ]; then
+ #TODO: Use whatever mechanism dash supports to test for
+ # rxvt-* to match things like rxvt-unicode-256color
+ sh -c "exec $terminal_exec -e $1"
+ else
+ $terminal_exec -e "$1"
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible "configured terminal program '$terminal' not found or not executable"
+ fi
+}
+
+terminal_gnome()
+{
+ term_exec_key="/desktop/gnome/applications/terminal/exec"
+ term_exec_arg_key="/desktop/gnome/applications/terminal/exec_arg"
+
+ term_exec=`gconftool-2 --get ${term_exec_key}`
+ term_exec_arg=`gconftool-2 --get ${term_exec_arg_key}`
+
+ terminal_exec=`which $term_exec 2>/dev/null`
+
+ if [ -x "$terminal_exec" ]; then
+ if [ x"$1" = x"" ]; then
+ $terminal_exec
+ else
+ if [ x"$term_exec_arg" = x"" ]; then
+ $terminal_exec "$1"
+ else
+ $terminal_exec "$term_exec_arg" "$1"
+ fi
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible "configured terminal program '$term_exec' not found or not executable"
+ fi
+}
+
+terminal_xfce()
+{
+ if [ x"$1" = x"" ]; then
+ exo-open --launch TerminalEmulator
+ else
+ exo-open --launch TerminalEmulator "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+}
+
+terminal_generic()
+{
+ # if $TERM is a known non-command, use hard-coded fallbacks
+ if [ x"$TERM" = x"" ] || [ x"$TERM" = x"linux" ] || [ x"$TERM" = x"vt100" ]; then
+ TERM=xterm
+ fi
+
+ terminal_exec=`which $TERM 2>/dev/null`
+
+ if [ -x "$terminal_exec" ]; then
+ if [ x"$1" = x"" ]; then
+ $terminal_exec
+ else
+ $terminal_exec -e "$1"
+ fi
+
+ if [ $? -eq 0 ]; then
+ exit_success
+ else
+ exit_failure_operation_failed
+ fi
+ else
+ exit_failure_operation_impossible "configured terminal program '$TERM' not found or not executable"
+ fi
+}
+
+terminal_lxde()
+{
+ if which lxterminal &>/dev/null; then
+ if [ x"$1" = x"" ]; then
+ lxterminal
+ else
+ lxterminal -e "$1"
+ fi
+ else
+ terminal_generic "$1"
+ fi
+}
+
+#[ x"$1" != x"" ] || exit_failure_syntax
+
+command=
+while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ -*)
+ exit_failure_syntax "unexpected option '$parm'"
+ ;;
+
+ *)
+ if [ -n "$command" ] ; then
+ exit_failure_syntax "unexpected argument '$parm'"
+ fi
+ command="$parm"
+ ;;
+ esac
+done
+
+detectDE
+
+if [ x"$DE" = x"" ]; then
+ DE=generic
+fi
+
+case "$DE" in
+ kde)
+ terminal_kde "$command"
+ ;;
+
+ gnome*)
+ terminal_gnome "$command"
+ ;;
+
+ xfce)
+ terminal_xfce "$command"
+ ;;
+
+ lxde)
+ terminal_lxde "$command"
+ ;;
+
+ generic)
+ terminal_generic "$command"
+ ;;
+
+ *)
+ exit_failure_operation_impossible "no terminal emulator available"
+ ;;
+esac
diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in
new file mode 100644
index 0000000..ddc86f5
--- /dev/null
+++ b/scripts/xdg-utils-common.in
@@ -0,0 +1,330 @@
+
+#----------------------------------------------------------------------------
+# Common utility functions included in all XDG wrapper scripts
+#----------------------------------------------------------------------------
+
+DEBUG()
+{
+ [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && return 0;
+ [ ${XDG_UTILS_DEBUG_LEVEL} -lt $1 ] && return 0;
+ shift
+ echo "$@" >&2
+}
+
+# This handles backslashes but not quote marks.
+first_word()
+{
+ read first rest
+ echo "$first"
+}
+
+#-------------------------------------------------------------
+# map a binary to a .desktop file
+binary_to_desktop_file()
+{
+ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ binary="`which "$1"`"
+ binary="`readlink -f "$binary"`"
+ base="`basename "$binary"`"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" ] || continue
+ [ -d "$dir/applications" ] || [ -d "$dir/applnk" ] || continue
+ for file in "$dir"/applications/*.desktop "$dir"/applications/*/*.desktop "$dir"/applnk/*.desktop "$dir"/applnk/*/*.desktop; do
+ [ -r "$file" ] || continue
+ # Check to make sure it's worth the processing.
+ grep -q "^Exec.*$base" "$file" || continue
+ # Make sure it's a visible desktop file (e.g. not "preferred-web-browser.desktop").
+ grep -Eq "^(NoDisplay|Hidden)=true" "$file" && continue
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command="`which "$command"`"
+ if [ x"`readlink -f "$command"`" = x"$binary" ]; then
+ # Fix any double slashes that got added path composition
+ echo "$file" | sed -e 's,//*,/,g'
+ return
+ fi
+ done
+ done
+}
+
+#-------------------------------------------------------------
+# map a .desktop file to a binary
+## FIXME: handle vendor dir case
+desktop_file_to_binary()
+{
+ search="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
+ desktop="`basename "$1"`"
+ IFS=:
+ for dir in $search; do
+ unset IFS
+ [ "$dir" ] && [ -d "$dir/applications" ] || continue
+ file="$dir/applications/$desktop"
+ [ -r "$file" ] || continue
+ # Remove any arguments (%F, %f, %U, %u, etc.).
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
+ command="`which "$command"`"
+ readlink -f "$command"
+ return
+ done
+}
+
+#-------------------------------------------------------------
+# Exit script on successfully completing the desired operation
+
+exit_success()
+{
+ if [ $# -gt 0 ]; then
+ echo "$@"
+ echo
+ fi
+
+ exit 0
+}
+
+
+#-----------------------------------------
+# Exit script on malformed arguments, not enough arguments
+# or missing required option.
+# prints usage information
+
+exit_failure_syntax()
+{
+ if [ $# -gt 0 ]; then
+ echo "@NAME@: $@" >&2
+ echo "Try '@NAME@ --help' for more information." >&2
+ else
+ usage
+ echo "Use 'man @NAME@' or '@NAME@ --manual' for additional info."
+ fi
+
+ exit 1
+}
+
+#-------------------------------------------------------------
+# Exit script on missing file specified on command line
+
+exit_failure_file_missing()
+{
+ if [ $# -gt 0 ]; then
+ echo "@NAME@: $@" >&2
+ fi
+
+ exit 2
+}
+
+#-------------------------------------------------------------
+# Exit script on failure to locate necessary tool applications
+
+exit_failure_operation_impossible()
+{
+ if [ $# -gt 0 ]; then
+ echo "@NAME@: $@" >&2
+ fi
+
+ exit 3
+}
+
+#-------------------------------------------------------------
+# Exit script on failure returned by a tool application
+
+exit_failure_operation_failed()
+{
+ if [ $# -gt 0 ]; then
+ echo "@NAME@: $@" >&2
+ fi
+
+ exit 4
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to read a specified file
+
+exit_failure_file_permission_read()
+{
+ if [ $# -gt 0 ]; then
+ echo "@NAME@: $@" >&2
+ fi
+
+ exit 5
+}
+
+#------------------------------------------------------------
+# Exit script on insufficient permission to write a specified file
+
+exit_failure_file_permission_write()
+{
+ if [ $# -gt 0 ]; then
+ echo "@NAME@: $@" >&2
+ fi
+
+ exit 6
+}
+
+check_input_file()
+{
+ if [ ! -e "$1" ]; then
+ exit_failure_file_missing "file '$1' does not exist"
+ fi
+ if [ ! -r "$1" ]; then
+ exit_failure_file_permission_read "no permission to read file '$1'"
+ fi
+}
+
+check_vendor_prefix()
+{
+ file_label="$2"
+ [ -n "$file_label" ] || file_label="filename"
+ file=`basename "$1"`
+ case "$file" in
+ [a-zA-Z]*-*)
+ return
+ ;;
+ esac
+
+ echo "@NAME@: $file_label '$file' does not have a proper vendor prefix" >&2
+ echo 'A vendor prefix consists of alpha characters ([a-zA-Z]) and is terminated' >&2
+ echo 'with a dash ("-"). An example '"$file_label"' is '"'example-$file'" >&2
+ echo "Use --novendor to override or '@NAME@ --manual' for additional info." >&2
+ exit 1
+}
+
+check_output_file()
+{
+ # if the file exists, check if it is writeable
+ # if it does not exists, check if we are allowed to write on the directory
+ if [ -e "$1" ]; then
+ if [ ! -w "$1" ]; then
+ exit_failure_file_permission_write "no permission to write to file '$1'"
+ fi
+ else
+ DIR=`dirname "$1"`
+ if [ ! -w "$DIR" ] || [ ! -x "$DIR" ]; then
+ exit_failure_file_permission_write "no permission to create file '$1'"
+ fi
+ fi
+}
+
+#----------------------------------------
+# Checks for shared commands, e.g. --help
+
+check_common_commands()
+{
+ while [ $# -gt 0 ] ; do
+ parm="$1"
+ shift
+
+ case "$parm" in
+ --help)
+ usage
+ echo "Use 'man @NAME@' or '@NAME@ --manual' for additional info."
+ exit_success
+ ;;
+
+ --manual)
+ manualpage
+ exit_success
+ ;;
+
+ --version)
+ echo "@NAME@ 1.1.0 rc1"
+ exit_success
+ ;;
+ esac
+ done
+}
+
+check_common_commands "$@"
+
+[ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL;
+if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then
+ # Be silent
+ xdg_redirect_output=" > /dev/null 2> /dev/null"
+else
+ # All output to stderr
+ xdg_redirect_output=" >&2"
+fi
+
+#--------------------------------------
+# Checks for known desktop environments
+# set variable DE to the desktop environments name, lowercase
+
+detectDE()
+{
+ # see https://bugs.freedesktop.org/show_bug.cgi?id=34164
+ unset GREP_OPTIONS
+
+ if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
+ case "${XDG_CURRENT_DESKTOP}" in
+ GNOME)
+ DE=gnome;
+ ;;
+ KDE)
+ DE=kde;
+ ;;
+ LXDE)
+ DE=lxde;
+ ;;
+ XFCE)
+ DE=xfce
+ esac
+ fi
+
+ if [ x"$DE" = x"" ]; then
+ # classic fallbacks
+ if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
+ elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome;
+ elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE=mate;
+ 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;
+ elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
+ elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE=xfce
+ fi
+ fi
+
+ if [ x"$DE" = x"" ]; then
+ # fallback to checking $DESKTOP_SESSION
+ case "$DESKTOP_SESSION" in
+ gnome)
+ DE=gnome;
+ ;;
+ LXDE|Lubuntu)
+ DE=lxde;
+ ;;
+ xfce|xfce4|'Xfce Session')
+ DE=xfce;
+ ;;
+ esac
+ fi
+
+ if [ x"$DE" = x"" ]; then
+ # fallback to uname output for other platforms
+ case "$(uname 2>/dev/null)" in
+ Darwin)
+ DE=darwin;
+ ;;
+ esac
+ fi
+
+ if [ x"$DE" = x"gnome" ]; then
+ # gnome-default-applications-properties is only available in GNOME 2.x
+ # but not in GNOME 3.x
+ which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3"
+ fi
+}
+
+#----------------------------------------------------------------------------
+# kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4
+# It also always returns 1 in KDE 3.4 and earlier
+# Simply return 0 in such case
+
+kfmclient_fix_exit_code()
+{
+ version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'`
+ major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'`
+ minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'`
+ release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'`
+ test "$major" -gt 3 && return $1
+ test "$minor" -gt 5 && return $1
+ test "$release" -gt 4 && return $1
+ return 0
+}
diff --git a/scripts/xsl/README b/scripts/xsl/README
new file mode 100644
index 0000000..620ecdd
--- /dev/null
+++ b/scripts/xsl/README
@@ -0,0 +1,23 @@
+Here you find some XSL transformation scripts for processing mime
+type definitions in XML format as defined by the Shared MIME-info Database
+specification [1]
+
+xdg-mime actually embeds a version of these scripts, the versions in this
+directory are for entertainment purposes only
+
+[1] http://www.freedesktop.org/wiki/Standards/shared-mime-info-spec
+===
+Command: xsltproc sharedmime-list.xsl input-file.xml
+
+Lists all mimetypes contained in a shared mime Database XML input file
+===
+Command: xsltproc --stringparam type mime/type \
+ --stringparam source input-file.xml \
+ sharedmime2mimelnk.xsl /path/to/input-file.xml
+
+Converts the mimetype "mime/type" contained in a shared mime Database XML
+input file into KDE's mimelnk format.
+===
+TODO:
+* Add support for magic entries and convert to KDE magic chunks in
+ share/config/magic/*
diff --git a/scripts/xsl/refentry2htmlindex.xsl b/scripts/xsl/refentry2htmlindex.xsl
new file mode 100644
index 0000000..caabb32
--- /dev/null
+++ b/scripts/xsl/refentry2htmlindex.xsl
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="html"
+ encoding="UTF-8"
+ omit-xml-declaration="yes"
+ indent="no"/>
+<xsl:template match="/">
+ <xsl:for-each select='refentry/refnamediv'>
+ <xsl:variable name="href">
+ <xsl:value-of select="refname"/>
+ <xsl:text>.html</xsl:text>
+ </xsl:variable>
+ <tr>
+ <td><a href="{$href}"><xsl:value-of select="refname"/></a>:</td>
+ <td><xsl:value-of select="refpurpose"/></td>
+ </tr>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/scripts/xsl/sharedmime-list.xsl b/scripts/xsl/sharedmime-list.xsl
new file mode 100644
index 0000000..3e6a9d0
--- /dev/null
+++ b/scripts/xsl/sharedmime-list.xsl
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info">
+<xsl:output method="text"
+ encoding="UTF-8"
+ indent="no"/>
+<xsl:template match="/">
+ <xsl:for-each select='mime:mime-info/mime:mime-type'>
+ <xsl:value-of select="@type"/><xsl:text>&#10;</xsl:text>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/scripts/xsl/sharedmime2mimelnk.xsl b/scripts/xsl/sharedmime2mimelnk.xsl
new file mode 100644
index 0000000..b5b42e5
--- /dev/null
+++ b/scripts/xsl/sharedmime2mimelnk.xsl
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info">
+<xsl:output method="text"
+ encoding="UTF-8"
+ indent="no"/>
+<xsl:template match="/">
+ <xsl:for-each select='mime:mime-info/mime:mime-type[@type=$type]'>
+ <xsl:text>[Desktop Entry]&#10;</xsl:text>
+ <xsl:text># Installed by xdg-mime from </xsl:text><xsl:value-of select="$source"/><xsl:text>&#10;</xsl:text>
+ <xsl:text>Type=MimeType&#10;</xsl:text>
+ <xsl:text>MimeType=</xsl:text><xsl:value-of select="@type"/><xsl:text>&#10;</xsl:text>
+ <xsl:text>Icon=</xsl:text><xsl:value-of select="translate(@type,'/','-')"/><xsl:text>&#10;</xsl:text>
+ <xsl:if test="mime:sub-class-of">
+ <xsl:text>X-KDE-IsAlso=</xsl:text><xsl:value-of select="mime:sub-class-of/@type"/><xsl:text>&#10;</xsl:text>
+ </xsl:if>
+ <xsl:if test="mime:glob">
+ <xsl:text>Patterns=</xsl:text>
+ <xsl:for-each select='mime:glob[@pattern]'>
+ <xsl:value-of select="@pattern"/><xsl:text>;</xsl:text>
+ </xsl:for-each>
+ <xsl:text>&#10;</xsl:text>
+ </xsl:if>
+ <xsl:text>Comment=</xsl:text><xsl:value-of select="mime:comment[not(@xml:lang)]"/><xsl:text>&#10;</xsl:text>
+ <xsl:for-each select='mime:comment[@xml:lang]'>
+ <xsl:sort select='@xml:lang'/>
+ <xsl:text>Comment[</xsl:text><xsl:value-of select="@xml:lang"/><xsl:text>]=</xsl:text><xsl:value-of select="."/><xsl:text>&#10;</xsl:text>
+ </xsl:for-each>
+ </xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..f3c7a7c
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+Makefile
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..c57b0e0
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,45 @@
+MKDIR = mkdir -p
+RMDIR = rmdir
+INSTALL = @INSTALL@ $(INSTALL_FLAGS)
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
+INSTALL_LIBRARY = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
+INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
+XMLTO = @XMLTO@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+
+all:
+
+release:
+ rm -rf xdg-su tmp
+ rm -f xdg-test.log *~
+
+test:
+ ./testrun -IRC
+ rm -rf tmp/xdgt*
+
+distclean: clean
+ rm -f Makefile
+
+clean:
+ rm -rf tmp/xdgt*
+
+tests-userclean:
+ find ${HOME} -name 'xdgtestdata*' | xargs rm -rf
+ find ${HOME} -name 'x-xdg*.xml' | xargs rm -f
+ find ${HOME}/.kde/share/mimelnk -name 'x-xdg*.desktop' | xargs rm -f
+
+tests-clean: tests-userclean
+ find `echo "${XDG_DATA_DIRS}:/usr/local/share/:/usr/share/:${XDG_CONFIG_DIRS}:/etc/xdg" | sed -e 's/:/ /g'` -name 'xdgtestdata*' | xargs rm -rf
+ find `echo "${XDG_DATA_DIRS}:/usr/local/share/:/usr/share/:${XDG_CONFIG_DIRS}:/etc/xdg" | sed -e 's|:| |g'` -name 'x-xdgt*' | xargs rm -f
+
+install:
+
+uninstall:
+
+doc:
+ perl doc_gen.pl
diff --git a/tests/NOTES b/tests/NOTES
new file mode 100644
index 0000000..9e37376
--- /dev/null
+++ b/tests/NOTES
@@ -0,0 +1,8 @@
+Test notes for xdg-desktop-icon
+-------------------------------
+1. Double install behavior is not well defined. Should installing two files with the same name onto the desktop generate errors, or should the older be overwritten?
+
+
+Test notes for xdg-email
+------------------------
+1. When running --attach tests, there is a bug in evolution (SUSE 10.0/Gnome) so that the attachment window is not displayed, yet there is still an attachment present. To see it, you must attach a second file.
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..26469f2
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,124 @@
+README: xdg-utils tests
+
+Created 6/27/2006 by Tom Whipple <tom.whipple@intel.com>
+
+
+RUNNING XDG-UTILS TESTS
+-----------------------
+At a minimum, you must have your current directory be the same as the
+directory containing this README. Then, simply execute:
+
+$ ./testrun
+WARNING: guessed XDG_TEST_DIR to be /home/tw/portland/xdg-utils/tests
+TEST_LIST: generic_bogus_arg-1-1 ... generic_version-1-50
+...
+FAIL: test_user_mime_install
+NORESULT: test_system_mime_install
+71 of 92 tests passed. (114 attempted)
+See xdg-test.log for details.
+NOT OK!
+
+FAIL indicates (not suprisingly) a test failure.
+NORESULT indicates that the test prerequisites failed for some reason.
+ (e.g. the install phase of an uninstall test failed)
+UNTESTED means that something needed was not found. This is fine and should
+ be ignored. These tests are not counted in the total, only attempted.
+ (e.g. test requires root, but we are not running as root)
+
+NOTE: The test runner makes guesses about appropriate values of XDG_TEST_DIR
+ and PATH. These values can be overriden explicitly.
+
+To run tests individually, or as smaller groups do something like
+
+$ ./testrun xdg-mime
+
+OR
+
+$ ./testrun xdg-mime/t.10-user_mime_install
+
+OR (if you have defined XDG_TEST_DIR and PATH correctly)
+
+$ xdg-mime/t.10-user_mime_install
+
+
+BACKUPS
+-------
+THESE TESTS CHANGE YOUR USER ENVIRONMENT. Effort is made to keep pollution
+to a minimum, but we make no guarantees!! Back up your environment/system
+early and often. This is especially critical if you run tests as root. You
+have been warned.
+
+
+INTERACTIVE TESTS
+-----------------
+Because it is difficult to verify the way things appear to the user, some
+tests are interactive and require the user to verify or perform actions.
+This is sometimes annoying, so interactive tests can be disabled with the
+-I flag. Note that if you run tests non-interactively, some tests
+(xdg-email) may generate strange errors on the screen, since the test
+cleans up support files before the email client tries to read them. Use
+the -C option to work around this.
+
+
+PRIVILEGED TESTS
+---------------
+BACK UP YOUR SYSTEM. See above.
+
+Some tests require root (e.g. those commands with a --system option). So,
+tests in this group return UNTESTED if they are not run as root.
+
+The test runner will ask for the root password in order to run these tests
+as the root user.
+
+
+CLEANUP
+-------
+Tests should clean up after themselves. However, this sometimes fails,
+so use 'sudo make tests-clean' or 'make tests-userclean'.
+(Note that you must have generated a makefile via 'cd .. && ./configure'
+at some point.)
+
+
+DIRECTORY STRUCTURE
+-------------------
+xdg-* tests for each util
+include "library" code used by most tests
+generic generic tests to be run on most utilities.
+ See xdg-mime/t.apply_generic
+
+
+WRITING XDG-UTILS TESTS
+-----------------------
+See xdg-mime/t.10-user_mime_install as an example.
+
+Each test is as follows
+
+test_function() { -- Tests are functions for TET integration.
+
+test_start "test description" -- required to begin a test
+test_purpose "verbose text" -- optionally provide a verbose description.
+ not used.
+test_init -- optionally begin a prerequisite section.
+ assertions that fail here cause NORESULT
+ rather than FAIL
+<pre-assertions>
+test_procedure -- required to begin the actuall test
+ assertions
+<test-assertions>
+
+test_result -- required to generate result codes.
+ Must be last.
+}
+
+run_test test_function
+ - OR -
+repeat_test test_function NVARS V1 ... VN V1val1 ... V1valM ... VNval1 ... VNvalM
+ -- one of the above is required.
+ see include/testcontrol.sh for detail
+
+
+For questions or feedback, please use the Portland mailinglist at
+http://lists.freedesktop.org/mailman/listinfo/portland
+
+Test results can be submitted on
+http://portland.freedesktop.org/testreport.html
diff --git a/tests/TODO b/tests/TODO
new file mode 100644
index 0000000..6bd84cf
--- /dev/null
+++ b/tests/TODO
@@ -0,0 +1,23 @@
+xdg-utils test TODO list:
+
+1. Test the following not-called options:
+xdg-desktop-icon
+ --novendor
+xdg-desktop-menu
+ --novendor
+xdg-email
+ --utf8
+xdg-icon-resource
+ --novendor
+ --theme
+ --context
+
+2. Better test the following poorly tested options:
+xdg-desktop-menu
+ --noupdate
+xdg-icon-resource
+ --noupdate
+
+3. Make the shinythings/webmirror example into a test case. All parts are currently tested, so this _should_ be an easy pass.
+
+4. Modify testrun and include/testcontrol.sh to print the file name of the test being run, rather than the function name. This is more difficult than it would seem, since the framework is designed to be run by TET for interoperability with the LSB effort. TET mandates that tests be functions named ic1 ... icN. Additionally, the framework allows tests to be repeated.
diff --git a/tests/debug/README b/tests/debug/README
new file mode 100644
index 0000000..1a15fd5
--- /dev/null
+++ b/tests/debug/README
@@ -0,0 +1,5 @@
+The "tests" in this directory are here to verify the functionality of the test suite itself. Likely these tests are not useful to a general audience.
+
+You should probably not do anything with them unless you have a good idea what they do.
+
+Questions should be addressed to the test developer: Tom Whipple <mail@tomwhipple.com>
diff --git a/tests/debug/t.extraout b/tests/debug/t.extraout
new file mode 100755
index 0000000..ea84b33
--- /dev/null
+++ b/tests/debug/t.extraout
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_extraout() {
+test_start "$FUNCNAME: verify functionallity of assert_nostdout"
+
+test_procedure
+
+assert_exit 0 echo foobar
+assert_nostdout
+
+test_result
+}
+
+run_test test_extraout
diff --git a/tests/debug/t.failoverride b/tests/debug/t.failoverride
new file mode 100755
index 0000000..c3cf257
--- /dev/null
+++ b/tests/debug/t.failoverride
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_verify_failoverride() {
+test_start "$FUNCNAME: verify it works to change a fail to a warn"
+
+test_procedure
+
+test_fail "Manual failure"
+
+test_failoverride WARN
+test_result
+}
+
+run_test test_verify_failoverride
diff --git a/tests/debug/t.interactive b/tests/debug/t.interactive
new file mode 100755
index 0000000..fa203c2
--- /dev/null
+++ b/tests/debug/t.interactive
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_interactive() {
+test_start "$FUNCNAME: verify functionallity of assert_interactive"
+
+test_procedure
+
+assert_interactive "Enter 'y'" y
+assert_interactive "Enter 'n'" n
+assert_interactive "neg Enter 'y'" n
+assert_interactive "neg Enter 'n'" y
+assert_interactive "Wait"
+
+test_result
+}
+
+run_test test_interactive
diff --git a/tests/debug/t.nodisplay b/tests/debug/t.nodisplay
new file mode 100755
index 0000000..b50b206
--- /dev/null
+++ b/tests/debug/t.nodisplay
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+
+test_nodisplay() {
+
+test_start "$FUNCNAME: verify display is not set."
+
+test_init
+
+echo '#!/bin/bash' > showdisp.sh
+echo '(echo "DISPLAY:($DISPLAY)")' >> showdisp.sh
+
+chmod 755 showdisp.sh
+
+echo "Display before: '$DISPLAY'"
+set_no_display
+echo "Display after: '$DISPLAY'"
+
+test_procedure
+
+echo "Display in procedure: '$DISPLAY'"
+
+assert_exit 0 ./showdisp.sh
+assert_stdout
+assert_nostderr
+
+cat out.stdout
+
+test_result
+}
+
+run_test test_nodisplay
diff --git a/tests/debug/t.var_bleed b/tests/debug/t.var_bleed
new file mode 100755
index 0000000..f0fb0ed
--- /dev/null
+++ b/tests/debug/t.var_bleed
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_var_bleed_set() {
+test_start "$FUNCNAME: set the BLEEDTEST variable"
+
+test_procedure
+
+export BLEED1=i_am_set
+BLEED2=set
+assert_exit 0 export BLEED3="set_within_assert_exit"
+
+test_result
+}
+
+test_var_bleed_read() {
+test_start "$FUNCNAME: read the BLEEDTEST variable"
+
+
+test_procedure
+
+assert_exit 0 echo -n "$BLEED1"
+assert_nostdout
+assert_nostderr
+
+assert_exit 0 echo -n "$BLEED2"
+assert_nostdout
+assert_nostderr
+
+assert_exit 0 echo -n "$BLEED3"
+assert_nostdout
+assert_nostderr
+
+assert_exit 0 echo -n "$BLEED4"
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+test_stdout_capture() {
+test_start "$FUNCNAME: stdout capture test. note: FAIL=PASS"
+
+assert_exit 0 echo -n "some output"
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+run_test test_var_bleed_set
+run_test test_var_bleed_read
+run_test test_stdout_capture
diff --git a/tests/doc_gen.pl b/tests/doc_gen.pl
new file mode 100755
index 0000000..ed29d94
--- /dev/null
+++ b/tests/doc_gen.pl
@@ -0,0 +1,164 @@
+#!perl
+
+use Data::Dumper;
+
+my @test_files = split('\s+',`ls generic/t.* xdg-*/t.*`);
+
+my $cvs_pre = "http://webcvs.freedesktop.org/portland/portland/xdg-utils/tests/";
+my $cvs_post = '?view=markup';
+my $assert_doc = "assertions.html";
+my $now = scalar localtime;
+my $style = "<style type=\"text/css\" media=\"all\">@import url(\"layout.css\");</style></head>\n";
+my $root_header = qq{| <a href="index.html">Tests</a> | <a href="$assert_doc">Assertions</a> | <a href="http://portland.freedesktop.org/wiki/WritingXdgTests">Overview</a> |<hr/>\n};
+my $group_header = qq{| <a href="../index.html">Tests</a> | <a href="../$assert_doc">Assertions</a> | <a href="http://portland.freedesktop.org/wiki/WritingXdgTests">Overview</a> |<hr/>\n};
+my $footer = "<hr><font size=\"-1\">xdg-utils test documentation generated $now</font>\n";
+
+my %fcns;
+
+my %group;
+my %shortdesc;
+
+## Read assertion file
+open IN, 'include/testassertions.sh' or die "Failed to open assertion file: $!\n";
+my $state = 'NULL';
+my %assertions;
+while ( <IN> ) {
+ if ( m/(\w+)\s*\(\)/ ) {
+ $state = $1;
+ $assertions{$state} = ();
+ }
+ elsif ( $state ne 'NULL' and m/^#(.*)/ ) {
+ my $txt = $1;
+ chomp $txt;
+ push @{ $assertions{$state} }, $txt;
+ }
+ else {
+ $state = 'NULL';
+ }
+}
+close IN;
+
+if ( ! -d 'doc' ) { mkdir 'doc'; }
+
+open OUT, ">doc/$assert_doc" or die "Failed to open $assert_doc: $!\n";
+print OUT "<html><head><title>xdg-utils test assertions</title>$style</head><body>\n$root_header";
+
+my @s_assert = sort keys %assertions ;
+print OUT qq{<h2>Defined Assertions in <a href="$cvs_pre}.qq{include/testassertions.sh$cvs_post">include/testassertions.sh</a></h2>\n};
+for $a ( @s_assert ) {
+ print OUT qq{<a href="#$a">$a</a><br>\n};
+}
+for $a ( @s_assert ) {
+ print OUT qq{<hr><h2><a name="$a">$a</a></h2>\n};
+ print OUT "<pre>", join("\n",@{ $assertions{$a} } ), "</pre>\n";
+}
+print OUT "$footer</body></html>";
+
+
+## Read test files
+for $f ( @test_files ) {
+ open IN, $f or die "Failed to open $f: $!\n";
+ $f =~ m{(.+)/t\.(.+)};
+ my $dir = $1;
+ my $test = $2;
+ `mkdir -p doc/$dir`;
+ my $o = "doc/$dir/$test.html";
+
+ push @{ $group{$dir} }, $test;
+
+ open HTM, ">$o" or die "Failed to open '$o': $!\n";
+ print HTM "<html><head><title>xdg-utils test: $f</title>\n";
+ print HTM $style;
+
+ print HTM "<body>$group_header<h1>Test: <a href=\"$cvs_pre$f$cvs_post\">$f</a></h1><hr/>\n";
+ my $fcn = '';
+ my $state = 'BEGIN';
+ while ( <IN> ) {
+ #find the test function
+ if ( m/(\w+)\s*\(\)/ ) {
+ $fcn = $1;
+ if (defined $fcns{$fcn} ){
+ print "WARNING in $f: $fcn already exists in $fcns{$fcn}!\n"
+ }
+ $fcns{$fcn} = $f;
+ $state = 'FUNCTION';
+ }
+ #find test_start
+ elsif ( m/test_start (.*)/ ) {
+ print HTM "<h2>Purpose of $fcn</h2>";
+ my $txt = $1;
+ $txt =~ s/\$FUNCNAME:*\s*//;
+ $txt =~ s/\"//g;
+ $shortdesc{ $test } = $txt;
+ print HTM "<p>$txt</p>\n";
+ $state = 'START';
+ }
+ #find test_purpose
+ elsif ( m/test_purpose (.*)/ ) {
+ print HTM "<h2>Description</h2>";
+ my $txt = $1;
+ $txt =~ s/\"//g;
+ print HTM "<p>$txt</p>\n";
+ }
+ #find initilization
+ elsif ( m/test_init/ ) {
+ print HTM "<h2>Depencencies</h2>\n";
+ $state = 'INIT';
+ next;
+ }
+ elsif ( m/test_procedure/ ) {
+ print HTM "<h2>Test Procedure</h2>\n";
+ $state = 'TEST';
+ next;
+ }
+ elsif ( m/test_note (.*)/ ) {
+ print HTM "<h2>Note</h2><p>$1</p>\n";
+ next;
+ }
+ elsif ( m/test_result/ ) {
+ $state = 'DONE';
+ }
+ if ( m/^#/ ) {
+ next;
+ }
+ if ( $state eq 'INIT' or $state eq 'TEST' ) {
+ $line = $_;
+ $line =~ s/^\s*(\w+)/<a href="\.\.\/$assert_doc#$1">$1<\/a>/;
+ if ( $assertions{$1} ) {
+ print HTM "<p>$line</p>\n";
+ #print "$f:\t'$1' found\n";
+ }
+ else {
+ #print "$f:\t'$1' not found\n";
+ print HTM "<p>$_</p>\n";
+ }
+ #print HTM "<p>$_</p>\n";
+ }
+ }
+ print HTM "$footer</body></html>\n";
+ close HTM;
+ close IN;
+}
+
+open INDEX, ">doc/index.html" or die "Could not open index: $!";
+print INDEX "<html><head><title>xdg-utils test suite</title>\n";
+print INDEX $style;
+
+print INDEX "<body>$root_header<h1>xdg-utils test documentation</h1>";
+
+my @s_groups = sort keys %group;
+
+for $g ( @s_groups ) {
+ print INDEX qq{<a href="#$g">$g</a> \n};
+}
+print INDEX "<table border=0>\n";
+for $k ( @s_groups ) {
+ print INDEX qq{<tr><td colspan=2><hr><h2><a name="$k">$k</a></h2></td></tr>\n};
+ for $i ( @{ $group{$k} } ) {
+ print INDEX "<tr><td><a href=\"$k/$i.html\">$i</a></td><td>$shortdesc{$i}</td></tr>\n";
+ }
+}
+print INDEX "</table>$footer</body></html>\n";
+close INDEX;
+
+#print Dumper keys %assertions;
diff --git a/tests/generic/t.bogus_arg b/tests/generic/t.bogus_arg
new file mode 100755
index 0000000..d7c7f35
--- /dev/null
+++ b/tests/generic/t.bogus_arg
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+
+generic_bogus_arg() {
+test_start "$FUNCNAME: generic bogus argument $XDGUTIL"
+test_purpose "Ensure that $XDGUTIL exits with an error when called with an unsupported argument."
+
+# Dependencies section
+test_init
+
+assert_util_var
+set_no_display
+
+# Test steps section
+test_procedure
+
+assert_exit 1 "$XDGUTIL" "--fobar-bogus-arg"
+assert_nostdout
+assert_stderr
+
+test_result
+}
+GENERIC_TEST="generic_bogus_arg"
diff --git a/tests/generic/t.help b/tests/generic/t.help
new file mode 100755
index 0000000..15e5a58
--- /dev/null
+++ b/tests/generic/t.help
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+
+generic_help() {
+test_start "$FUNCNAME: generic help message - $XDGUTIL"
+test_purpose "Ensure that $XDGUTIL prints it's help message and exits with 0 when called with the --help argument."
+
+# Dependencies section
+test_init
+
+assert_util_var
+set_no_display
+
+# Test steps section
+test_procedure
+
+assert_exit 0 "$XDGUTIL" "--help"
+assert_stdout
+assert_nostderr
+
+test_result
+}
+GENERIC_TEST="generic_help"
diff --git a/tests/generic/t.manual b/tests/generic/t.manual
new file mode 100755
index 0000000..b1ad58b
--- /dev/null
+++ b/tests/generic/t.manual
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+
+generic_manual() {
+test_start "$FUNCNAME: generic manual - $XDGUTIL"
+test_purpose "Ensure that $XDGUTIL exits with an error and usage message when called without required arguments."
+
+# Dependencies section
+test_init
+
+assert_util_var
+set_no_display
+
+# Test steps section
+test_procedure
+
+assert_exit 0 "$XDGUTIL" "--manual"
+assert_stdout
+assert_nostderr
+
+test_result
+}
+GENERIC_TEST="generic_manual"
diff --git a/tests/generic/t.no_arg b/tests/generic/t.no_arg
new file mode 100755
index 0000000..412cd5d
--- /dev/null
+++ b/tests/generic/t.no_arg
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+
+generic_no_arg() {
+test_start "$FUNCNAME: generic noarg - $XDGUTIL"
+test_purpose "Ensure that $XDGUTIL exits with an error and usage message when called without required arguments."
+
+# Dependencies section
+test_init
+
+assert_util_var
+set_no_display
+
+# Test steps section
+test_procedure
+
+assert_exit 1 "$XDGUTIL"
+assert_stdout
+assert_nostderr
+
+test_result
+}
+GENERIC_TEST="generic_no_arg"
diff --git a/tests/generic/t.version b/tests/generic/t.version
new file mode 100755
index 0000000..0a0c3dd
--- /dev/null
+++ b/tests/generic/t.version
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+
+generic_version() {
+test_start "$FUNCNAME: generic version arg - $XDGUTIL"
+
+test_purpose "Ensure that $XDGUTIL prints the version information and exists with code 0."
+
+# Dependencies section
+test_init
+
+assert_util_var
+set_no_display
+
+# Test steps section
+test_procedure
+
+assert_exit 0 "$XDGUTIL" "--version"
+assert_stdout
+assert_nostderr
+
+test_result
+}
+GENERIC_TEST="generic_version"
diff --git a/tests/icons/red-128.png b/tests/icons/red-128.png
new file mode 100644
index 0000000..b970b10
--- /dev/null
+++ b/tests/icons/red-128.png
Binary files differ
diff --git a/tests/icons/red-128.xcf b/tests/icons/red-128.xcf
new file mode 100644
index 0000000..9c8b0d1
--- /dev/null
+++ b/tests/icons/red-128.xcf
Binary files differ
diff --git a/tests/icons/red-16.png b/tests/icons/red-16.png
new file mode 100644
index 0000000..d5c641b
--- /dev/null
+++ b/tests/icons/red-16.png
Binary files differ
diff --git a/tests/icons/red-16.xcf b/tests/icons/red-16.xcf
new file mode 100644
index 0000000..6ac81bc
--- /dev/null
+++ b/tests/icons/red-16.xcf
Binary files differ
diff --git a/tests/icons/red-22.png b/tests/icons/red-22.png
new file mode 100644
index 0000000..0567a1e
--- /dev/null
+++ b/tests/icons/red-22.png
Binary files differ
diff --git a/tests/icons/red-22.xcf b/tests/icons/red-22.xcf
new file mode 100644
index 0000000..22a2f9d
--- /dev/null
+++ b/tests/icons/red-22.xcf
Binary files differ
diff --git a/tests/icons/red-24.png b/tests/icons/red-24.png
new file mode 100644
index 0000000..eccdf93
--- /dev/null
+++ b/tests/icons/red-24.png
Binary files differ
diff --git a/tests/icons/red-24.xcf b/tests/icons/red-24.xcf
new file mode 100644
index 0000000..f33ba0d
--- /dev/null
+++ b/tests/icons/red-24.xcf
Binary files differ
diff --git a/tests/icons/red-32.png b/tests/icons/red-32.png
new file mode 100644
index 0000000..0fec0c8
--- /dev/null
+++ b/tests/icons/red-32.png
Binary files differ
diff --git a/tests/icons/red-32.xcf b/tests/icons/red-32.xcf
new file mode 100644
index 0000000..d181d0e
--- /dev/null
+++ b/tests/icons/red-32.xcf
Binary files differ
diff --git a/tests/icons/red-48.png b/tests/icons/red-48.png
new file mode 100644
index 0000000..27c70c1
--- /dev/null
+++ b/tests/icons/red-48.png
Binary files differ
diff --git a/tests/icons/red-48.xcf b/tests/icons/red-48.xcf
new file mode 100644
index 0000000..4e9e636
--- /dev/null
+++ b/tests/icons/red-48.xcf
Binary files differ
diff --git a/tests/icons/red-64.png b/tests/icons/red-64.png
new file mode 100644
index 0000000..4e6396f
--- /dev/null
+++ b/tests/icons/red-64.png
Binary files differ
diff --git a/tests/icons/red-64.xcf b/tests/icons/red-64.xcf
new file mode 100644
index 0000000..1999162
--- /dev/null
+++ b/tests/icons/red-64.xcf
Binary files differ
diff --git a/tests/icons/red-SVG.svg b/tests/icons/red-SVG.svg
new file mode 100644
index 0000000..21dfab5
--- /dev/null
+++ b/tests/icons/red-SVG.svg
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="80" y="110" width="300" height="180" viewBox="0 0 200 120">
+ <g fill="#FF0000" stroke="#FF0000" font-size="45" font-family="Sans">
+ <text>SVG</text>
+ </g>
+</svg>
diff --git a/tests/icons/red-template.xcf b/tests/icons/red-template.xcf
new file mode 100644
index 0000000..4a70dbd
--- /dev/null
+++ b/tests/icons/red-template.xcf
Binary files differ
diff --git a/tests/include/desktop_environment b/tests/include/desktop_environment
new file mode 100755
index 0000000..210f516
--- /dev/null
+++ b/tests/include/desktop_environment
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+## This script modified from one supplied by Bryce Harrington at OSDL
+
+which kde-config >/dev/null 2>&1
+if [ "$?" -eq 0 ]; then
+ # From Sutoka on FreeNode/#kde
+ kde_version=`kde-config --version | grep KDE | cut -d' ' -f2 2> /dev/null`
+ kde_running=$KDE_FULL_SESSION
+ if [ ! -z "$KDE_FULL_SESSION" ]; then
+ running="kde $running"
+ fi
+ echo "kde: $kde_version"
+else
+ echo "kde: not present (didn't find kde-config)"
+fi
+
+# From kees on #osdl
+which gnome-session >/dev/null 2>&1
+if [ "$?" -eq 0 ] ; then
+ gnome_version=`gnome-session --version | cut -d ' ' -f3 2>/dev/null`
+ echo "gnome: $gnome_version"
+
+ if [ ! -z "$GNOME_DESKTOP_SESSION_ID" ]; then
+ running="gnome $running"
+ fi
+else
+ echo "gnome: not present (didn't find gnome-session)"
+fi
+
+which xfce4-session >/dev/null 2>&1
+if [ "$?" -eq 0 ] ; then
+ xfce_version=`xfce4-session --version | grep '(Xfce ' | cut -d '(' -f 2 | cut -d ' ' -f2 | cut -d ')' -f1`
+ # From massonnet on FreeNode/#xfce
+ #if [ `pidof xfce4-session` ]; then
+ if [ "$GDMSESSION" = 'xfce4' ] ; then
+ running="xfce $running"
+ fi
+
+ echo "xfce: $xfce_version"
+else
+ echo "xfce: not present (didn't find xfce4-session)"
+fi
+
+if [ -z "$running" ] ; then
+ running='none'
+fi
+
+
+echo "running: $running "
+if [ `whoami` = 'root' ] ; then
+ echo "user: root"
+else
+ echo "user: normal"
+fi
+
diff --git a/tests/include/linux_distro b/tests/include/linux_distro
new file mode 100755
index 0000000..2cadca6
--- /dev/null
+++ b/tests/include/linux_distro
@@ -0,0 +1,209 @@
+#!/usr/bin/perl
+
+
+########################################################################
+
+package Linux::Distribution;
+
+use 5.006000;
+use strict;
+use warnings;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+
+our @EXPORT_OK = qw( distribution_name distribution_version );
+
+our $VERSION = '0.14.1';
+
+our $standard_release_file = 'lsb-release';
+
+our %primary_release_files = (
+ 'debian_version' => 'debian',
+ 'debian_release' => 'debian',
+ 'redhat-release' => 'redhat',
+ 'redhat_version' => 'redhat',
+);
+
+our %secondary_release_files = (
+ 'gentoo-release' => 'gentoo',
+ 'fedora-release' => 'fedora',
+ 'turbolinux-release' => 'turbolinux',
+ 'mandrake-release' => 'mandrake',
+ 'mandrakelinux-release' => 'mandrakelinux',
+ 'mandriva-release' => 'mandriva',
+ 'SuSE-release' => 'suse',
+ 'knoppix-version' => 'knoppix',
+ 'yellowdog-release' => 'yellowdog',
+ 'slackware-version' => 'slackware',
+ 'slackware-release' => 'slackware',
+ 'redflag-release' => 'redflag',
+ 'conectiva-release' => 'conectiva',
+ 'immunix-release' => 'immunix',
+ 'tinysofa-release' => 'tinysofa',
+ 'trustix-release' => 'trustix',
+ 'adamantix_version' => 'adamantix',
+ 'yoper-release' => 'yoper',
+ 'arch-release' => 'arch',
+ 'libranet_version' => 'libranet',
+ 'va-release' => 'va-linux',
+ 'xandros-desktop-version' => 'xandros',
+);
+
+our %version_match = (
+ 'gentoo' => 'Gentoo Base System version (.*)',
+ 'debian' => '(.+)',
+ 'suse' => 'VERSION = (.*)',
+ 'fedora' => 'Fedora Core release (\d+) \(',
+ 'redflag' => 'Red Flag (?:Desktop|Linux) (?:release |\()(.*?)(?: \(.+)?\)',
+ 'redhat' => 'Red Hat (?:Desktop|Linux) release (.*) \(',
+ 'slackware' => '^Slackware (.+)$',
+ 'mandriva' => 'Mandriva Linux release (\d+.\d+) \(',
+ 'arch' => 'Arch Linux (.*) \(',
+ 'xandros' => 'Version: Xandros Desktop OS (.+)'
+);
+
+
+if ($^O ne 'linux') {
+ require Carp;
+ Carp::croak 'you are trying to use a linux specific module on a different OS';
+}
+
+sub new {
+ my %self = (
+ 'DISTRIB_ID' => '',
+ 'DISTRIB_RELEASE' => '',
+ 'DISTRIB_CODENAME' => '',
+ 'DISTRIB_DESCRIPTION' => '',
+ 'release_file' => '',
+ 'pattern' => ''
+ );
+
+ return bless \%self;
+}
+
+sub distribution_name {
+ my $self = shift || new();
+ my $distro;
+ if ($distro = $self->_get_lsb_info()){
+ return $distro if ($distro);
+ }
+ foreach (keys %secondary_release_files) {
+ if (-f "/etc/$_" && !-l "/etc/$_"){
+ if (-f "/etc/$_" && !-l "/etc/$_"){
+ $self->{'DISTRIB_ID'} = $secondary_release_files{$_};
+ $self->{'release_file'} = $_;
+ return $self->{'DISTRIB_ID'};
+ }
+ }
+ }
+ foreach (keys %primary_release_files) {
+ if (-f "/etc/$_" && !-l "/etc/$_"){
+ if (-f "/etc/$_" && !-l "/etc/$_"){
+ $self->{'DISTRIB_ID'} = $primary_release_files{$_};
+ $self->{'release_file'} = $_;
+ return $self->{'DISTRIB_ID'};
+ }
+ }
+ }
+ undef
+}
+
+sub distribution_version {
+ my $self = shift || new();
+ my $release;
+ return $release if ($release = $self->_get_lsb_info('DISTRIB_RELEASE'));
+ if (! $self->{'DISTRIB_ID'}){
+ $self->distribution_name() or die 'No version because no distro.';
+ }
+ $self->{'pattern'} = $version_match{$self->{'DISTRIB_ID'}};
+ return "unknown" if (! $self->{'pattern'});
+ return "unknown" if (! ($release = $self->_get_file_info()));
+ $self->{'DISTRIB_RELEASE'} = $release;
+ return $release;
+}
+
+sub _get_lsb_info {
+ my $self = shift;
+ my $field = shift || 'DISTRIB_ID';
+ my $tmp = $self->{'release_file'};
+ if ( -r '/etc/' . $standard_release_file ) {
+ $self->{'release_file'} = $standard_release_file;
+ $self->{'pattern'} = $field . '=(.+)';
+ my $info = $self->_get_file_info();
+ if ($info){
+ $self->{$field} = $info;
+ return $info
+ }
+ }
+ $self->{'release_file'} = $tmp;
+ $self->{'pattern'} = '';
+ undef;
+}
+
+sub _get_file_info {
+ my $self = shift;
+ open FH, '/etc/' . $self->{'release_file'} or die 'Cannot open file: /etc/' . $self->{'release_file'};
+ my $info = '';
+ while (<FH>){
+ chomp $_;
+ ($info) = $_ =~ m/$self->{'pattern'}/;
+ return "\L$info" if $info;
+ }
+ undef;
+}
+
+1;
+
+
+# Simple script to use the above perl module to print the distro name
+if (my $distro = distribution_name) {
+ my $version = distribution_version();
+ print "$distro $version\n";
+} else {
+ print "distribution unknown\n";
+}
+
+
+
+__END__
+
+
+=head1 NAME
+
+linux_distro - tool for printing the current linux distribution
+
+=head1 SYNOPSIS
+
+ linux_distro
+
+=head1 DESCRIPTION
+
+This is a simple tool that tries to guess on what linux distribution we are running by looking for release's files in /etc. It now looks for 'lsb-release' first as that should be the most correct and adds ubuntu support. Secondly, it will look for the distro specific files.
+
+It currently recognizes slackware, debian, suse, fedora, redhat, turbolinux, yellowdog, knoppix, mandrake, conectiva, immunix, tinysofa, va-linux, trustix, adamantix, yoper, arch-linux, libranet, gentoo, ubuntu, redflag and xandros.
+
+It has function to get the version for debian, suse, redhat, gentoo, slackware, redflag and ubuntu(lsb). People running unsupported distro's are greatly encouraged to submit patches :-)
+
+=head2 EXPORT
+
+None by default.
+
+=head1 TODO
+
+Add the capability of recognize the version of the distribution for all recognized distributions.
+
+=head1 AUTHORS
+
+Alberto Re, E<lt>alberto@accidia.netE<gt>
+Judith Lebzelter, E<lt>judith@osdl.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.5 or,
+at your option, any later version of Perl 5 you may have available.
+
+=cut
+
diff --git a/tests/include/listargs b/tests/include/listargs
new file mode 100755
index 0000000..7468bd9
--- /dev/null
+++ b/tests/include/listargs
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "argc:$#"
+
+declare -i argn=1
+while [ "$#" -gt 0 ] ; do
+ echo "arg$argn:$1"
+ shift 1
+ argn=$(( argn + 1 ))
+done
diff --git a/tests/include/system_info b/tests/include/system_info
new file mode 100755
index 0000000..b689a30
--- /dev/null
+++ b/tests/include/system_info
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+parentdir=${0%/*}
+which perl >/dev/null 2>&1
+if [ "$?" ] ; then
+ distro=`perl $parentdir/linux_distro 2>&1`
+else
+ distro="not available (couldn't find perl)"
+fi
+
+echo "distribution: $distro"
+
+echo "xdg-utils:" `xdg-mime --version | cut -d ' ' -f 2`
+
+. "$parentdir/desktop_environment"
+
+detail=`uname -a`
+echo "uname: $detail"
+
+echo "xset data:"
+echo "-------------------------------------"
+xset q
+echo "-------------------------------------"
diff --git a/tests/include/tempfile.sh b/tests/include/tempfile.sh
new file mode 100644
index 0000000..d965fe4
--- /dev/null
+++ b/tests/include/tempfile.sh
@@ -0,0 +1,47 @@
+## Created 7/14/2006 by Tom Whipple <tom.whipple@intel.com>
+
+## create a globally unique identifier (GUID)
+## note that this is LIKELY to be unique, but not 100% guaranteed.
+get_guid() {
+ prefix=$1
+ now=`date '+%F-%H%M%S.%N'`
+ GUID="$prefix$now-$RANDOM"
+}
+
+get_tmpsubdir() {
+ if [ ! -z "$1" ] ; then
+ tmp="$1"
+ else
+ tmp=${TMPDIR-/tmp}
+ fi
+ if [ -z "$GUID" ] ; then
+ get_guid
+ fi
+ TMPSUBDIR="$tmp/$GUID-$$"
+ (umask 000 && mkdir -p $TMPSUBDIR) || {
+ echo "Could not create temporary directory!" >&2
+ exit 255
+ }
+}
+
+get_shortid() {
+ seqfile=$1
+
+ today=`date '+%m-%d'`
+
+ if [ -f "$seqfile" ] ; then
+ seqdate=`cat $seqfile | cut -d '+' -f 1 -`
+ if [ "$today" = "$seqdate" ] ; then
+ seq=$(( `cat $seqfile | cut -d '+' -f 2 -` + 1 ))
+ else
+ seq=1
+ fi
+ else
+ seq=1
+ fi
+
+ SHORTID="$today+$seq"
+ echo "$SHORTID" > "$seqfile"
+
+}
+
diff --git a/tests/include/testassertions.sh b/tests/include/testassertions.sh
new file mode 100644
index 0000000..1ba026d
--- /dev/null
+++ b/tests/include/testassertions.sh
@@ -0,0 +1,379 @@
+# Adapted from
+# shfuncs : test suite common shell functions
+# which was shipped with the TET example code.
+
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+## NOTE: Documentation is generated AUTOMATICALLY from this file
+## Function usage must immediately follow function delcaration
+
+assert_exit() {
+# execute command (saving output) and check exit code
+# Usage: assert_exit N command ...
+# where N is a number or a literal 'N' (for non-zero)
+# command can be an unquoted string, but be careful.
+ EXPECT="$1"
+ shift 1
+
+ # make sure nothing is hanging around from a prev. test.
+ rm -f out.stdout out.stderr
+
+ # $1 is command, $2 is expected exit code (0 or "N" for non-zero)
+ ( "$@" > out.stdout 2> out.stderr )
+ CODE="$?"
+
+ LASTCOMMAND="$*"
+
+ if [ -z "$EXPECT" ]; then
+ EXPECT=0;
+ fi
+ if [ "$EXPECT" = N -a "$CODE" -eq 0 ]; then
+ test_fail "Command ($*) gave exit code $CODE, expected nonzero"
+ elif [ "$EXPECT" != N ] && [ "$EXPECT" -ne "$CODE" ]; then
+ test_fail "Command ($*) gave exit code $CODE, expected $EXPECT"
+ fi
+}
+
+assert_interactive_notroot() {
+ if [ `whoami` != 'root' ] ; then
+ assert_interactive "$@"
+ fi
+}
+
+assert_interactive() {
+# Useage:
+# assert_interactive {msg} [y|n|C|s varname]
+#
+# msg is the text to print.
+# y -> expect y for [y/n]
+# n -> expect n for [y/n]
+# s -> save y or n into varname. Then, (presumably) $varname can be
+# given in place of y or n in subsequent calls to assert_interactive
+# C -> cleanup msg. Always print "msg [enter to continue]" despite test failure.
+# if no argument is given after msg, print "msg [enter to continue]"
+
+ query=$1
+ expect=$2
+# It seems valuable to see what happens even if the test has failed.
+# (eg fail on stdout.)
+ if [ "$TEST_STATUS" = 'FAIL' -a "$expect" != C ] ; then
+ ## Don't waste user's time if test has already failed.
+ test_infoline "Test has already failed. Not bothering to ask '$query'"
+ return
+ fi
+
+ if [ ! -z "$XDG_TEST_NO_INTERACTIVE" ] ; then
+ test_infoline "Assumed '$query' is '$expect'"
+ return
+ fi
+
+ if [ ! -z "$expect" -a "$expect" != C ] ; then
+ if [ "$expect" != y -a "$expect" != n -a "$expect" != s -a "$expect" != C ] ; then
+ echo "TEST SYNTAX ERROR: interactive assertions require one of (y,n,s,C) as choices. (found '$expect')" >&2
+ exit 255
+ fi
+ unset result
+ while [ "$result" != y -a "$result" != n ] ; do
+ echo -ne "\n\t$query [y/n]: " >&2
+ read result
+ done
+
+ if [ "$expect" = s ] ; then
+ if [ -z "$3" ] ; then
+ echo "TEST SYNTAX ERROR: 's' requires a variable name"
+ exit 255
+ fi
+ eval "$3=$result"
+ elif [ "$result" != "$expect" ] ; then
+ test_fail "User indicated '$result' instead of '$expect' in response to '$query'"
+ fi
+ else
+ echo -ne "\n\t$query [enter to continue] " >&2
+ read result
+ fi
+}
+
+
+assert_file_in_path() {
+# Assert that some file is present in a path.
+#
+# Usage:
+# assert_file_in_path FILENAME PATH
+# where FILE is the exact name of the file and
+# PATH is a ':' separated list of directories
+ search_dirs=`echo "$2" | tr ':' ' '`
+ found_files=`find $search_dirs -name "$1" 2>/dev/null`
+
+ if [ -z "$found_files" ] ; then
+ test_fail "Did not find '$1' in '$2'"
+ fi
+}
+
+assert_file_not_in_path() {
+# Assert the some file is NOT present in a path.
+# Opposite of 'assert_file_in_path'
+ search_dirs=`echo "$2" | tr ':' ' '`
+ found_files=`find $search_dirs -name "$1" 2>/dev/null`
+
+ if [ ! -z "$found_files" ] ; then
+ test_fail "Found '$found_files' in $2"
+ fi
+}
+
+
+assert_file() {
+# Assert the existance of an exact filename
+# Usage: assert_file FILE
+ if [ ! -e "$1" ] ; then
+ test_fail "'$1' does not exist"
+ return
+ elif [ ! -f "$1" ] ; then
+ test_fail "'$1' is not a regular file"
+ return
+ fi
+ if [ -f "$2" ] ; then
+ compare=`diff -wB "$1" "$2"`
+ if [ ! -z "$compare" ] ; then
+ test_fail "'$1' is different from '$2'. Diff is:\n$compare"
+ fi
+ fi
+}
+
+assert_nofile() {
+# Assert the non existance of an exact filename.
+# Opposite of 'assert_file'
+ if [ -e "$1" ] ; then
+ test_fail "'$1' exists."
+ fi
+}
+
+
+assert_nostdout() {
+# assert nothing was written to a stdout.
+# NOTE: Failing this assertion will WARN rather than FAIL
+ if [ -s out.stdout ]
+ then
+ test_infoline "Unexpected output from '$LASTCOMMAND' written to stdout, as shown below:"
+ infofile out.stdout stdout:
+ if [ "$TEST_STATUS" = "PASS" ]; then
+ test_status WARN
+ fi
+ fi
+}
+
+assert_nostderr() {
+# assert nothing was written to stderr.
+# NOTE: Failing this assertion will WARN rather than FAIL
+ if [ -n "$XDG_UTILS_DEBUG_LEVEL" ] ; then
+ if [ -s out.stderr ] ; then
+ infofile out.stderr debug:
+ fi
+ elif [ -s out.stderr ] ; then
+ test_infoline "Unexpected output from '$LASTCOMMAND' written to stderr, as shown below:"
+ infofile out.stderr stderr:
+ if [ "$TEST_STATUS" = "PASS" ]; then
+ test_status WARN
+ fi
+ fi
+}
+
+assert_stderr() {
+# check that stderr matches expected error
+# $1 is file containing regexp for expected error
+# if no argument supplied, just check out.stderr is not empty
+
+ if [ ! -s out.stderr ]
+ then
+ test_infoline "Expected output from '$LASTCOMMAND' to stderr, but none written"
+ test_fail
+ return
+ fi
+ if [ ! -z "$1" ] ; then
+ expfile="$1"
+ OK=Y
+ exec 4<&0 0< "$expfile" 3< out.stderr
+ while read expline
+ do
+ if read line <&3
+ then
+ if expr "$line" : "$expline" > /dev/null
+ then
+ :
+ else
+ OK=N
+ break
+ fi
+ else
+ OK=N
+ fi
+ done
+ exec 0<&4 3<&- 4<&-
+ if [ "$OK" = N ]
+ then
+ test_infoline "Incorrect output from '$LASTCOMMAND' written to stderr, as shown below"
+ infofile "$expfile" "expected stderr:"
+ infofile out.stderr "received stderr:"
+ test_fail
+ fi
+ fi
+}
+
+assert_stdout() {
+# check that stderr matches expected error
+# $1 is file containing regexp for expected error
+# if no argument supplied, just check out.stderr is not empty
+
+ if [ ! -s out.stdout ]
+ then
+ test_infoline "Expected output from '$LASTCOMMAND' to stdout, but none written"
+ test_fail
+ return
+ fi
+ if [ ! -z "$1" ] ; then
+ expfile="$1"
+
+ if [ ! -e "$expfile" ] ; then
+ test_status NORESULT "Could not find file '$expfile' to look up expected pattern!"
+ return
+ fi
+ OK=Y
+ exec 4<&0 0< "$expfile" 3< out.stdout
+ while read expline
+ do
+ if read line <&3
+ then
+ if expr "$line" : "$expline" > /dev/null
+ then
+ :
+ else
+ OK=N
+ break
+ fi
+ else
+ OK=N
+ fi
+ done
+ exec 0<&4 3<&- 4<&-
+ if [ "$OK" = N ]
+ then
+ test_infoline "Incorrect output from '$LASTCOMMAND' written to stdout, as shown below"
+ infofile "$expfile" "expected stdout:"
+ infofile out.stdout "received stdout:"
+ test_fail
+ fi
+ fi
+}
+
+require_interactive() {
+# if $XDG_TEST_NO_INTERACTIVE is set, test result becomes UNTESTED
+ if [ ! -z "$XDG_TEST_NO_INTERACTIVE" ] ; then
+ test_result UNTESTED "XDG_TEST_NO_INTERACTIVE is set, but this test needs interactive"
+ fi
+}
+
+require_root() {
+# if the test is not being run as root, test result is UNTESTED
+ if [ `whoami` != 'root' ] ; then
+ test_result UNTESTED "not running as root, but test requires root privileges"
+ fi
+}
+
+require_notroot() {
+# if the test is being run as root, the test result is UNTESTED
+# opposite of 'require_root'
+ if [ `whoami` = 'root' ] ; then
+ test_result UNTESTED "running as root, but test must be run as a normal user"
+ fi
+}
+
+set_no_display() {
+# Clear $DISPLAY
+ unset DISPLAY
+}
+
+assert_display() {
+# Assert that the $DISPLAY variable is set.
+ if [ -z "$DISPLAY" ] ; then
+ test_fail "DISPLAY not set!"
+ fi
+}
+
+assert_util_var() {
+# Assert that the $XDGUTIL varilable is set.
+# DEPRICATED. Only used by generic tests.
+if [ "x$XDGUTIL" = x ]; then
+ test_fail "XDGUTIL variable not set"
+fi
+}
+
+use_file() {
+# Copy a datafile from it's defult location into the test directory
+# Usage:
+# use_file ORIG_FILE VAR
+# Where ORIG_FILE is the name of the file, and VAR is the name of the
+# variable to create that will contain the new (unique) filename.
+# DO NOT put a '$' in front of VAR. VAR will be created via eval.
+#
+# $VAR will be set to 'xdgtestdata-$XDG_TEST_ID-$file' after the
+# directory is stripped from $file.
+ src="$1"
+ file=${src##/*/}
+ varname="$2"
+
+ if [ $# -lt 2 ] ; then
+ echo "TEST SYNTAX ERROR: use_file must have two arguments" >&2
+ exit 255
+ fi
+
+ assert_file "$src"
+
+ outfile="xdgtestdata-$XDG_TEST_ID-$file"
+ eval "$varname=$outfile"
+
+ cp "$src" "$XDG_TEST_TMPDIR/$outfile"
+}
+
+get_unique_name() {
+# Get a unique name for a file, similar to 'use_file'
+# except that no file is copied. You are left to create file $VAR.
+ varname="$1"
+ file="$2"
+ if [ -z "$varname" ] ; then
+ echo "TEST SYNAX ERROR: get_unique_name requries a variable name"
+ exit 255
+ fi
+
+ outfile="xdgtestdata-$XDG_TEST_ID-$file"
+ eval "$varname=$outfile"
+}
+
+edit_file() {
+# Edit file via sed.
+# Usage:
+# edit_file $FILE origstr VARNAME [newstr]
+# Where:
+# $FILE is a file, probably copied from 'use_file'
+# VARNAME is created via 'eval' to contain the newstr
+# newstr is the optional substitution. If newstr is not present,
+# it will become 'xdgtestdata-$XDG_TEST_ID-$origstr'
+ file="$1"
+ origstr="$2"
+ varname="$3"
+ newstr="$4"
+
+ if [ $# -lt 3 ] ; then
+ echo "TEST SYNTAX ERROR: edit_file must have at least 3 arguments."
+ exit 255
+ fi
+
+ assert_file "$file"
+
+ if [ -z "$newstr" ] ; then
+ newstr="xdgtestdata-$XDG_TEST_ID-$origstr"
+ fi
+
+ eval "$varname=\"$newstr\""
+
+ sed -i -e "s|$origstr|$newstr|g" "$file"
+}
+
diff --git a/tests/include/testcontrol.sh b/tests/include/testcontrol.sh
new file mode 100644
index 0000000..cdd1610
--- /dev/null
+++ b/tests/include/testcontrol.sh
@@ -0,0 +1,121 @@
+
+if [ -z "$IC_NUM" ] ; then
+ declare -i IC_NUM=1
+fi
+
+run_test() {
+## USAGE:
+# run_test test_func
+
+# if tests are being run with TET or the test runner
+if [ ! -z "$USING_TET" -o ! -z "$USING_TEST_RUNNER" ]; then
+ ## The TET framework REQUIRES variables of the form $ic1 ... $icN
+ ## where each variable is a list of test functions. Here, there is only
+ ## one test function per $icN variable. Each $icN variable MUST be present
+ ## in the $iclist
+ export ic$IC_NUM="$1"
+ export iclist="$iclist ic$IC_NUM"
+
+ ## The standalone test runner executes each function in $TEST_LIST
+ export TEST_LIST="$TEST_LIST $1"
+
+else # test is being run directly.
+ test_setup
+
+ ## Subshell is necessary for containment
+ ( "$1" )
+ test_cleanup
+fi
+IC_NUM=$(($IC_NUM+1))
+
+}
+
+repeat_test() {
+## USAGE:
+# repeat_test test_func N var1 ... varN var1_value1 ... var1_valueM ... varN_valueM
+# where N is the number of values to substiute and M is the number of
+# values each varable takes
+#
+# EXAMPLE
+# repeat_test copy_file 2 INPUT OUTPUT infile1 infile2 outfile1 outfile2
+#
+# NOTE - all variables MUST have the same number of arguments
+
+if [ "$#" -lt 4 ] ; then
+ echo "TEST SYNTAX ERROR: repeat_test() requires at least 4 arguments!"
+ exit 255
+fi
+
+FUNC="$1"
+VARS="$2"
+shift 2
+
+## get list of variables
+declare -i I=1
+while [ "$I" -le "$VARS" ]; do
+ eval "v$I=$1"
+ shift 1
+
+ eval "out=\$v$I"
+ I=$(($I+1))
+done
+
+#echo "----"
+
+## $LENGTH is the number of values each variable takes
+declare -i LENGTH=$(( $# / $VARS ))
+#echo "list size: $LENGTH"
+
+## Main loop: create a test function for each set of values.
+declare -i J=1
+while [ "$J" -le "$LENGTH" ] ; do
+ declare -i I=1
+ ## Begin test function string
+
+ # it is only safe to use $IC_NUM since run_test is used later in this function.
+ str="$FUNC-$J-$IC_NUM() {"
+
+ while [ "$I" -le "$VARS" ] ; do
+ ## Assign each value to appropriate variable
+ eval "var=\$v$I"
+ eval "value=\$$(( ($I-1)*$LENGTH+$J ))"
+ #echo "$var: $value"
+ str="$str
+ $var=\"$value\""
+
+ I=$(($I+1))
+ done
+ ## Close the test function and load it
+ str="$str
+ $FUNC
+ }"
+ #echo "$str"
+ eval "$str"
+ run_test "$FUNC-$J-$IC_NUM"
+
+ J=$(($J+1))
+done
+
+}
+
+. "$XDG_TEST_DIR/include/tempfile.sh"
+
+test_setup() {
+ get_guid "xdgt"
+ export XDG_TEST_ID="$GUID"
+ get_tmpsubdir "$XDG_TEST_DIR/tmp"
+ export XDG_TEST_TMPDIR="$TMPSUBDIR"
+ cd "$XDG_TEST_TMPDIR"
+
+ get_shortid "$XDG_TEST_DIR/tmp/shortid"
+ export XDG_TEST_SHORTID="$SHORTID"
+}
+
+test_cleanup() {
+ if [ -z "$XDG_TEST_DONT_CLEANUP" ] ; then
+ cd "$XDG_TEST_DIR"
+ # ALWAYS check what you pass to 'rm -rf'
+ [ -d "$XDG_TEST_TMPDIR" ] && rm -rf "$XDG_TEST_TMPDIR"
+ fi
+}
+
diff --git a/tests/include/testfuncs.sh b/tests/include/testfuncs.sh
new file mode 100644
index 0000000..d8d73e5
--- /dev/null
+++ b/tests/include/testfuncs.sh
@@ -0,0 +1,138 @@
+verify_test_context() {
+ if [ -z "$TEST_NAME" -a ! "$USING_TET" ]; then
+ echo "A test context must be established with 'test_start <name>'!"
+ exit 255
+ fi
+}
+
+## record the test a name.
+test_start () {
+
+ TEST_NAME="$*"
+ verify_test_context
+ TEST_STATUS=PASS
+
+ if [ $USING_TET ]; then
+ tet_infoline $TEST_NAME
+ FAIL=N
+ else
+ echo -n "[`date`] $TEST_NAME: "
+ fi
+
+}
+
+test_infoline() {
+ verify_test_context
+ FAIL_MESSAGE="$FAIL_MESSAGE\n$*"
+ if [ "$USING_TET" ] ; then
+ tet_infoline $*
+ fi
+}
+
+test_fail() {
+ FAIL=Y
+ TEST_STATUS=FAIL
+ test_infoline $*
+}
+
+## provide a nice way to document the test purpose
+test_purpose() {
+ verify_test_context
+ # TODO: generate a manpage or something.
+}
+test_note() {
+ #verify_test_context
+ # TODO: generate even more docs.
+ tmp=1
+}
+
+## Used for setup/dependency verification.
+test_init() {
+ verify_test_context
+}
+
+test_status() {
+ TEST_STATUS="$1"
+ test_infoline "$2"
+}
+
+## Called after test_init()
+test_procedure() {
+ verify_test_context
+ ## Make sure nothing screwed up in initilization
+ if [ "$TEST_STATUS" != "PASS" ]; then
+ # Something failed before we could get to the test.
+ FAIL=N
+ test_result NORESULT "Initilization failed!"
+ fi
+}
+
+## Must be within test_procedure
+test_failoverride() {
+ STAT=${1-WARN}
+ if [ "$TEST_STATUS" == FAIL ] ; then
+ FAIL=N
+ test_status "$STAT"
+ fi
+}
+
+## Report the test's result.
+test_result() {
+ verify_test_context
+
+ # Set status appropriately
+ if [ ! -z "$1" ]; then
+ TEST_STATUS=$1
+ # account for TET
+ if [ "$TEST_STATUS" = "FAIL" ] ; then
+ FAIL=Y
+ fi
+ fi
+ # if we have a message, save it
+ if [ ! -z "$2" ]; then
+ test_infoline $2
+ fi
+ if [ "$USING_TET" ]; then
+ tet_result $TEST_STATUS
+ fi
+ # not using tet, so print nice explanation
+
+ [ -z "$USING_TET" ] && echo -n "$TEST_STATUS"
+
+ ## Result codes MUST agree with tet_codes
+ ## for LSB/tet integration.
+ case "$TEST_STATUS" in
+ PASS ) RESULT=0
+ ;;
+ FAIL ) RESULT=1
+ [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
+ ;;
+ UNTESTED ) RESULT=5
+ [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
+ ;;
+ NORESULT ) RESULT=7
+ [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
+ ;;
+ WARN ) RESULT=10
+ [ -z "$USING_TET" ] && echo -ne " $FAIL_MESSAGE"
+ ;;
+ *) RESULT=1
+ [ -z "$USING_TET" ] && echo -ne " - UNKNOWN STATUS\n$FAIL_MESSAGE"
+ ;;
+ esac
+ #fi
+ [ -z "$USING_TET" ] && echo ""
+ exit "$RESULT"
+}
+
+infofile() # write file to journal using tet_infoline
+{
+ # $1 is file name, $2 is prefix for tet_infoline
+
+ prefix="$2"
+ while read line
+ do
+ test_infoline "$prefix$line"
+ done < "$1"
+}
+
diff --git a/tests/spec/test_specification.odt b/tests/spec/test_specification.odt
new file mode 100755
index 0000000..19d4527
--- /dev/null
+++ b/tests/spec/test_specification.odt
Binary files differ
diff --git a/tests/spec/test_specification.pdf b/tests/spec/test_specification.pdf
new file mode 100755
index 0000000..f27927a
--- /dev/null
+++ b/tests/spec/test_specification.pdf
Binary files differ
diff --git a/tests/testrun b/tests/testrun
new file mode 100755
index 0000000..822fc69
--- /dev/null
+++ b/tests/testrun
@@ -0,0 +1,226 @@
+#!/bin/bash
+
+# Defaults.
+ROOT_TEST_GROUPS="xdg-desktop-icon xdg-desktop-menu xdg-icon-resource xdg-mime xdg-utils-usecases"
+USER_TEST_GROUPS="$ROOT_TEST_GROUPS xdg-email xdg-open xdg-screensaver"
+
+usage() {
+cat << _ENDUSAGE_
+Usage:
+$0 [-iIcChRSd:p:f:a] [test|testgroup] [...]
+
+Options:
+ [-h] Show this message and exit.
+
+ [-I|-i] Turn off/on interactive tests. Default: on
+ (overrides XDG_TEST_NO_INTERACTIVE)
+
+ [-C|-c] Turn off/on deletion of tempfiles. Default: on
+ (overrides XDG_TEST_DONT_CLEANUP)
+
+ [-R] Turn off su to root tests.
+ You will not be prompted for the root password at the beginning of the testrun.
+
+ [-S] Use sudo instead of su.
+
+ [-a] Run all tests. (i.e xdg-*/) Has no effect if tests are specified explicitly.
+
+ [-d dir] Set XDG_TEST_DIR to dir
+
+ [-p path] Reset PATH to path. Recommended for internal use only.
+
+ [-f pid] RESERVED -- state flag for self reference. DON'T USE.
+
+Arguments:
+
+After options, all arguments correspond to tests to run. The default is to run all tests, which consist of all files matching 'xdg-*/t.*'.
+
+Supplied testgroups can be a list of directories or a list of individual tests.
+
+_ENDUSAGE_
+exit 1
+}
+MYARGS="$@"
+
+if [ `whoami` == root ] ; then
+ XDG_TEST_DONT_SU="set"
+ DEFAULT_TEST_GROUPS="$ROOT_TEST_GROUPS"
+ RUNNING_AS="root"
+else
+ DEFAULT_TEST_GROUPS="$USER_TEST_GROUPS"
+ RUNNING_AS="normal"
+fi
+
+## Read options
+while getopts "iIcChRSf:d:p:a" opt; do
+ case $opt in
+ I ) export XDG_TEST_NO_INTERACTIVE="set" ;;
+ i ) unset XDG_TEST_NO_INTERACTIVE ;;
+ C ) export XDG_TEST_DONT_CLEANUP="set" ;;
+ c ) unset XDG_TEST_DONT_CLEANUP ;;
+ R ) XDG_TEST_DONT_SU="set" ;;
+ S ) XDG_TEST_USE_SUDO="set" ;;
+ f ) XDG_TEST_SELF_LAUNCH="$OPTARG" ;;
+ d ) export XDG_TEST_DIR="$OPTARG" ;;
+ p ) export PATH="$OPTARG" ;;
+ a ) DEFAULT_TEST_GROUPS=`ls -d $XDG_TEST_DIR/xdg-*` ;;
+ h ) usage ;;
+ \? ) usage ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+## Set up prerequisites
+if [ -z "$XDG_TEST_DIR" ] ; then
+ export XDG_TEST_DIR="$PWD"
+ echo "WARNING: guessed XDG_TEST_DIR to be $XDG_TEST_DIR"
+fi
+if [ -z `which xdg-mime 2>/dev/null` ] && [ -d "$XDG_TEST_DIR/../scripts" ] ; then
+ export PATH="$PATH:$XDG_TEST_DIR/../scripts"
+ echo "WARNING: modified PATH to add '$XDG_TEST_DIR/../scripts'"
+fi
+
+## Read test groups
+if [ $# -eq 0 ] ; then
+ TEST_GROUPS="$DEFAULT_TEST_GROUPS"
+else
+ TEST_GROUPS="$@"
+fi
+
+TEST_FILES=`find $TEST_GROUPS -name 't.*[^~]' | sort`
+
+declare -i PASS=0
+declare -i FAILCOUNT=0
+declare -i TOTAL=0
+declare -i ATTEMPT=0
+TEST_LOG="$XDG_TEST_DIR/xdg-test.log"
+
+export USING_TEST_RUNNER="true"
+
+for MY_TEST_FILE in $TEST_FILES; do
+ . "$MY_TEST_FILE"
+done
+
+if [ -z "$XDG_TEST_SELF_LAUNCH" ] ; then # not self launched
+ test -d "$XDG_TEST_DIR/tmp" || mkdir "$XDG_TEST_DIR/tmp"
+ touch "$XDG_TEST_DIR/tmp/shortid"
+ chmod 666 "$XDG_TEST_DIR/tmp/shortid"
+
+ if [ "$RUNNING_AS" == root -a -z "$*" ] ; then
+ echo "WARNING: Tests are incomplete unless run as a normal (non-root) user."
+ echo "The test runner will SU as needed to run root cases."
+ fi
+
+ echo "======================================================" >> "$TEST_LOG"
+ echo "[`date`] TEST RUN START: $*" >> "$TEST_LOG"
+ "$XDG_TEST_DIR/include/system_info" >>"$TEST_LOG"
+
+ if [ -z "$XDG_TEST_DONT_SU" ] ; then
+ if [ -z "$XDG_TEST_USE_SUDO" ] ; then
+ SUCMD=
+ echo "Running su for system tests. (Use testrun -S to use sudo instead)"
+ echo "Please enter the root password when requested."
+ else
+ SUCMD=`which sudo 2>/dev/null`
+ echo "Running ${SUCMD-su} for system tests."
+ echo "Please enter an apropriate password if requested."
+ fi
+ # Note if sudo is not found, $SUCMD will be blank, so run su directly.
+ # We cannot assume su works since systems like Ubuntu require sudo
+ # Yet, systems like Debian do not ship with sudo by default.
+ $SUCMD su - -c "cd $PWD && XDG_UTILS_DEBUG_LEVEL=$XDG_UTILS_DEBUG_LEVEL $0 -f $$ -d '$XDG_TEST_DIR' -p '$PATH' $MYARGS"
+ fi
+
+ TEST_STATUS_FILE="$XDG_TEST_DIR/tmp/xdgtest_status-$$"
+ USERCLASS="normal user"
+else
+ TEST_STATUS_FILE="$XDG_TEST_DIR/tmp/xdgtest_status-$XDG_TEST_SELF_LAUNCH"
+ USERCLASS="root"
+fi
+
+echo "[`date`] ---- $USERCLASS run start: $*" >> "$TEST_LOG"
+#echo "TEST_LIST: $TEST_LIST"
+
+for t in $TEST_LIST; do
+ TOTAL=$((TOTAL + 1 ))
+ ATTEMPT=$((ATTEMPT + 1 ))
+
+ echo -n "$t: "
+
+ test_setup
+
+ # Run test - subshell is necessary to keep things contained.
+ ( "$t" ) >> "$TEST_LOG"
+ CODE="$?"
+
+ test_cleanup
+
+ # Report result
+ case "$CODE" in
+ 0 ) PASS=$((PASS + 1))
+ RESULT=PASS
+ ;;
+
+ 1 ) RESULT=FAIL
+ FAILCOUNT=$((FAILCOUNT +1))
+ ;;
+ 5 ) RESULT=UNTESTED
+ TOTAL=$((TOTAL - 1 )) ## HACK: we don't want to count tests that don't run.
+ ;;
+ 7 ) RESULT=NORESULT ;;
+ 10 ) RESULT=WARN ;;
+ * ) RESULT="UNKNOWN($CODE)";;
+ esac
+ echo "$RESULT"
+ test "$RESULT" == FAIL && echo "" >> "$TEST_LOG"
+done
+
+echo -n "[`date`] ---- " >> "$TEST_LOG"
+echo "$USERCLASS run end: $FAILCOUNT tests failed, $PASS of $TOTAL tests passed. ($ATTEMPT attempted)" | tee -a "$TEST_LOG"
+
+if [ -z "$XDG_TEST_SELF_LAUNCH" ] ; then # not su'd
+ if [ -f "$TEST_STATUS_FILE" ] ; then
+ RFAIL=`grep 'FAIL' "$TEST_STATUS_FILE" | cut -d ':' -f2`
+ RPASS=`grep 'PASS' "$TEST_STATUS_FILE" | cut -d ':' -f2`
+ RTOTAL=`grep 'TOTAL' "$TEST_STATUS_FILE" | cut -d ':' -f2`
+ RATTEMPT=`grep 'ATTEMPT' "$TEST_STATUS_FILE" | cut -d ':' -f2`
+
+ rm -f "$TEST_STATUS_FILE"
+ fi
+
+ GFAIL=$(( $FAILCOUNT + ${RFAIL-0} ))
+ GPASS=$(( $PASS + ${RPASS-0} ))
+ GTOTAL=$(( $TOTAL + ${RTOTAL-0} ))
+ GATTEMPT=$(( $ATTEMPT + ${RATTEMPT-0} ))
+
+ echo -n "[`date`] TEST RUN END: $* - " >> "$TEST_LOG"
+ echo -n "TOTAL: "
+ echo "$GFAIL tests failed, $GPASS of $GTOTAL tests passed. ($GATTEMPT attempted)" | tee -a "$TEST_LOG"
+
+ if [ $(( $GTOTAL - $GPASS )) -gt 0 ]; then
+ EC=1
+ echo "NOT OK! -- See $TEST_LOG for details."
+ else
+ EC=0
+ echo "ok"
+ fi
+ if [ -z "$*" -a -z "$XDG_TEST_NO_INTERACTIVE" ] ; then
+ echo "Please consider submitting your test report to"
+ echo "http://portland.freedesktop.org/testreport.html"
+ echo ""
+ fi
+
+ exit "$EC"
+else ## Running su'd. save results.
+ echo "FAIL:$FAILCOUNT" > $TEST_STATUS_FILE
+ echo "PASS:$PASS" >> $TEST_STATUS_FILE
+ echo "TOTAL:$TOTAL" >> $TEST_STATUS_FILE
+ echo "ATTEMPT:$ATTEMPT" >> $TEST_STATUS_FILE
+
+ if [ $(( $TOTAL - $PASS)) -gt 0 ] ; then
+ exit -1
+ else
+ exit 0
+ fi
+fi
+
diff --git a/tests/tet_run b/tests/tet_run
new file mode 100755
index 0000000..e0366a8
--- /dev/null
+++ b/tests/tet_run
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+## FILL THIS IN or be sure environment is correct.
+#XDG_TEST_DIR=
+#TET_ROOT=
+
+export XDG_TEST_NO_INTERACTIVE="true"
+
+if [ -z "$XDG_TEST_DIR" ] ; then
+ # User didn't follow directions, make a guess.
+ XDG_TEST_DIR=`pwd`
+fi
+if [ -z "$TET_ROOT" ] ; then
+ # can't really guess
+ echo "TET_ROOT is not defined!!"
+ exit 1
+fi
+USING_TET="true"
+TEST_GROUPS=`find "$XDG_TEST_DIR" -type d -name 'xdg-*'`
+TEST_FILES=`find $TEST_GROUPS -name 't.*'`
+
+## load all the tests.
+for t in $TEST_FILES; do
+ . "$t"
+done
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+tet_startup="test_setup"
+tet_cleanup="test_cleanup"
+
+## $iclist and all $ic1 ... $icN variables are now defined.
+echo "iclist: $iclist"
+
+## Launch TET
+. "$TET_ROOT/lib/xpg3sh/tcm.sh"
diff --git a/tests/xdg-desktop-icon/data/desktop_icon_install.desktop b/tests/xdg-desktop-icon/data/desktop_icon_install.desktop
new file mode 100644
index 0000000..28c96fd
--- /dev/null
+++ b/tests/xdg-desktop-icon/data/desktop_icon_install.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Type=Application
+
+Exec=touch xdg-test-desktop-icon-install.tmp
+
+Name=Desktop_Icon
+StartupNotify=false
diff --git a/tests/xdg-desktop-icon/t.00-apply_generic b/tests/xdg-desktop-icon/t.00-apply_generic
new file mode 100755
index 0000000..f97b1c8
--- /dev/null
+++ b/tests/xdg-desktop-icon/t.00-apply_generic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-desktop-icon"
+done
+
diff --git a/tests/xdg-desktop-icon/t.01-notexist_file_uninstall b/tests/xdg-desktop-icon/t.01-notexist_file_uninstall
new file mode 100755
index 0000000..efb771f
--- /dev/null
+++ b/tests/xdg-desktop-icon/t.01-notexist_file_uninstall
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_notexist_file_uninstall() {
+## Begin the test.
+FILE="pain_file_uninstall.txt"
+test_start "$FUNCNAME: verify uninstalling file does not cause an error if it is not installed."
+
+# Dependencies section
+test_init
+
+get_unique_name INSFILE "$FILE"
+set_no_display
+echo "Some more boring text" > "$INSFILE"
+assert_file "$INSFILE"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$INSFILE" "$HOME/Desktop"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-icon uninstall "$INSFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$INSFILE" "$HOME/Desktop"
+
+test_result
+}
+
+run_test test_notexist_file_uninstall
diff --git a/tests/xdg-desktop-icon/t.02-plain_file_install b/tests/xdg-desktop-icon/t.02-plain_file_install
new file mode 100755
index 0000000..5aa713e
--- /dev/null
+++ b/tests/xdg-desktop-icon/t.02-plain_file_install
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_plain_file_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify text file is installed correctly on the desktop"
+
+# Dependencies section
+test_init
+
+INSFILE="xdgtestdata-$XDG_TEST_SHORTID.txt"
+set_no_display
+echo "Some more boring text. $XDG_TEST_ID" > "$INSFILE"
+assert_file "$INSFILE"
+
+DESKTOP="$HOME/Desktop"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$INSFILE" "$DESKTOP"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-icon install "$INSFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$INSFILE" "$DESKTOP"
+
+assert_interactive_notroot "Is there an icon on the desktop with name '$INSFILE'?" y
+
+## Cleanup
+xdg-desktop-icon uninstall "$INSFILE"
+
+test_result
+}
+
+run_test test_plain_file_install
diff --git a/tests/xdg-desktop-icon/t.03-plain_file_uninstall b/tests/xdg-desktop-icon/t.03-plain_file_uninstall
new file mode 100755
index 0000000..ff2f5e1
--- /dev/null
+++ b/tests/xdg-desktop-icon/t.03-plain_file_uninstall
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_plain_file_uninstall() {
+## Begin the test.
+test_start "$FUNCNAME: verify $FILE is uninstalled correctly from the desktop"
+
+# Dependencies section
+test_init
+
+INSFILE="xdgtestdata-$XDG_TEST_SHORTID.txt"
+DESKTOP="$HOME/Desktop"
+
+set_no_display
+echo "Some more boring text" > "$INSFILE"
+assert_file "$INSFILE"
+
+# Verify the test icon is not installed already.
+assert_exit 0 xdg-desktop-icon install "$INSFILE"
+assert_file_in_path "$INSFILE" "$DESKTOP"
+assert_interactive_notroot "Is an icon named '$INSFILE' present on the desktop?" y
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-icon uninstall "$INSFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$INSFILE" "$DESKTOP"
+assert_interactive_notroot "Is an icon named '$INSFILE' still present on the desktop?" n
+
+test_result
+}
+
+run_test test_plain_file_uninstall
diff --git a/tests/xdg-desktop-icon/t.04-desktop_icon_install b/tests/xdg-desktop-icon/t.04-desktop_icon_install
new file mode 100755
index 0000000..0fb47f4
--- /dev/null
+++ b/tests/xdg-desktop-icon/t.04-desktop_icon_install
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_desktop_icon_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify a desktop file installed correctly on the desktop"
+
+# Dependencies section
+test_init
+
+# Generate .desktop file
+use_file "$XDG_TEST_DIR/xdg-desktop-icon/data/desktop_icon_install.desktop" DESK_FILE
+edit_file "$DESK_FILE" 'xdg-test-desktop-icon-install.tmp' CREATE_FILE
+edit_file "$DESK_FILE" 'Desktop_Icon' ICON_TEXT "Install $XDG_TEST_SHORTID"
+assert_file "$DESK_FILE"
+DESKTOP="$HOME/Desktop"
+
+set_no_display
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESK_FILE" "$DESKTOP"
+assert_nofile "$HOME/$CREATE_FILE"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-icon install "$DESK_FILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$DESK_FILE" "$DESKTOP"
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" ] && [ `whoami` != root ] ; then
+assert_interactive "Is there an icon on the desktop with name '$ICON_TEXT'?" y
+assert_interactive "Please double click the '$ICON_TEXT' icon."
+
+## Double clicking will result in the command 'touch xdg-test-desktop-icon-install.tmp' to be run
+assert_file "$HOME/$CREATE_FILE"
+
+
+## Cleanup
+rm -f "$HOME/$CREATE_FILE"
+fi
+xdg-desktop-icon uninstall "$DESK_FILE" >/dev/null 2>&1
+
+test_result
+}
+
+run_test test_desktop_icon_install
diff --git a/tests/xdg-desktop-icon/t.05-desktop_icon_uninstall b/tests/xdg-desktop-icon/t.05-desktop_icon_uninstall
new file mode 100755
index 0000000..049dfec
--- /dev/null
+++ b/tests/xdg-desktop-icon/t.05-desktop_icon_uninstall
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_desktop_icon_uninstall() {
+## Begin the test.
+DIR="$XDG_TEST_DIR/xdg-desktop-icon/data"
+FILE="desktop_icon_install.desktop"
+test_start "$FUNCNAME: verify desktop file is uninstalled correctly from the desktop"
+DESKTOP="$HOME/Desktop"
+
+# Dependencies section
+test_init
+
+use_file "$XDG_TEST_DIR/xdg-desktop-icon/data/desktop_icon_install.desktop" DESK_FILE
+edit_file "$XDG_TEST_TMPDIR/$DESK_FILE" 'xdg-test-desktop-icon-install.tmp' CREATE_FILE
+edit_file "$DESK_FILE" 'Desktop_Icon' ICON_TEXT "Uninstall $XDG_TEST_SHORTID"
+assert_file "$XDG_TEST_TMPDIR/$DESK_FILE"
+
+set_no_display
+
+# Verify the test icon is not installed already.
+assert_exit 0 xdg-desktop-icon install "$XDG_TEST_TMPDIR/$DESK_FILE"
+
+assert_file_in_path "$DESK_FILE" "$DESKTOP"
+assert_interactive_notroot "Is an icon named '$ICON_TEXT' present on the desktop?" y
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-icon uninstall "$DESK_FILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$DESK_FILE" "$DESKTOP"
+assert_interactive_notroot "Is an icon named '$ICON_TEXT' still present on the desktop?" n
+
+test_result
+}
+
+run_test test_desktop_icon_uninstall
diff --git a/tests/xdg-desktop-menu/data/menu_install.directory b/tests/xdg-desktop-menu/data/menu_install.directory
new file mode 100644
index 0000000..a6f5c2b
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/menu_install.directory
@@ -0,0 +1,3 @@
+[Desktop Entry]
+Type=Directory
+Name=XDG UTILS TEST
diff --git a/tests/xdg-desktop-menu/data/menu_item_category.desktop b/tests/xdg-desktop-menu/data/menu_item_category.desktop
new file mode 100755
index 0000000..b08da4b
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/menu_item_category.desktop
@@ -0,0 +1,6 @@
+[Desktop Entry]
+Type=Application
+Name=Test Menu Categories
+Exec=touch /tmp/xdg-test-menu-item-install.tmp
+Categories=Development;
+StartupNotify=false
diff --git a/tests/xdg-desktop-menu/data/menu_item_dummy.desktop b/tests/xdg-desktop-menu/data/menu_item_dummy.desktop
new file mode 100644
index 0000000..599f107
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/menu_item_dummy.desktop
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=EXTRA ITEM
+Exec=touch xdgtestdata-dummy.tmp
+StartupNotify=false
diff --git a/tests/xdg-desktop-menu/data/menu_item_dummy2.desktop b/tests/xdg-desktop-menu/data/menu_item_dummy2.desktop
new file mode 100644
index 0000000..7a3380f
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/menu_item_dummy2.desktop
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=EXTRA ITEM 2
+Exec=touch xdgtestdata-dummy.tmp
+StartupNotify=false
diff --git a/tests/xdg-desktop-menu/data/menu_item_test.desktop b/tests/xdg-desktop-menu/data/menu_item_test.desktop
new file mode 100644
index 0000000..9e8902a
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/menu_item_test.desktop
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=Test Menu Item Install
+Exec=touch /tmp/xdg-test-menu-item-install.tmp
+StartupNotify=false
diff --git a/tests/xdg-desktop-menu/data/shinythings_example/install-webmirror.sh b/tests/xdg-desktop-menu/data/shinythings_example/install-webmirror.sh
new file mode 100755
index 0000000..9e43918
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/shinythings_example/install-webmirror.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## usage: install-webmirror.sh install user
+## or
+## install-webmirror.sh uninstall system
+## etc.
+
+c="$1"
+p="$2"
+if [ -z "$c" ] ; then
+ c='install'
+fi
+if [ -z "$p" ] ; then
+ p="user"
+fi
+
+xdg-icon-resource "$c" --mode "$p" --size 22 ../../../icons/red-22.png webmirror.png
+xdg-icon-resource "$c" --mode "$p" --size 22 ../../../icons/red-22.png webmirror-menu.png
+xdg-icon-resource "$c" --mode "$p" --size 22 ../../../icons/red-22.png webmirror-admintool.png
+xdg-icon-resource "$c" --mode "$p" --size 64 ../../../icons/red-64.png webmirror.png
+xdg-icon-resource "$c" --mode "$p" --size 64 ../../../icons/red-64.png webmirror-menu.png
+xdg-icon-resource "$c" --mode "$p" --size 64 ../../../icons/red-64.png webmirror-admintool.png
+
+#xdg-desktop-menu "$c" "$p" --vendor shinythings ./webmirror.desktop
+#xdg-desktop-menu "$c" "$p" --vendor shinythings ./webmirror-admin.desktop
+#xdg-desktop-menu "$c" "$p" --vendor shinythings ./webmirror.directory
+#xdg-desktop-menu "$c" "$p" --vendor shinythings ./webmirror.menu
+
+xdg-desktop-menu "$c" --mode "$p" --noupdate ./webmirror.desktop
+xdg-desktop-menu "$c" --mode "$p" --noupdate ./webmirror-admin.desktop
+xdg-desktop-menu "$c" --mode "$p" --noupdate ./webmirror.directory
+xdg-desktop-menu "$c" --mode "$p" --noupdate ./webmirror.menu
+
+xdg-desktop-menu forceupdate "$p"
diff --git a/tests/xdg-desktop-menu/data/shinythings_example/webmirror-admin.desktop b/tests/xdg-desktop-menu/data/shinythings_example/webmirror-admin.desktop
new file mode 100755
index 0000000..838d0a4
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/shinythings_example/webmirror-admin.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Application
+
+Exec=webmirror-admintool
+Icon=webmirror-admintool
+
+Name=WebMirror Admin Tool
+Name[nl]=WebSpiegel Administratie Tool
diff --git a/tests/xdg-desktop-menu/data/shinythings_example/webmirror.desktop b/tests/xdg-desktop-menu/data/shinythings_example/webmirror.desktop
new file mode 100755
index 0000000..1974653
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/shinythings_example/webmirror.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Application
+
+Exec=webmirror
+Icon=webmirror
+
+Name=WebMirror
+Name[nl]=WebSpiegel
+
diff --git a/tests/xdg-desktop-menu/data/shinythings_example/webmirror.directory b/tests/xdg-desktop-menu/data/shinythings_example/webmirror.directory
new file mode 100755
index 0000000..d452112
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/shinythings_example/webmirror.directory
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Encoding=UTF-8
+
+Icon=webmirror-menu
+
+Name=WebMirror Menu
+Name[nl]=WebSpiegel
diff --git a/tests/xdg-desktop-menu/data/shinythings_example/webmirror.menu b/tests/xdg-desktop-menu/data/shinythings_example/webmirror.menu
new file mode 100755
index 0000000..8beb253
--- /dev/null
+++ b/tests/xdg-desktop-menu/data/shinythings_example/webmirror.menu
@@ -0,0 +1,13 @@
+<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 0.8//EN"
+ "http://www.freedesktop.org/standards/menu-spec/menu-0.8.dtd">
+<Menu>
+ <Name>Applications</Name>
+ <Menu>
+ <Name>WebMirror Menu</Name>
+ <Directory>webmirror.directory</Directory>
+ <Include>
+ <Filename>webmirror.desktop</Filename>
+ <Filename>webmirror-admin.desktop</Filename>
+ </Include>
+ </Menu>
+</Menu>
diff --git a/tests/xdg-desktop-menu/t.00-apply_generic b/tests/xdg-desktop-menu/t.00-apply_generic
new file mode 100755
index 0000000..f80aebc
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.00-apply_generic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-desktop-menu"
+done
+
diff --git a/tests/xdg-desktop-menu/t.01-menu_user_forceupdate b/tests/xdg-desktop-menu/t.01-menu_user_forceupdate
new file mode 100755
index 0000000..54a79d3
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.01-menu_user_forceupdate
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## test function
+test_menu_user_forceupdate() {
+test_start "$FUNCNAME: verify forceupdate doesn't error for --mode user"
+
+test_init
+
+set_no_display
+
+test_procedure
+
+assert_exit 0 xdg-desktop-menu forceupdate --mode user
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+run_test test_menu_user_forceupdate
diff --git a/tests/xdg-desktop-menu/t.02-menu_system_as_nonroot b/tests/xdg-desktop-menu/t.02-menu_system_as_nonroot
new file mode 100755
index 0000000..7c972e9
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.02-menu_system_as_nonroot
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_system_as_nonroot() {
+USERPATH="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:$HOME/.local:$HOME/.config:$XDG_DATA_HOME"
+
+## Begin the test.
+test_start "$FUNCNAME: verify error for --mode system when run as a normal user"
+
+# Dependencies section
+test_init
+
+require_notroot
+set_no_display
+
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+assert_file "$DESKTOP"
+
+# Test steps section
+test_procedure
+
+assert_exit 3 xdg-desktop-menu install --mode system "$DESKTOP"
+assert_nostdout
+assert_stderr
+
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+
+assert_exit 3 xdg-desktop-menu uninstall --mode system "$DESKTOP"
+assert_nostdout
+assert_stderr
+
+test_result
+}
+run_test test_menu_system_as_nonroot
diff --git a/tests/xdg-desktop-menu/t.03-menu_system_forceupdate b/tests/xdg-desktop-menu/t.03-menu_system_forceupdate
new file mode 100755
index 0000000..230428f
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.03-menu_system_forceupdate
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## test function
+test_menu_system_forceupdate() {
+test_start "$FUNCNAME: verify forceupdate doesn't error for --mode system"
+
+test_init
+
+set_no_display
+require_root
+
+test_procedure
+
+assert_exit 0 xdg-desktop-menu forceupdate --mode system
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+run_test test_menu_system_forceupdate
diff --git a/tests/xdg-desktop-menu/t.10-simple_menu_item_user_install b/tests/xdg-desktop-menu/t.10-simple_menu_item_user_install
new file mode 100755
index 0000000..2421107
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.10-simple_menu_item_user_install
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_simple_menu_item_user_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify a basic desktop file is installed in the user's applications menu"
+test_purpose "A basic desktop file is installed into the menu."
+
+# Dependencies section
+test_init
+
+# Generate .desktop file
+USERPATH="$HOME/.local"
+
+set_no_display
+
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_category.desktop" DESKTOP
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Categories' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
+
+assert_file "$DESKTOP"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu install --mode user "$DESKTOP"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$DESKTOP" "$USERPATH"
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then
+
+assert_interactive "Is an item called '$ITEM_TEXT' somewhere in the menu tree, possibly in a menu dedicated to 'Development'?" y
+assert_interactive "Please select the menu item '$ITEM_TEXT'"
+
+## Double clicking will result in the command 'touch xdg-test-menu-item-install.tmp' to be run
+assert_file "$WORK_DIR/$CREATEFILE"
+fi
+
+assert_exit 0 xdg-desktop-menu uninstall --mode user "$DESKTOP"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+
+assert_interactive_notroot "Is the menu item '$ITEM_TEXT' still present?" n
+
+test_result
+}
+
+run_test test_simple_menu_item_user_install
diff --git a/tests/xdg-desktop-menu/t.12-menu_user_install b/tests/xdg-desktop-menu/t.12-menu_user_install
new file mode 100755
index 0000000..612889e
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.12-menu_user_install
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_user_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify a user menu is created correctly"
+
+# Dependencies section
+test_init
+
+USERPATH="$HOME/.local:$HOME/.config"
+
+set_no_display
+
+# Generate .desktop file
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
+
+edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
+
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
+
+assert_file "$DESKTOP"
+assert_file "$DIRECTORY"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu install --mode user "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$DESKTOP" "$USERPATH"
+assert_file_in_path "$DESKTOP2" "$USERPATH"
+assert_file_in_path "$DIRECTORY" "$USERPATH"
+
+if [ "$GDMSESSION" = "kde" ] ; then
+ # TODO: HACK: this shouldn't be necessary.
+ assert_interactive_notroot "You are running KDE. Please note that KDE takes time to update it's menus. Please refresh the menu several times prior to answering the following questions."
+fi
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then
+assert_interactive "Is there a menu in <main> called '$MENU_NAME'?" y
+assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXTRA ITEM' and '$ITEM_TEXT'?" y
+assert_interactive "Please select the menu item '<main>/$MENU_NAME/$ITEM_TEXT'"
+
+## Double clicking will result in the command 'touch xdg-test-menu-item-install.tmp' to be run
+assert_file "$WORK_DIR/$CREATEFILE"
+fi
+
+## Cleanup
+xdg-desktop-menu uninstall --mode user "$DIRECTORY" "$DESKTOP" "$DESKTOP2">/dev/null 2>&1
+
+test_result
+}
+
+run_test test_menu_user_install
diff --git a/tests/xdg-desktop-menu/t.13-menu_user_uninstall b/tests/xdg-desktop-menu/t.13-menu_user_uninstall
new file mode 100755
index 0000000..68e24f0
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.13-menu_user_uninstall
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_user_uninstall() {
+## Begin the test.
+test_start "$FUNCNAME: verify a user menu is removed correctly"
+
+# Dependencies section
+test_init
+
+USERPATH="$HOME/.local:$HOME/.config:$HOME/.gnome:$HOME/.kde"
+
+set_no_display
+
+# Generate .desktop file
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
+
+edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
+
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+
+assert_file "$DESKTOP"
+assert_file "$DIRECTORY"
+
+assert_exit 0 xdg-desktop-menu install --mode user "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+
+assert_file_in_path "$DESKTOP" "$USERPATH"
+assert_file_in_path "$DESKTOP" "$USERPATH2"
+assert_file_in_path "$DIRECTORY" "$USERPATH"
+
+assert_interactive_notroot "Is the menu '<main>/$MENU_NAME present with items 'EXTRA_ITEM' and '$ITEM_TEXT'\n\t(NOTE: If you are using KDE, it may take a few seconds to appear.)" y
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu uninstall --mode user "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DESKTOP2" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+
+assert_interactive_notroot "Is the menu '<main>/$MENU_NAME' still present?" n
+assert_interactive_notroot "Is '$ITEM_TEXT' present anywhere in the menu tree?" n
+
+test_result
+
+# Cleanup
+xdg-desktop-menu uninstall --mode user "$DIRECTORY" "$DESKTOP" "$DESKTOP2" > /dev/null 2> /dev/null
+
+}
+
+run_test test_menu_user_uninstall
diff --git a/tests/xdg-desktop-menu/t.14-menu_install_category b/tests/xdg-desktop-menu/t.14-menu_install_category
new file mode 100755
index 0000000..bb7b981
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.14-menu_install_category
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_install_category() {
+## Begin the test.
+test_start "$FUNCNAME: verify that the menu properly supports the '$CATEGORY' category"
+
+# Dependencies section
+test_init
+
+# Generate .desktop file
+#USERPATH="$HOME/.local"
+
+set_no_display
+
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_category.desktop" DESKTOP
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Categories' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" 'Development' TMP "$CATEGORY"
+edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
+
+assert_file "$DESKTOP"
+
+# Verify the test icon is not installed already.
+#assert_file_not_in_path "$DESKTOP" "$USERPATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu install "$DESKTOP"
+assert_nostdout
+assert_nostderr
+
+#assert_file_in_path "$DESKTOP" "$USERPATH"
+
+#if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then
+
+assert_interactive "Is an item called '$ITEM_TEXT' somewhere in the menu tree?\n\tThe item is probably in a menu that is related to '$CATEGORY'?" y
+#fi
+
+## Cleanup
+assert_exit 0 xdg-desktop-menu uninstall "$DESKTOP"
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+repeat_test test_menu_install_category 1 CATEGORY AudioVideo Game Office System Education Graphics Network Utility
diff --git a/tests/xdg-desktop-menu/t.15-menu_advanced_install b/tests/xdg-desktop-menu/t.15-menu_advanced_install
new file mode 100755
index 0000000..502529a
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.15-menu_advanced_install
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_advanced_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify submenus are handled correctly"
+
+# Dependencies section
+test_init
+
+USERPATH="$HOME/.local:$HOME/.config"
+
+set_no_display
+
+# Generate .desktop file
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy2.desktop" DESKTOP3
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
+
+edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
+
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
+
+assert_file "$DESKTOP"
+assert_file "$DIRECTORY"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu install "$DIRECTORY" "$DESKTOP" "$DESKTOP2" "$DESKTOP3"
+assert_nostdout
+assert_nostderr
+
+if [ `whoami` != 'root' ]; then
+assert_file_in_path "$DESKTOP" "$USERPATH"
+assert_file_in_path "$DESKTOP2" "$USERPATH"
+assert_file_in_path "$DESKTOP3" "$USERPATH"
+assert_file_in_path "$DIRECTORY" "$USERPATH"
+fi
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then
+assert_interactive "Is there a menu in <main> called '$MENU_NAME'?" y
+assert_interactive "Are there exactly 3 items in '<main>/$MENU_NAME' called 'EXTRA ITEM', 'EXTRA ITEM 2' and '$ITEM_TEXT'?" y
+fi
+
+assert_exit 0 xdg-desktop-menu uninstall "$DIRECTORY" "$DESKTOP3"
+assert_nostdout
+assert_nostderr
+
+if [ `whoami` != 'root' ]; then
+assert_file_in_path "$DESKTOP" "$USERPATH"
+assert_file_in_path "$DESKTOP2" "$USERPATH"
+assert_file_not_in_path "$DESKTOP3" "$USERPATH"
+assert_file_in_path "$DIRECTORY" "$USERPATH"
+fi
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" -a `whoami` != 'root' ]; then
+assert_interactive "Is there still a menu in <main> called '$MENU_NAME'?" y
+assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXTRA ITEM' and '$ITEM_TEXT'?" y
+fi
+
+assert_exit 0 xdg-desktop-menu uninstall "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+assert_nostdout
+assert_nostderr
+
+if [ `whoami` != 'root' ]; then
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DESKTOP2" "$USERPATH"
+assert_file_not_in_path "$DESKTOP3" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+fi
+
+test_result
+}
+
+run_test test_menu_advanced_install
diff --git a/tests/xdg-desktop-menu/t.20-simple_menu_item_system_install b/tests/xdg-desktop-menu/t.20-simple_menu_item_system_install
new file mode 100755
index 0000000..6839d65
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.20-simple_menu_item_system_install
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_simple_menu_item_system_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify a desktop file is installed in the system applications menu"
+test_purpose "A basic desktop file is installed into the menu."
+
+# Dependencies section
+test_init
+
+# Generate .desktop file
+USERPATH="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:${XDG_CONFIG_DIRS-/etc/xdg}"
+
+require_root
+set_no_display
+
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_category.desktop" DESKTOP
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Categories' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
+
+assert_file "$DESKTOP"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu install --mode system "$DESKTOP"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$DESKTOP" "$USERPATH"
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" ]; then
+assert_interactive "Is an item called '$ITEM_TEXT' somewhere in the menu tree, possibly in a menu dedicated to 'Development'?" y
+assert_interactive "Please select the menu item '$ITEM_TEXT'"
+
+## Double clicking will result in the command 'touch xdg-test-menu-item-install.tmp' to be run
+assert_file "$WORK_DIR/$CREATEFILE"
+
+fi
+
+assert_exit 0 xdg-desktop-menu uninstall --mode system "$DESKTOP"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+
+assert_interactive_notroot "Is the menu item '$ITEM_TEXT' still present?" n
+
+test_result
+}
+
+run_test test_simple_menu_item_system_install
diff --git a/tests/xdg-desktop-menu/t.22-menu_system_install b/tests/xdg-desktop-menu/t.22-menu_system_install
new file mode 100755
index 0000000..2a2a71a
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.22-menu_system_install
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_system_install() {
+## Begin the test.
+test_start "$FUNCNAME: verify a system menu is created correctly"
+
+# Dependencies section
+test_init
+
+USERPATH="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:${XDG_CONFIG_DIRS-/etc/xdg}"
+
+require_root
+set_no_display
+
+# Generate .desktop file
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
+
+edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
+
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" '/tmp' WORK_DIR "$XDG_TEST_TMPDIR"
+
+assert_file "$DESKTOP"
+assert_file "$DIRECTORY"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu install --mode system "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$DESKTOP" "$USERPATH"
+assert_file_in_path "$DESKTOP2" "$USERPATH"
+assert_file_in_path "$DIRECTORY" "$USERPATH"
+
+
+if [ -z "$XDG_TEST_NO_INTERACTIVE" ]; then
+
+assert_interactive "Is there a menu in <main> called '$MENU_NAME'?\n\t(NOTE: If you are using KDE, it may take a few seconds for the menu to appear.)" y
+assert_interactive "Are there exactly 2 items in '<main>/$MENU_NAME' called 'EXTRA ITEM' and '$ITEM_TEXT'?" y
+assert_interactive "Please select the menu item '<main>/$MENU_NAME/$ITEM_TEXT'"
+
+## Double clicking will result in the command 'touch xdg-test-menu-item-install.tmp' to be run
+assert_file "$WORK_DIR/$CREATEFILE"
+
+fi
+
+## Cleanup
+xdg-desktop-menu uninstall --mode system "$DIRECTORY" "$DESKTOP" "$DESKTOP2">/dev/null 2>&1
+
+test_result
+}
+
+run_test test_menu_system_install
diff --git a/tests/xdg-desktop-menu/t.23-menu_system_uninstall b/tests/xdg-desktop-menu/t.23-menu_system_uninstall
new file mode 100755
index 0000000..55165f5
--- /dev/null
+++ b/tests/xdg-desktop-menu/t.23-menu_system_uninstall
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_menu_system_uninstall() {
+## Begin the test.
+test_start "$FUNCNAME: verify a system menu is removed correctly"
+
+# Dependencies section
+test_init
+
+require_root
+set_no_display
+
+USERPATH="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:${XDG_CONFIG_DIRS-/etc/xdg}"
+
+# Generate .desktop file
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_test.desktop" DESKTOP
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_item_dummy.desktop" DESKTOP2
+use_file "$XDG_TEST_DIR/xdg-desktop-menu/data/menu_install.directory" DIRECTORY
+
+edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
+
+edit_file "$DESKTOP" 'xdg-test-menu-item-install.tmp' CREATEFILE
+edit_file "$DESKTOP" 'Test Menu Item Install' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+
+assert_file "$DESKTOP"
+assert_file "$DIRECTORY"
+
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+
+assert_exit 0 xdg-desktop-menu install --mode system "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+
+assert_file_in_path "$DESKTOP" "$USERPATH"
+assert_file_in_path "$DESKTOP" "$USERPATH2"
+assert_file_in_path "$DIRECTORY" "$USERPATH"
+
+assert_interactive "Is the menu '<main>/$MENU_NAME present with items 'EXTRA_ITEM' and '$ITEM_TEXT'.\n\t(NOTE: If you are using KDE, it may take a few seconds to appear.)" y
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-desktop-menu uninstall --mode system "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$DESKTOP" "$USERPATH"
+assert_file_not_in_path "$DESKTOP2" "$USERPATH"
+assert_file_not_in_path "$DIRECTORY" "$USERPATH"
+
+assert_interactive "Is the menu '<main>/$MENU_NAME' still present?\n\t(NOTE: If you are using KDE, it may take a few seconds to disappear.)" n
+assert_interactive "Is '$ITEM_TEXT' present anywhere in the menu tree?" n
+
+test_result
+
+# Cleanup
+xdg-desktop-menu uninstall --mode system "$DIRECTORY" "$DESKTOP" "$DESKTOP2" > /dev/null 2> /dev/null
+
+}
+
+run_test test_menu_system_uninstall
diff --git a/tests/xdg-email/t.00-apply_generic b/tests/xdg-email/t.00-apply_generic
new file mode 100755
index 0000000..2d4f54e
--- /dev/null
+++ b/tests/xdg-email/t.00-apply_generic
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-email"
+done
+
diff --git a/tests/xdg-email/t.10-email_basic b/tests/xdg-email/t.10-email_basic
new file mode 100755
index 0000000..60fdb8b
--- /dev/null
+++ b/tests/xdg-email/t.10-email_basic
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_email_basic() {
+test_start "$FUNCNAME: verify basic email compose"
+
+ADDR="$XDG_TEST_SHORTID@portland.freedesktop.org"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-email "$PRE$ADDR"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did a new email open to '$ADDR' with only the to: field complete?" y
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+repeat_test test_email_basic 1 PRE "" "mailto:"
diff --git a/tests/xdg-email/t.12-email_cc_args b/tests/xdg-email/t.12-email_cc_args
new file mode 100755
index 0000000..426b666
--- /dev/null
+++ b/tests/xdg-email/t.12-email_cc_args
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_cc_args() {
+test_start "$FUNCNAME: verify cc/bcc/subject/body/attach arguments work"
+
+
+addr="$XDG_TEST_SHORTID@portland.freedesktop.org"
+ADDR_TO="to_$addr"
+ADDR_CC="cc_$addr"
+ADDR_BCC="bcc_$addr"
+SUBJ="I am a subject about $XDG_TEST_SHORTID"
+BODY="I am the body. $XDG_TEST_SHORTID is short for $XDG_TEST_ID"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-email --cc "$ADDR_CC" --bcc "$ADDR_BCC" \
+ --subject "$SUBJ" --body "$BODY" "$ADDR_TO"
+
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did a new email open to '$ADDR_TO'?" y
+assert_interactive "Is the cc: line '$ADDR_CC'?" y
+assert_interactive "Is the bcc: line '$ADDR_BCC'?" y
+assert_interactive "Is the subject: line '$SUBJ'?" y
+assert_interactive "Is the body '$BODY'?" y
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+run_test test_cc_args
diff --git a/tests/xdg-email/t.13-email_multi_address b/tests/xdg-email/t.13-email_multi_address
new file mode 100755
index 0000000..c06ec70
--- /dev/null
+++ b/tests/xdg-email/t.13-email_multi_address
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_multi_address() {
+test_start "$FUNCNAME: verify multiple to/cc/bcc arguments work"
+
+addr="$XDG_TEST_SHORTID@portland.freedesktop.org"
+TO1="to-1-$addr"
+TO2="to-2-$addr"
+CC1="cc-1-$addr"
+CC2="cc-2-$addr"
+BCC1="bcc-1-$addr"
+BCC2="bcc-2-$addr"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-email --cc "$CC1" --bcc "$BCC1" \
+ --cc "$CC2" --bcc "$BCC2" --subject 'I am the subject' \
+ --body 'I am the body' "$TO1" "$TO2"
+
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an email open to both '$TO1' and '$TO2'?" y
+assert_interactive "Are both '$CC1' and '$CC2' CC'd?" y
+assert_interactive "Are both '$BCC1' and '$BCC2' BCC'd?" y
+
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+repeat_test test_multi_address 1 PRE "t"
diff --git a/tests/xdg-email/t.21-email_uri_multi_address b/tests/xdg-email/t.21-email_uri_multi_address
new file mode 100755
index 0000000..9d184ea
--- /dev/null
+++ b/tests/xdg-email/t.21-email_uri_multi_address
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_email_uri_multi_address() {
+test_start "$FUNCNAME: verify uri email compose"
+
+ADDR="$XDG_TEST_SHORTID@portland.freedesktop.org"
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-email "mailto:$ADDR?to=t2-$ADDR&subject=Test%20Subject&cc=cc-$ADDR&cc=cc2-$ADDR&body=Test%20Body"
+
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an email open to both '$ADDR' and 't2-$ADDR'?" y
+assert_interactive "Are both 'cc-$ADDR' and 'cc2-$ADDR' CC'd?" y
+assert_interactive "Is the subject 'Test Subject'?" y
+assert_interactive "Is the body 'Test Body'?" y
+
+assert_interactive "Please close any email windows opened by the test." C
+
+
+test_result
+}
+
+run_test test_email_uri_multi_address
diff --git a/tests/xdg-email/t.22-email_mix_args_uri b/tests/xdg-email/t.22-email_mix_args_uri
new file mode 100755
index 0000000..d04a3dd
--- /dev/null
+++ b/tests/xdg-email/t.22-email_mix_args_uri
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_email_mix_args_uri() {
+test_start "$FUNCNAME: verify an email is generated correctly when called with both a uri and not."
+
+ADDR="$XDG_TEST_SHORTID@portland.freedesktop.org"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-email --cc "ccarg-$ADDR" --subject "Subject arg" "mailto:$ADDR?cc=ccuri-$ADDR&body=Body%20URI" "t2-$ADDR"
+
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an email open to both '$ADDR' and 't2-$ADDR'?" y
+assert_interactive "Are both 'ccarg-$ADDR' and 'ccuri-$ADDR' in the CC'd?" y
+assert_interactive "Is the subject 'Subject arg'?" y
+assert_interactive "Is the body 'Body URI'?" y
+
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+run_test test_email_mix_args_uri
diff --git a/tests/xdg-email/t.30-email_attach b/tests/xdg-email/t.30-email_attach
new file mode 100755
index 0000000..648d4a6
--- /dev/null
+++ b/tests/xdg-email/t.30-email_attach
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_email_attach() {
+test_start "$FUNCNAME: verify attach argument works"
+
+ADDR="$XDG_TEST_SHORTID@portland.freedesktop.org"
+
+test_init
+
+require_notroot
+
+## Require a running X server
+assert_display
+
+get_unique_name TARG 'attach.txt'
+echo "I am an attachment." > $TARG
+assert_file "$TARG"
+
+test_procedure
+
+assert_exit 0 xdg-email --attach "$TARG" "$ADDR"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an email open to '$ADDR'?" y
+assert_interactive "Is there an attachment?" y
+
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+run_test test_email_attach
diff --git a/tests/xdg-email/t.31-email_attach_full_path b/tests/xdg-email/t.31-email_attach_full_path
new file mode 100755
index 0000000..fa688c4
--- /dev/null
+++ b/tests/xdg-email/t.31-email_attach_full_path
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_email_attach_full_path() {
+test_start "$FUNCNAME: verify attach argument works"
+
+ADDR="$XDG_TEST_SHORTID@portland.freedesktop.org"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+get_unique_name TARG 'attach.txt'
+echo "I am an attachment." > $TARG
+assert_file "$TARG"
+
+test_procedure
+
+assert_exit 0 xdg-email --attach "$XDG_TEST_TMPDIR/$TARG" "$ADDR"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an email open to '$ADDR'?" y
+assert_interactive "Is there an attachment?" y
+
+
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+run_test test_email_attach_full_path
diff --git a/tests/xdg-email/t.32-email_missing_attach b/tests/xdg-email/t.32-email_missing_attach
new file mode 100755
index 0000000..78c5dc5
--- /dev/null
+++ b/tests/xdg-email/t.32-email_missing_attach
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_email_missing_attach() {
+test_start "$FUNCNAME: verify an error when --attach does not have a valid file"
+
+ADDR="$XDG_TEST_SHORTID@portland.freedesktop.org"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+get_unique_name TARG 'attach.txt'
+assert_nofile "$TARG"
+
+test_procedure
+
+assert_exit 2 xdg-email --attach "$TARG" "$ADDR"
+assert_nostdout
+assert_stderr
+
+assert_interactive "Did an email open to '$ADDR'?" n
+assert_interactive "Please close any email windows opened by the test." C
+
+test_result
+}
+
+run_test test_email_missing_attach
diff --git a/tests/xdg-icon-resource/t.apply_generic b/tests/xdg-icon-resource/t.apply_generic
new file mode 100755
index 0000000..4d6614e
--- /dev/null
+++ b/tests/xdg-icon-resource/t.apply_generic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-icon-resource"
+done
+
diff --git a/tests/xdg-icon-resource/t.icon_duplicate_install b/tests/xdg-icon-resource/t.icon_duplicate_install
new file mode 100755
index 0000000..53b3297
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_duplicate_install
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_duplicate_install() {
+test_start "$FUNCNAME: verify $ICON is installed correctly after already being installed"
+
+## Begin the test.
+userpath="$HOME/.icons:$HOME/.local:$XDG_DATA_HOME"
+
+# Dependencies section
+test_init
+
+set_no_display
+use_file "$XDG_TEST_DIR/icons/$ICON" ICON_FILE
+assert_file "$ICON_FILE"
+
+# Verify the test icon is not installed already.
+assert_exit 0 xdg-icon-resource install --mode user --size "$SIZE" "$ICON_FILE"
+assert_file_in_path "$ICON_FILE" "$userpath"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-icon-resource install --mode user --size "$SIZE" "$ICON_FILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$ICON_FILE" "$userpath"
+
+# Cleanup
+xdg-icon-resource uninstall --mode user --size "$SIZE" "$ICON_FILE"
+
+test_result
+}
+
+repeat_test test_icon_duplicate_install 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
+repeat_test test_icon_duplicate_install 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
diff --git a/tests/xdg-icon-resource/t.icon_nonexist_uninstall b/tests/xdg-icon-resource/t.icon_nonexist_uninstall
new file mode 100755
index 0000000..3a9a8b5
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_nonexist_uninstall
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_nonexist_uninstall() {
+test_start "$FUNCNAME: verify $ICON is uninstalled correctly even if it is not installed"
+
+## Begin the test.
+userpath="$HOME/.icons:$HOME/.local:$XDG_DATA_HOME"
+
+# Dependencies section
+test_init
+
+set_no_display
+use_file "$XDG_TEST_DIR/icons/$ICON" ICON_FILE
+assert_file "$ICON_FILE"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$ICON_FILE" "$userpath"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-icon-resource uninstall --mode user --size "$SIZE" "$ICON_FILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$ICON_FILE" "$userpath"
+
+test_result
+}
+
+repeat_test test_icon_nonexist_uninstall 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
+repeat_test test_icon_nonexist_uninstall 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
diff --git a/tests/xdg-icon-resource/t.icon_system_as_nonroot b/tests/xdg-icon-resource/t.icon_system_as_nonroot
new file mode 100755
index 0000000..a9d46f7
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_system_as_nonroot
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_system_as_nonroot() {
+ICON_PATH="$HOME/.icons:${XDG_DATA_DIRS-/usr/local/share:/usr/share}:/usr/share/pixmaps:$HOME/.local/icons:$XDG_DATA_HOME"
+
+## Begin the test.
+test_start "$FUNCNAME: verify error for --mode system when run as a normal user"
+
+# Dependencies section
+test_init
+
+require_notroot
+set_no_display
+
+use_file "$XDG_TEST_DIR/icons/red-32.png" ICONFILE
+assert_file "$ICONFILE"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$ICONFILE" "$ICON_PATH"
+
+# Test steps section
+test_procedure
+
+assert_exit 3 xdg-icon-resource install --mode system --size 32 "$ICONFILE"
+assert_nostdout
+assert_stderr
+
+assert_file_not_in_path "$ICONFILE" "$ICON_PATH"
+
+assert_exit 3 xdg-icon-resource uninstall --mode system --size 32 "$ICONFILE"
+assert_nostdout
+assert_stderr
+
+test_result
+}
+run_test test_icon_system_as_nonroot
diff --git a/tests/xdg-icon-resource/t.icon_system_install b/tests/xdg-icon-resource/t.icon_system_install
new file mode 100755
index 0000000..b3806da
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_system_install
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_system_install() {
+test_start "$FUNCNAME: verify $ICON is installed correctly with --mode system"
+
+## Begin the test.
+icondir="$XDG_TEST_DIR/icons"
+systempath="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:/usr/share/pixmaps"
+
+# Dependencies section
+test_init
+
+require_root
+set_no_display
+
+use_file "$XDG_TEST_DIR/icons/$ICON" ICONFILE
+assert_file "$ICONFILE"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$ICONFILE" "$systempath"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-icon-resource install --mode system --size "$SIZE" "$ICONFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$ICONFILE" "$systempath"
+
+## Cleanup
+xdg-icon-resource uninstall --mode system --size "$SIZE" "$ICONFILE"
+
+test_result
+}
+
+repeat_test test_icon_system_install 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
+repeat_test test_icon_system_install 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
diff --git a/tests/xdg-icon-resource/t.icon_system_uninstall b/tests/xdg-icon-resource/t.icon_system_uninstall
new file mode 100755
index 0000000..3b80770
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_system_uninstall
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_system_uninstall() {
+test_start "$FUNCNAME: verify $ICON is uninstalled correctly with --mode system"
+
+## Begin the test.
+systempath="${XDG_DATA_DIRS-/usr/local/share:/usr/share}:/usr/share/pixmaps"
+
+# Dependencies section
+test_init
+
+require_root
+set_no_display
+
+use_file "$XDG_TEST_DIR/icons/$ICON" ICONFILE
+assert_file "$ICONFILE"
+
+# Verify the test icon is not installed already.
+assert_exit 0 xdg-icon-resource install --mode system --size "$SIZE" "$ICONFILE"
+assert_file_in_path "$ICONFILE" "$systempath"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-icon-resource uninstall --mode system --size "$SIZE" "$ICONFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$ICONFILE" "$systempath"
+
+test_result
+}
+
+repeat_test test_icon_system_uninstall 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
+repeat_test test_icon_system_uninstall 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
diff --git a/tests/xdg-icon-resource/t.icon_user_install b/tests/xdg-icon-resource/t.icon_user_install
new file mode 100755
index 0000000..fdba2f1
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_user_install
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_user_install() {
+test_start "$FUNCNAME: verify $ICON is installed correctly"
+
+## Begin the test.
+userpath="$HOME/.icons:$HOME/.local:$XDG_DATA_HOME"
+
+# Dependencies section
+test_init
+
+set_no_display
+use_file "$XDG_TEST_DIR/icons/$ICON" ICONFILE
+assert_file "$ICONFILE"
+
+# Verify the test icon is not installed already.
+assert_file_not_in_path "$ICONFILE" "$userpath"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-icon-resource install --mode user --size "$SIZE" "$ICONFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_in_path "$ICONFILE" "$userpath"
+
+xdg-icon-resource uninstall --mode user --size "$SIZE" "$ICONFILE"
+
+test_result
+}
+
+repeat_test test_icon_user_install 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
+repeat_test test_icon_user_install 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
diff --git a/tests/xdg-icon-resource/t.icon_user_uninstall b/tests/xdg-icon-resource/t.icon_user_uninstall
new file mode 100755
index 0000000..ca6222f
--- /dev/null
+++ b/tests/xdg-icon-resource/t.icon_user_uninstall
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_icon_user_uninstall() {
+test_start "$FUNCNAME: verify $ICON is uninstalled correctly"
+
+## Begin the test.
+userpath="$HOME/.icons:$HOME/.local:$XDG_DATA_HOME"
+
+# Dependencies section
+test_init
+
+set_no_display
+use_file "$XDG_TEST_DIR/icons/$ICON" ICONFILE
+assert_file "$ICONFILE"
+
+# Verify the test icon is not installed already.
+assert_exit 0 xdg-icon-resource install --mode user --size "$SIZE" "$ICONFILE"
+assert_file_in_path "$ICONFILE" "$userpath"
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-icon-resource uninstall --mode user --size "$SIZE" "$ICONFILE"
+assert_nostdout
+assert_nostderr
+
+assert_file_not_in_path "$ICONFILE" "$userpath"
+
+test_result
+}
+
+repeat_test test_icon_user_uninstall 2 ICON SIZE 'red-16.png' 'red-22.png' 'red-24.png' 'red-32.png' 16 22 24 32
+repeat_test test_icon_user_uninstall 2 ICON SIZE 'red-48.png' 'red-64.png' 'red-128.png' 48 64 128
diff --git a/tests/xdg-mime/data/test2mime.xml b/tests/xdg-mime/data/test2mime.xml
new file mode 100644
index 0000000..d459869
--- /dev/null
+++ b/tests/xdg-mime/data/test2mime.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="text/x-xdg-testpattern">
+ <comment>xdg-utils mime 01 test</comment>
+ <glob pattern="*.xdg1test"/>
+ </mime-type>
+ <mime-type type="text/x-xdg-test2pattern">
+ <comment>xdg-utils mime 02 test</comment>
+ <glob pattern="*.xdg2test"/>
+ </mime-type>
+</mime-info>
diff --git a/tests/xdg-mime/data/testmime.xml b/tests/xdg-mime/data/testmime.xml
new file mode 100644
index 0000000..938770b
--- /dev/null
+++ b/tests/xdg-mime/data/testmime.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+ <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="text/x-xdg-testpattern">
+ <comment>xdg-utils install mime test</comment>
+ <glob pattern="*.xdgtest"/>
+ </mime-type>
+ </mime-info>
diff --git a/tests/xdg-mime/t.00-apply_generic b/tests/xdg-mime/t.00-apply_generic
new file mode 100755
index 0000000..d3058e6
--- /dev/null
+++ b/tests/xdg-mime/t.00-apply_generic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-mime"
+done
+
diff --git a/tests/xdg-mime/t.01-query_text_plain b/tests/xdg-mime/t.01-query_text_plain
new file mode 100755
index 0000000..80b962f
--- /dev/null
+++ b/tests/xdg-mime/t.01-query_text_plain
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_query_text_plain() {
+# TODO: expand to cover file weirdness.
+INPUT_FILE='testfile.txt'
+
+test_start "$FUNCNAME: verify a query against $INPUT_FILE returns 'text/plain'"
+test_purpose "Verify that the basic query (text/plain) is working."
+
+## Check dependencies
+test_init
+
+require_notroot
+
+echo 'This is some text.' > $INPUT_FILE
+assert_file "$INPUT_FILE"
+
+echo 'text/plain' > out.plain
+
+## Main test
+test_procedure
+
+assert_exit 0 xdg-mime query filetype "$INPUT_FILE"
+assert_stdout out.plain
+assert_nostderr
+
+
+test_result
+}
+
+run_test test_query_text_plain
diff --git a/tests/xdg-mime/t.02-query_missing_file b/tests/xdg-mime/t.02-query_missing_file
new file mode 100755
index 0000000..08045d5
--- /dev/null
+++ b/tests/xdg-mime/t.02-query_missing_file
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_query_missing_file() {
+INPUT_FILE='non-existant-file.xml'
+
+test_start "$FUNCNAME: verify correct error for missing file: $INPUT_FILE"
+test_purpose "Verify that the correct error is generated when the mime file is missing. This is bug 7123 case 1"
+
+## Check dependencies
+test_init
+
+# query requires a desktop environment
+require_notroot
+assert_nofile "$INPUT_FILE"
+
+## Main test
+test_procedure
+
+assert_exit 2 xdg-mime query filetype "$INPUT_FILE"
+assert_stderr
+assert_nostdout
+
+test_result
+}
+
+run_test test_query_missing_file
diff --git a/tests/xdg-mime/t.03-system_as_nonroot b/tests/xdg-mime/t.03-system_as_nonroot
new file mode 100755
index 0000000..cb94ce2
--- /dev/null
+++ b/tests/xdg-mime/t.03-system_as_nonroot
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_system_as_nonroot() {
+# TODO: should follow the filename tests.
+
+## Begin the test.
+test_start "$FUNCNAME: verify error for --mode system when run as a normal user"
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file "$INPUT_FILE"
+echo "text/x-$XDG_TEST_ID" >xdgmime.expected
+
+QUERY_FILE="testfile.xdgtest"
+echo "Some text." > $QUERY_FILE
+assert_file "$QUERY_FILE"
+
+# Verify the test type is not installed already.
+assert_exit 0 xdg-mime query filetype $QUERY_FILE
+assert_stdout
+mv out.stdout out.saved1
+
+# Test steps section
+test_procedure
+
+assert_exit 3 xdg-mime install --mode system "$INPUT_FILE"
+assert_nostdout
+assert_stderr
+
+assert_exit 0 xdg-mime query filetype "$QUERY_FILE"
+assert_stdout out.saved1
+assert_nostderr
+
+assert_exit 3 xdg-mime uninstall --mode system "$INPUT_FILE"
+assert_nostdout
+assert_stderr
+
+test_result
+}
+run_test test_system_as_nonroot
diff --git a/tests/xdg-mime/t.10-user_mime_install b/tests/xdg-mime/t.10-user_mime_install
new file mode 100755
index 0000000..0475b30
--- /dev/null
+++ b/tests/xdg-mime/t.10-user_mime_install
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_user_mime_install() {
+
+## Begin the test.
+test_start "$FUNCNAME: install user mime type"
+test_purpose "Verify that new mime types get installed into the user space correctly"
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file "$INPUT_FILE"
+echo "text/$TEST_MIME" >testmime.expected
+
+echo "Some text." >testfile.xdgtest
+assert_file testfile.xdgtest
+
+
+# Verify the test type is not installed already.
+assert_exit 0 xdg-mime query filetype testfile.xdgtest
+assert_stdout
+mv out.stdout out.save1
+assert_exit 1 diff out.save1 testmime.expected
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime install --mode user "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+sleep 1
+
+assert_exit 0 xdg-mime query filetype testfile.xdgtest
+assert_stdout testmime.expected
+assert_nostderr
+
+# TODO: this is a cleanup step
+xdg-mime uninstall --mode user "$INPUT_FILE"
+
+test_result
+}
+run_test test_user_mime_install
diff --git a/tests/xdg-mime/t.11-user_mime_uninstall b/tests/xdg-mime/t.11-user_mime_uninstall
new file mode 100755
index 0000000..1bf71dd
--- /dev/null
+++ b/tests/xdg-mime/t.11-user_mime_uninstall
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_user_mime_uninstall() {
+# TODO: should follow the filename tests.
+QUERY_FILE="testfile.xdgtest"
+
+## Begin the test.
+test_start "$FUNCNAME: uninstall user mime type"
+test_purpose "Verify that mime types get removed from the user space correctly."
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file "$INPUT_FILE"
+echo "text/$TEST_MIME" >testmime.expected
+
+echo "Some text." >testfile.xdgtest
+assert_file testfile.xdgtest
+
+assert_exit 0 xdg-mime query filetype testfile.xdgtest
+assert_stdout
+mv out.stdout origmime.save
+
+# Install & verify mime type is installed
+assert_exit 0 xdg-mime install --mode user "$INPUT_FILE"
+assert_exit 0 xdg-mime query filetype testfile.xdgtest
+assert_stdout testmime.expected
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime uninstall --mode user "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+## Verify uninstall
+assert_exit 0 xdg-mime query filetype $QUERY_FILE
+assert_stdout origmime.save
+
+test_result
+}
+run_test test_user_mime_uninstall
diff --git a/tests/xdg-mime/t.12-user_install_missing_file b/tests/xdg-mime/t.12-user_install_missing_file
new file mode 100755
index 0000000..a2bd1a2
--- /dev/null
+++ b/tests/xdg-mime/t.12-user_install_missing_file
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_user_install_missing_file() {
+INPUT_FILE='non-existant-file.xml'
+
+test_start "$FUNCNAME: install mime type as user with missing file $INPUT_FILE"
+test_purpose "Verify that the correct error is generated when the mime file is missing."
+
+## Check dependencies
+test_init
+
+require_notroot
+assert_nofile "$INPUT_FILE"
+
+## Main test
+test_procedure
+
+assert_exit 2 xdg-mime install --mode user "$INPUT_FILE"
+assert_stderr
+assert_nostdout
+
+test_result
+}
+
+run_test test_user_install_missing_file
diff --git a/tests/xdg-mime/t.13-notexist_mime_uninstall b/tests/xdg-mime/t.13-notexist_mime_uninstall
new file mode 100755
index 0000000..0d4ca08
--- /dev/null
+++ b/tests/xdg-mime/t.13-notexist_mime_uninstall
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_notexist_mime_uninstall() {
+# TODO: should follow the filename tests.
+QUERY_FILE="testfile.xdgtest"
+
+## Begin the test.
+test_start "$FUNCNAME: uninstall mime type that is not present"
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file $INPUT_FILE
+
+echo "Some text." > $QUERY_FILE
+assert_file "$QUERY_FILE"
+
+# Install & verify mime type is installed
+assert_exit 0 xdg-mime query filetype "$QUERY_FILE" >mimesave.expected
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime uninstall --mode user "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+## Verify no change
+assert_exit 0 xdg-mime query filetype "$QUERY_FILE"
+assert_stdout mimesave.expected
+
+test_result
+}
+run_test test_notexist_mime_uninstall
diff --git a/tests/xdg-mime/t.14-user_mime_install2in1 b/tests/xdg-mime/t.14-user_mime_install2in1
new file mode 100755
index 0000000..adbb4c5
--- /dev/null
+++ b/tests/xdg-mime/t.14-user_mime_install2in1
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_user_mime_install2in1() {
+
+## Begin the test.
+test_start "$FUNCNAME: install user mime type 2 in 1 file"
+test_purpose "Verify that new mime types get installed into the user space correctly when they are in the same file"
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/test2mime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST1_MIME "x-xdg-01-$XDG_TEST_ID"
+edit_file "$INPUT_FILE" "x-xdg-test2pattern" TEST2_MIME "x-xdg-02-$XDG_TEST_ID"
+
+assert_file "$INPUT_FILE"
+echo "text/$TEST1_MIME" >out.expect1
+echo "text/$TEST2_MIME" >out.expect2
+
+echo "Some text." >testfile.xdg1test
+echo "Some text." >testfile.xdg2test
+assert_file testfile.xdg1test
+assert_file testfile.xdg2test
+
+
+# Verify the test type is not installed already.
+assert_exit 0 xdg-mime query filetype testfile.xdg1test
+assert_stdout
+mv out.stdout out.save1
+assert_exit 1 diff out.save1 out.expect1
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime install --mode user "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+sleep 1
+
+assert_exit 0 xdg-mime query filetype testfile.xdg1test
+assert_stdout out.expect1
+assert_nostderr
+
+assert_exit 0 xdg-mime query filetype testfile.xdg2test
+assert_stdout out.expect2
+assert_nostderr
+
+# Cleanup
+xdg-mime uninstall --mode user "$INPUT_FILE" >/dev/null 2>&1
+
+test_result
+}
+run_test test_user_mime_install2in1
diff --git a/tests/xdg-mime/t.15-user_mime_uninstall2in1 b/tests/xdg-mime/t.15-user_mime_uninstall2in1
new file mode 100755
index 0000000..7e8c888
--- /dev/null
+++ b/tests/xdg-mime/t.15-user_mime_uninstall2in1
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_user_mime_uninstall2in1() {
+
+## Begin the test.
+test_start "$FUNCNAME: uninstall user mime type"
+test_purpose "Verify that mime types get removed from the user space correctly."
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/test2mime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST1_MIME "x-xdg-01-$XDG_TEST_ID"
+edit_file "$INPUT_FILE" "x-xdg-test2pattern" TEST2_MIME "x-xdg-02-$XDG_TEST_ID"
+
+assert_file "$INPUT_FILE"
+echo "text/$TEST1_MIME" >out.expect1
+echo "text/$TEST2_MIME" >out.expect2
+
+echo "Some text." >testfile.xdg1test
+echo "Some text." >testfile.xdg2test
+assert_file testfile.xdg1test
+assert_file testfile.xdg2test
+
+
+assert_exit 0 xdg-mime query filetype testfile.xdg1test
+assert_stdout
+mv out.stdout out.save1
+
+assert_exit 0 xdg-mime query filetype testfile.xdg2test
+assert_stdout
+mv out.stdout out.save2
+
+# Install & verify mime type is installed
+assert_exit 0 xdg-mime install --mode user "$INPUT_FILE"
+
+assert_exit 0 xdg-mime query filetype testfile.xdg1test
+assert_stdout out.expect1
+
+assert_exit 0 xdg-mime query filetype testfile.xdg2test
+assert_stdout out.expect2
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime uninstall --mode user "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+## Verify uninstall
+assert_exit 0 xdg-mime query filetype testfile.xdg1test
+assert_stdout out.save1
+
+assert_exit 0 xdg-mime query filetype testfile.xdg2test
+assert_stdout out.save2
+
+test_result
+}
+run_test test_user_mime_uninstall2in1
diff --git a/tests/xdg-mime/t.20-system_mime_install b/tests/xdg-mime/t.20-system_mime_install
new file mode 100755
index 0000000..6e8963f
--- /dev/null
+++ b/tests/xdg-mime/t.20-system_mime_install
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_system_mime_install() {
+
+## Begin the test.
+test_start "$FUNCNAME: install system mime type"
+test_purpose "Verify that new mime types get installed into the system space correctly"
+
+# Dependencies section
+test_init
+
+require_root
+
+set_no_display
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file "$INPUT_FILE"
+
+
+echo "text/$TEST_MIME" >testmime.expected
+
+echo "Some text." >testfile.xdgtest
+assert_file testfile.xdgtest
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime install --mode system "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+# TODO: query requires a running desktop
+#assert_exit 0 xdg-mime query filetype testfile.xdgtest
+#assert_stdout testmime.expected
+#assert_nostderr
+
+xdg-mime uninstall --mode system "$INPUT_FILE" >/dev/null 2>&1
+
+test_result
+}
+run_test test_system_mime_install
diff --git a/tests/xdg-mime/t.21-system_mime_uninstall b/tests/xdg-mime/t.21-system_mime_uninstall
new file mode 100755
index 0000000..4da59fd
--- /dev/null
+++ b/tests/xdg-mime/t.21-system_mime_uninstall
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_system_mime_uninstall() {
+
+## Begin the test.
+test_start "$FUNCNAME: uninstall system mime type"
+test_purpose "Verify that new mime types get removed from the system space correctly"
+
+# Dependencies section
+test_init
+
+require_root
+set_no_display
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file "$INPUT_FILE"
+echo "text/$TEST_MIME" >testmime.expected
+
+echo "Some text." >testfile.xdgtest
+assert_file testfile.xdgtest
+
+# TODO: query requires a desktop environment
+#assert_exit 0 xdg-mime query filetipe testfile.xdgtest
+#assert_stdout
+#mv out.stout out.save
+
+# Install & verify mime type is installed
+assert_exit 0 xdg-mime install --mode system "$INPUT_FILE"
+
+# TODO: query requires a running desktop environment
+#assert_exit 0 xdg-mime query filetype $QUERY_FILE
+#assert_stdout testmime.expected
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime uninstall --mode system "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+## Verify uninstall
+#assert_exit 0 xdg-mime query filetype $QUERY_FILE
+#assert_stdout out.save
+
+test_result
+}
+run_test test_system_mime_uninstall
diff --git a/tests/xdg-mime/t.22-system_install_missing_file b/tests/xdg-mime/t.22-system_install_missing_file
new file mode 100755
index 0000000..7a6233d
--- /dev/null
+++ b/tests/xdg-mime/t.22-system_install_missing_file
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_system_install_missing_file() {
+INPUT_FILE='non-existant-file.xml'
+
+test_start "$FUNCNAME: install mime type as system with missing file $INPUT_FILE"
+test_purpose "Verify that the correct error is generated when the mime file is missing."
+
+## Check dependencies
+test_init
+
+require_root
+set_no_display
+
+assert_nofile "$INPUT_FILE"
+
+## Main test
+test_procedure
+
+assert_exit 2 xdg-mime install --mode system "$INPUT_FILE"
+assert_stderr
+assert_nostdout
+
+test_result
+}
+
+run_test test_system_install_missing_file
diff --git a/tests/xdg-mime/t.23-double_mime_install b/tests/xdg-mime/t.23-double_mime_install
new file mode 100755
index 0000000..8f1439f
--- /dev/null
+++ b/tests/xdg-mime/t.23-double_mime_install
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_double_mime_install() {
+# TODO: should follow the filename tests.
+
+## Begin the test.
+test_start "$FUNCNAME: verify installing an existing mime type is OK"
+
+# Dependencies section
+test_init
+
+require_notroot
+
+use_file "$XDG_TEST_DIR/xdg-mime/data/testmime.xml" INPUT_FILE
+edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST_MIME "x-$XDG_TEST_ID"
+assert_file "$INPUT_FILE"
+echo "text/$TEST_MIME" >testmime.expected
+
+echo "Some text." >testfile.xdgtest
+assert_file testfile.xdgtest
+
+# Verify the test type is not installed already.
+assert_exit 0 xdg-mime install --mode user "$INPUT_FILE"
+assert_exit 0 xdg-mime query filetype testfile.xdgtest
+assert_stdout testmime.expected
+
+# Test steps section
+test_procedure
+
+assert_exit 0 xdg-mime install --mode user "$INPUT_FILE"
+assert_nostdout
+assert_nostderr
+
+assert_exit 0 xdg-mime query filetype testfile.xdgtest
+assert_stdout testmime.expected
+assert_nostderr
+
+# this is a cleanup step
+xdg-mime uninstall --mode user "$INPUT_FILE" >/dev/null 2>&1
+
+test_result
+}
+run_test test_double_mime_install
diff --git a/tests/xdg-open/t.00-apply_generic b/tests/xdg-open/t.00-apply_generic
new file mode 100755
index 0000000..7da4243
--- /dev/null
+++ b/tests/xdg-open/t.00-apply_generic
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-open"
+done
+
diff --git a/tests/xdg-open/t.01-open_basic b/tests/xdg-open/t.01-open_basic
new file mode 100755
index 0000000..48a04c4
--- /dev/null
+++ b/tests/xdg-open/t.01-open_basic
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_open_basic() {
+test_start "$FUNCNAME: verify basic file open test."
+
+test_init
+
+require_notroot
+
+## Require a running X server
+assert_display
+
+get_unique_name TARG 'open.txt'
+echo "I am open." > $TARG
+assert_file "$TARG"
+
+
+test_procedure
+
+assert_exit 0 xdg-open $TARG
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did a text editor open a file containing the string 'I am open.'?" y
+assert_interactive "Please close any windows opened by this test." C
+
+test_result
+}
+
+run_test test_open_basic
diff --git a/tests/xdg-open/t.02-open_dir b/tests/xdg-open/t.02-open_dir
new file mode 100755
index 0000000..835f3b2
--- /dev/null
+++ b/tests/xdg-open/t.02-open_dir
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_open_dir() {
+test_start "$FUNCNAME: verify basic directory open test."
+
+test_init
+
+require_notroot
+
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-open "$XDG_TEST_DIR"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did a file browser open to $XDG_TEST_DIR?" y
+assert_interactive "Please close any windows opened by this test." C
+
+test_result
+}
+
+run_test test_open_dir
diff --git a/tests/xdg-open/t.03-open_url b/tests/xdg-open/t.03-open_url
new file mode 100755
index 0000000..82f59eb
--- /dev/null
+++ b/tests/xdg-open/t.03-open_url
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_open_url() {
+test_start "$FUNCNAME: HTTP open test."
+URL="http://portland.freedesktop.org/wiki/"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_exit 0 xdg-open "$URL"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did a web browser open to '$URL'" y
+assert_interactive "Please close any windows opened by this test." C
+
+test_result
+}
+
+run_test test_open_url
diff --git a/tests/xdg-open/t.04-open_html b/tests/xdg-open/t.04-open_html
new file mode 100755
index 0000000..baef6e0
--- /dev/null
+++ b/tests/xdg-open/t.04-open_html
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+FILE=testfile.html
+test_open_html() {
+test_start "$FUNCNAME: open '$PRE$FILE'"
+
+test_init
+
+require_notroot
+
+## Require a running X server
+assert_display
+
+echo '<html><body>I am an HTML file!</body></html>' >"$FILE"
+assert_file "$FILE"
+
+test_procedure
+
+assert_exit 0 xdg-open "$PRE$FILE"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an HTML file open containing the text 'I am an HTML file!'?" y
+assert_interactive "Please close any windows opened by this test." C
+
+test_result
+}
+
+repeat_test test_open_html 1 PRE '' './'
diff --git a/tests/xdg-open/t.05-open_abs_path_html b/tests/xdg-open/t.05-open_abs_path_html
new file mode 100755
index 0000000..13c4102
--- /dev/null
+++ b/tests/xdg-open/t.05-open_abs_path_html
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+FILE=testfile.html
+test_open_abs_path_html() {
+test_start "$FUNCNAME: open absolute path of the form '$PRE/path/file.html'"
+
+test_init
+
+require_notroot
+
+## Require a running X server
+assert_display
+
+echo '<html><body>I am an HTML file!</body></html>' >"$FILE"
+assert_file "$FILE"
+
+test_procedure
+
+assert_exit 0 xdg-open "$PRE$XDG_TEST_TMPDIR/$FILE"
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did an HTML file open containing the text 'I am an HTML file!'?" y
+assert_interactive "Please close any windows opened by this test." C
+
+test_result
+}
+
+repeat_test test_open_abs_path_html 1 PRE '' 'file://'
diff --git a/tests/xdg-screensaver/t.00-apply_generic b/tests/xdg-screensaver/t.00-apply_generic
new file mode 100755
index 0000000..ed07e30
--- /dev/null
+++ b/tests/xdg-screensaver/t.00-apply_generic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-screensaver"
+done
+
diff --git a/tests/xdg-screensaver/t.01-screensave_status b/tests/xdg-screensaver/t.01-screensave_status
new file mode 100755
index 0000000..b3de2e5
--- /dev/null
+++ b/tests/xdg-screensaver/t.01-screensave_status
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_screensave_status() {
+test_start "$FUNCNAME: verify screensaver status returns 'enabled' or 'disabled'"
+test_purpose "The screensaver may have status 'enabled' or 'disabled'. (Not both as bug 7592.)"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+test_procedure
+
+# TODO: check for exactly one of disabled or enabled on output
+assert_exit 0 xdg-screensaver status
+assert_stdout
+assert_nostderr
+
+## See bug 7592
+screenstat=`cat out.stdout`
+assert_exit 0 test "$screenstat" = 'enabled' -o "$screenstat" = 'disabled'
+
+test_result
+}
+
+run_test test_screensave_status
diff --git a/tests/xdg-screensaver/t.02-screensave_suspend_basic b/tests/xdg-screensaver/t.02-screensave_suspend_basic
new file mode 100755
index 0000000..ef5019c
--- /dev/null
+++ b/tests/xdg-screensaver/t.02-screensave_suspend_basic
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_screensave_suspend_basic() {
+test_start "$FUNCNAME: verify screensaver suspend doesn't error"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+assert_exit 0 test ! -z "$WINDOWID"
+
+echo "disabled" >out.after
+
+sleep 1
+
+test_procedure
+
+assert_exit 0 xdg-screensaver suspend "$WINDOWID"
+assert_nostdout
+assert_nostderr
+
+sleep 1
+
+assert_exit 0 xdg-screensaver status
+assert_stdout out.after
+
+# cleanup
+xdg-screensaver resume "$WINDOWID" >/dev/null 2>&1
+
+test_result
+}
+
+run_test test_screensave_suspend_basic
diff --git a/tests/xdg-screensaver/t.03-screensave_resume_basic b/tests/xdg-screensaver/t.03-screensave_resume_basic
new file mode 100755
index 0000000..7a37274
--- /dev/null
+++ b/tests/xdg-screensaver/t.03-screensave_resume_basic
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_screensave_restore_basic() {
+test_start "$FUNCNAME: verify screensaver restore doesn't error"
+test_procedure "see also bug 7593"
+
+test_init
+
+require_notroot
+## Require a running X server
+assert_display
+
+assert_exit 0 test ! -z "$WINDOWID"
+assert_exit 0 xdg-screensaver status
+assert_stdout
+mv out.stdout out.prev
+
+sleep 1
+
+assert_exit 0 xdg-screensaver suspend "$WINDOWID"
+
+test_procedure
+
+sleep 1
+
+assert_exit 0 xdg-screensaver resume "$WINDOWID"
+assert_nostdout
+assert_nostderr
+
+sleep 1
+
+assert_exit 0 xdg-screensaver status
+assert_stdout out.prev
+
+test_result
+}
+
+run_test test_screensave_restore_basic
diff --git a/tests/xdg-screensaver/t.10-screensave_activate b/tests/xdg-screensaver/t.10-screensave_activate
new file mode 100755
index 0000000..27f28e2
--- /dev/null
+++ b/tests/xdg-screensaver/t.10-screensave_activate
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_screensave_activate() {
+test_start "$FUNCNAME: verify screensaver activate"
+
+test_init
+
+require_notroot
+require_interactive
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_interactive "I will activate the screensaver 1 second after you press enter. Please press shift after it does."
+
+assert_exit 0 xdg-screensaver status
+assert_stdout
+
+mv out.stdout out.stat
+
+sleep 1
+
+assert_exit 0 xdg-screensaver activate
+assert_nostdout
+assert_nostderr
+
+sleep 1
+
+assert_interactive "Did the screensaver activate?" y
+
+assert_exit 0 xdg-screensaver status
+assert_stdout out.stat
+
+test_result
+}
+
+run_test test_screensave_activate
diff --git a/tests/xdg-screensaver/t.11-screensave_reset b/tests/xdg-screensaver/t.11-screensave_reset
new file mode 100755
index 0000000..14b82c1
--- /dev/null
+++ b/tests/xdg-screensaver/t.11-screensave_reset
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_screensave_reset() {
+test_start "$FUNCNAME: verify screensaver reset"
+
+test_init
+
+require_notroot
+require_interactive
+## Require a running X server
+assert_display
+
+assert_exit 0 xdg-screensaver status
+assert_stdout
+mv out.stdout out.stat
+
+assert_interactive "Screensaver will activate 1sec after you press enter, then deactivate in 2 secs. Please be careful not to deactivate it manually."
+
+sleep 1
+assert_exit 0 xdg-screensaver activate
+sleep 2
+test_procedure
+
+assert_exit 0 xdg-screensaver reset
+assert_nostdout
+assert_nostderr
+
+assert_interactive "Did the screensaver deactivate automatically?" y
+
+assert_exit 0 xdg-screensaver status
+assert_stdout out.stat
+
+test_result
+}
+
+run_test test_screensave_reset
diff --git a/tests/xdg-screensaver/t.12-screensave_lock b/tests/xdg-screensaver/t.12-screensave_lock
new file mode 100755
index 0000000..ca6ffc2
--- /dev/null
+++ b/tests/xdg-screensaver/t.12-screensave_lock
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_screensave_lock() {
+test_start "$FUNCNAME: verify screensaver lock"
+
+test_init
+
+require_notroot
+require_interactive
+## Require a running X server
+assert_display
+
+test_procedure
+
+assert_interactive "I will lock the screensaver 1 second after you press enter. Please press shift after it does."
+
+assert_exit 0 xdg-screensaver status
+assert_stdout
+
+mv out.stdout out.stat
+
+sleep 1
+
+assert_exit 0 xdg-screensaver lock
+assert_nostdout
+assert_nostderr
+
+sleep 1
+
+assert_interactive "Did the screensaver activate?" y
+assert_interactive "Were you required to enter your password to de-activate it?" y
+
+assert_exit 0 xdg-screensaver status
+assert_stdout out.stat
+
+test_result
+}
+
+run_test test_screensave_lock
diff --git a/tests/xdg-su/t.00-apply_generic b/tests/xdg-su/t.00-apply_generic
new file mode 100755
index 0000000..187dc82
--- /dev/null
+++ b/tests/xdg-su/t.00-apply_generic
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+. "$XDG_TEST_DIR/include/testfuncs.sh"
+
+test_note This is a dummy test to run the generic tests for this utility.
+
+generic_tests=`ls $XDG_TEST_DIR/generic/t.*`
+for t in $generic_tests; do
+ . "$t"
+ repeat_test "$GENERIC_TEST" 1 "XDGUTIL" "xdg-su"
+done
+
diff --git a/tests/xdg-su/t.01-su_basic_asroot b/tests/xdg-su/t.01-su_basic_asroot
new file mode 100755
index 0000000..b0f3404
--- /dev/null
+++ b/tests/xdg-su/t.01-su_basic_asroot
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_su_basic_asroot() {
+test_start "$FUNCNAME: basic su already root"
+
+test_init
+
+require_root
+assert_display
+
+echo "root" >out.expected
+
+test_procedure
+
+assert_exit 0 xdg-su -c whoami
+assert_stdout out.expected
+assert_nostderr
+
+assert_interactive "Were you prompted for the admin password?" n
+
+test_result
+}
+
+run_test test_su_basic_asroot
diff --git a/tests/xdg-su/t.02-su_basic b/tests/xdg-su/t.02-su_basic
new file mode 100755
index 0000000..fd9db1e
--- /dev/null
+++ b/tests/xdg-su/t.02-su_basic
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_su_basic() {
+test_start "$FUNCNAME: basic su - up-privilege"
+
+test_init
+
+## Require a running X server
+require_notroot
+require_interactive
+
+assert_display
+
+echo "root" >out.expected
+
+test_procedure
+
+assert_interactive "Please make sure there no open password prompt windows.\n\tEnter the admin password when prompted."
+
+assert_exit 0 xdg-su -c 'whoami'
+assert_stdout out.expected
+assert_nostderr
+
+assert_interactive "Were you prompted for the admin password?" y
+
+test_result
+}
+
+run_test test_su_basic
diff --git a/tests/xdg-su/t.03-su_badpass b/tests/xdg-su/t.03-su_badpass
new file mode 100755
index 0000000..1c057ba
--- /dev/null
+++ b/tests/xdg-su/t.03-su_badpass
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_su_badpass() {
+test_start "$FUNCNAME: basic su password failure"
+
+test_init
+
+## Require a running X server
+require_notroot
+require_interactive
+
+assert_display
+
+test_procedure
+
+assert_interactive "Please make sure there no open password prompt windows.\n\tDO NOT enter the correct password when prompted. (Repeat as necessary)"
+
+assert_exit 4 xdg-su -c whoami
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+run_test test_su_badpass
diff --git a/tests/xdg-su/t.04-su_no_carg b/tests/xdg-su/t.04-su_no_carg
new file mode 100755
index 0000000..29d3a39
--- /dev/null
+++ b/tests/xdg-su/t.04-su_no_carg
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_su_no_carg() {
+test_start "$FUNCNAME: expected error when -c has no option"
+
+test_procedure
+
+assert_interactive "Please close any open password prompt windows."
+
+assert_exit 1 xdg-su -c ''
+assert_nostdout
+assert_stderr
+
+assert_interactive "Did a password prompt window appear?" n
+
+test_result
+}
+
+run_test test_su_no_carg
diff --git a/tests/xdg-su/t.05-su_no_cflag b/tests/xdg-su/t.05-su_no_cflag
new file mode 100755
index 0000000..54548f4
--- /dev/null
+++ b/tests/xdg-su/t.05-su_no_cflag
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+## Include utility functions.
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+## Test function
+test_su_no_cflag() {
+test_start "$FUNCNAME: expected error when no -c arg is present"
+test_purpose "Verify bug 7136 has been corrected"
+
+test_procedure
+
+assert_interactive "Please close any open password prompt windows."
+
+assert_exit 1 xdg-su whoami
+assert_nostdout
+assert_stderr
+
+assert_interactive "Did a password prompt window appear?" n
+
+test_result
+}
+
+run_test test_su_no_cflag
diff --git a/tests/xdg-utils-usecases/data/icon_file.xml b/tests/xdg-utils-usecases/data/icon_file.xml
new file mode 100644
index 0000000..ee40e54
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/icon_file.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+ <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="xdgtestdata/icontest">
+ <comment>xdg-utils icon file association test</comment>
+ <glob pattern="*.xdgtestext"/>
+ </mime-type>
+ </mime-info>
diff --git a/tests/xdg-utils-usecases/data/icon_test.desktop b/tests/xdg-utils-usecases/data/icon_test.desktop
new file mode 100644
index 0000000..828a96c
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/icon_test.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Type=Application
+
+Exec=touch xdg-test-desktop-icon-install.tmp
+
+Name=Icon Test
+Icon=red
+StartupNotify=false
diff --git a/tests/xdg-utils-usecases/data/menu_install.directory b/tests/xdg-utils-usecases/data/menu_install.directory
new file mode 100644
index 0000000..15f990d
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/menu_install.directory
@@ -0,0 +1,4 @@
+[Desktop Entry]
+Type=Directory
+Name=XDG UTILS TEST
+Icon=red
diff --git a/tests/xdg-utils-usecases/data/menu_item_dummy.desktop b/tests/xdg-utils-usecases/data/menu_item_dummy.desktop
new file mode 100644
index 0000000..599f107
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/menu_item_dummy.desktop
@@ -0,0 +1,5 @@
+[Desktop Entry]
+Type=Application
+Name=EXTRA ITEM
+Exec=touch xdgtestdata-dummy.tmp
+StartupNotify=false
diff --git a/tests/xdg-utils-usecases/data/mime_launch.desktop b/tests/xdg-utils-usecases/data/mime_launch.desktop
new file mode 100644
index 0000000..78c6c38
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/mime_launch.desktop
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Type=Application
+Name=Mime Launch Test
+Exec=mime_launch.sh %f
+Path=/tmp
+StartupNotify=false
+MimeType=text/x-xdg-testpattern
diff --git a/tests/xdg-utils-usecases/data/mime_launch.sh b/tests/xdg-utils-usecases/data/mime_launch.sh
new file mode 100755
index 0000000..161878a
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/mime_launch.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "file: $1" > exec.out
diff --git a/tests/xdg-utils-usecases/data/mime_launch.xml b/tests/xdg-utils-usecases/data/mime_launch.xml
new file mode 100644
index 0000000..729d0a0
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/mime_launch.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+ <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="text/x-xdg-testpattern">
+ <comment>xdg-utils mime launch test</comment>
+ <glob pattern="*.xdgtest"/>
+ </mime-type>
+ </mime-info>
diff --git a/tests/xdg-utils-usecases/data/testfile b/tests/xdg-utils-usecases/data/testfile
new file mode 100644
index 0000000..5f6e649
--- /dev/null
+++ b/tests/xdg-utils-usecases/data/testfile
Binary files differ
diff --git a/tests/xdg-utils-usecases/t.01-default_mime_launch b/tests/xdg-utils-usecases/t.01-default_mime_launch
new file mode 100755
index 0000000..b67f7e4
--- /dev/null
+++ b/tests/xdg-utils-usecases/t.01-default_mime_launch
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_default_mime_launch() {
+
+test_start "$FUNCNAME: verify we can install a mime type & associate it with an application"
+
+test_init
+require_notroot
+
+# Set up files
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/mime_launch.xml" MIME_FILE
+edit_file "$MIME_FILE" "x-xdg-testpattern" MIME2ND "x-$XDG_TEST_ID"
+edit_file "$MIME_FILE" xdgtest EXTEN "xdgt-$XDG_TEST_SHORTID"
+
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/mime_launch.sh" SHELL_FILE
+
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/mime_launch.desktop" DESKTOP_FILE
+edit_file "$DESKTOP_FILE" "x-xdg-testpattern" TMP "$MIME2ND"
+edit_file "$DESKTOP_FILE" '/tmp' TMP "$XDG_TEST_TMPDIR"
+edit_file "$DESKTOP_FILE" 'include' TMP "$XDG_TEST_DIR/include"
+edit_file "$DESKTOP_FILE" 'mime_launch.sh' TMP "$XDG_TEST_TMPDIR/$SHELL_FILE"
+
+TEST_FILE="testfile.$EXTEN"
+echo "Some text to make the textfile not empty" >"$TEST_FILE"
+
+MIME_TYPE="text/$MIME2ND"
+
+test_procedure
+
+# Install Desktop file
+assert_exit 0 xdg-desktop-menu install "$DESKTOP_FILE"
+assert_nostdout
+assert_nostderr
+
+# Install Mime file
+assert_exit 0 xdg-mime install "$MIME_FILE"
+assert_nostdout
+assert_nostderr
+
+# Verify mimetype
+echo "$MIME_TYPE" >out.expected
+assert_exit 0 xdg-mime query filetype "$TEST_FILE"
+MIME_INPUT=`cat out.stdout`
+assert_stdout out.expected
+assert_nostderr
+
+# Verify application is as expected
+echo "$DESKTOP_FILE" >out.expected
+assert_exit 0 xdg-mime query default "$MIME_TYPE"
+assert_stdout out.expected
+assert_nostderr
+
+# Verify correct application opens
+assert_exit 0 xdg-open "$TEST_FILE"
+assert_nostdout
+assert_nostderr
+
+echo "file: $XDG_TEST_TMPDIR/$TEST_FILE" >out.expect
+
+# exec.out is created by xdg-open
+assert_file "$XDG_TEST_TMPDIR/exec.out" 'out.expect'
+
+#cleanup
+assert_exit 0 xdg-desktop-menu uninstall "$DESKTOP_FILE"
+assert_nostdout
+assert_nostderr
+
+assert_exit 0 xdg-mime uninstall "$MIME_FILE"
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+run_test test_default_mime_launch
diff --git a/tests/xdg-utils-usecases/t.10-file_icon b/tests/xdg-utils-usecases/t.10-file_icon
new file mode 100755
index 0000000..6215b65
--- /dev/null
+++ b/tests/xdg-utils-usecases/t.10-file_icon
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_file_icon() {
+
+test_start "$FUNCNAME: ensure that associations with filetypes is correct."
+
+ICON_SIZES="16 22 24 32 48 64 128"
+
+test_init
+
+# get icon files
+for i in $ICON_SIZES; do
+ use_file "$XDG_TEST_DIR/icons/red-$i.png" TMP
+done
+
+# get & edit mime file
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/icon_file.xml" MIME_FILE
+edit_file "$MIME_FILE" 'icontest' MIME_MINOR "x-$XDG_TEST_SHORTID"
+edit_file "$MIME_FILE" 'xdgtestext' EXT "f$XDG_TEST_SHORTID"
+
+MIME_TYPE="xdgtestdata/$MIME_MINOR"
+TEST_FILE="testfile.$EXT"
+TEST_DIR="$XDG_TEST_TMPDIR/show"
+assert_exit 0 mkdir -p "$TEST_DIR"
+
+test_procedure
+
+# install icons of all sizes
+for i in $ICON_SIZES; do
+ assert_exit 0 xdg-icon-resource install --context mimetypes --size "$i" "xdgtestdata-$XDG_TEST_ID-red-$i.png" "xdgtestdata-$MIME_MINOR"
+ assert_nostdout
+ assert_nostderr
+done
+
+# associate icons with mime-type
+assert_exit 0 xdg-mime install "$MIME_FILE"
+assert_nostdout
+assert_nostderr
+
+cp "$XDG_TEST_DIR/xdg-utils-usecases/data/testfile" "$TEST_DIR/$TEST_FILE"
+
+# Wait a little for caches to update
+sleep 1
+
+# open directory with test file
+if [ `whoami` != 'root' ] ; then
+ assert_exit 0 xdg-open "$TEST_DIR"
+ assert_nostdout
+ assert_nostderr
+ assert_interactive "Did the file browser open the '$TEST_DIR' directory?" y
+else
+ assert_interactive "Please open '$TEST_DIR' in the file browser."
+fi
+
+# ask user to cycle through sizes & ensure correct icons are displayed.
+assert_interactive "Is a file named '$TEST_FILE' present in the directory?" y
+assert_interactive "Does the icon consist of a red number in the list {$ICON_SIZES}?\n\t(You may need to select something like 'View->As Icons')" y
+# assert_interactive "Does the number change appropriately when you increase or decrease the view size?" y
+
+## cleanup
+if [ `whoami` != 'root' ] ; then
+ assert_interactive "Please close any windows opened by this test." C
+else
+ assert_interactive "You may close the file browser window." C
+fi
+
+# remove icons
+for i in $ICON_SIZES; do
+ assert_exit 0 xdg-icon-resource uninstall --context mimetypes --size "$i" "xdgtestdata-$MIME_MINOR"
+ assert_nostdout
+ assert_nostderr
+done
+
+# remove mime file
+assert_exit 0 xdg-mime uninstall "$MIME_FILE"
+assert_nostdout
+assert_nostderr
+
+test_result
+}
+
+run_test test_file_icon
diff --git a/tests/xdg-utils-usecases/t.11-desktop_file_icon b/tests/xdg-utils-usecases/t.11-desktop_file_icon
new file mode 100755
index 0000000..9a1511a
--- /dev/null
+++ b/tests/xdg-utils-usecases/t.11-desktop_file_icon
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_desktop_file_icon() {
+
+test_start "$FUNCNAME: ensure that associations with filetypes is correct."
+
+ICON_SIZES="16 22 24 32 48 64 128"
+
+test_init
+
+# get icon files
+for i in $ICON_SIZES; do
+ use_file "$XDG_TEST_DIR/icons/red-$i.png" TMP
+done
+
+# get & edit desktop file
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/icon_test.desktop" DESKTOP_FILE
+edit_file "$DESKTOP_FILE" 'red' ICON_NAME
+TEST_DIR="$XDG_TEST_TMPDIR/show"
+assert_exit 0 mkdir -p "$TEST_DIR"
+assert_exit 0 cp "$DESKTOP_FILE" "$TEST_DIR/IconTest.desktop"
+
+test_procedure
+
+# install icons of all sizes
+for i in $ICON_SIZES; do
+ assert_exit 0 xdg-icon-resource install --size "$i" "xdgtestdata-$XDG_TEST_ID-red-$i.png" "$ICON_NAME"
+ assert_nostdout
+ assert_nostderr
+done
+
+# Wait a little for caches to update
+sleep 1
+
+# open directory with test file
+if [ `whoami` != 'root' ] ; then
+ assert_exit 0 xdg-open "$TEST_DIR"
+ assert_nostdout
+ assert_nostderr
+ assert_interactive "Did the file browser open the '$TEST_DIR' directory?" y
+else
+ assert_interactive "Please open '$TEST_DIR' in the file browser."
+fi
+
+# ask user to cycle through sizes & ensure correct icons are displayed.
+assert_interactive "Is a file named either 'Icon Test' or 'IconTest.desktop' present in the directory?" y
+assert_interactive "Does the icon consist of a red number?\n\t(You may need to select something like 'View->As Icons')" y
+# assert_interactive "Does the number change appropriately when you increase or decrease the view size?" y
+
+## cleanup
+if [ `whoami` != 'root' ] ; then
+ assert_interactive "Please close any windows opened by this test." C
+else
+ assert_interactive "You may close the file browser window." C
+fi
+
+# remove icons
+for i in $ICON_SIZES; do
+ xdg-icon-resource uninstall --size "$i" "$ICON_NAME" > /dev/null 2> /dev/null
+done
+
+test_result
+}
+
+run_test test_desktop_file_icon
diff --git a/tests/xdg-utils-usecases/t.14-desktop_menu_icon b/tests/xdg-utils-usecases/t.14-desktop_menu_icon
new file mode 100755
index 0000000..527c047
--- /dev/null
+++ b/tests/xdg-utils-usecases/t.14-desktop_menu_icon
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+. "$XDG_TEST_DIR/include/testassertions.sh"
+. "$XDG_TEST_DIR/include/testcontrol.sh"
+
+test_desktop_menu_icon() {
+
+test_start "$FUNCNAME: ensure that icons show up correctly in menu."
+
+ICON_SIZES="16 22 24 32 48 64 128"
+
+test_init
+
+# get icon files
+for i in $ICON_SIZES; do
+ use_file "$XDG_TEST_DIR/icons/red-$i.png" TMP
+done
+
+# get & edit desktop file
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/icon_test.desktop" DESKTOP
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/menu_item_dummy.desktop" DESKTOP2
+use_file "$XDG_TEST_DIR/xdg-utils-usecases/data/menu_install.directory" DIRECTORY
+
+edit_file "$DESKTOP" 'Icon Test' ITEM_TEXT "TEST $XDG_TEST_SHORTID"
+edit_file "$DESKTOP" 'red' ICON_NAME "red-$XDG_TEST_SHORTID"
+
+edit_file "$DIRECTORY" 'XDG UTILS TEST' MENU_NAME "MENU $XDG_TEST_SHORTID"
+edit_file "$DIRECTORY" 'red' ICON_NAME "red-$XDG_TEST_SHORTID"
+
+assert_file "$DESKTOP"
+assert_file "$DESKTOP2"
+assert_file "$DIRECTORY"
+
+test_procedure
+
+# install icons of all sizes
+for i in $ICON_SIZES; do
+ assert_exit 0 xdg-icon-resource install --size "$i" "xdgtestdata-$XDG_TEST_ID-red-$i.png" "$ICON_NAME"
+ assert_nostdout
+ assert_nostderr
+done
+
+assert_exit 0 xdg-desktop-menu install "$DIRECTORY" "$DESKTOP" "$DESKTOP2"
+assert_nostdout
+assert_nostderr
+
+# Wait a little for caches to update
+sleep 1
+
+assert_interactive "Is there a menu in <main> called '$MENU_NAME'?" y
+assert_interactive "Does the menu '$MENU_NAME' have a red number as its icon?" y
+assert_interactive "Does the menu entry '$ITEM_TEXT' in '<main>/$MENU_NAME' have a red number as its icon?" y
+
+## cleanup
+
+xdg-desktop-menu uninstall "$DIRECTORY" "$DESKTOP" "$DESKTOP2" > /dev/null 2> /dev/null
+
+# remove icons
+for i in $ICON_SIZES; do
+ xdg-icon-resource uninstall --size "$i" "$ICON_NAME" > /dev/null 2> /dev/null
+done
+
+test_result
+}
+
+run_test test_desktop_menu_icon \ No newline at end of file