diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | scripts/Makefile.in | 9 | ||||
-rw-r--r-- | scripts/generate-help-script.awk | 106 | ||||
-rwxr-xr-x | scripts/xdg-copy | 13 | ||||
-rwxr-xr-x | scripts/xdg-copy.in | 6 | ||||
-rwxr-xr-x | scripts/xdg-desktop | 1 | ||||
-rwxr-xr-x | scripts/xdg-email | 13 | ||||
-rwxr-xr-x | scripts/xdg-email.in | 6 | ||||
-rwxr-xr-x | scripts/xdg-file-dialog | 20 | ||||
-rwxr-xr-x | scripts/xdg-file-dialog.in | 6 | ||||
-rwxr-xr-x | scripts/xdg-menu | 117 | ||||
-rwxr-xr-x | scripts/xdg-menu.in | 6 | ||||
-rwxr-xr-x | scripts/xdg-mime | 18 | ||||
-rwxr-xr-x | scripts/xdg-mime.in | 6 | ||||
-rwxr-xr-x | scripts/xdg-open | 18 | ||||
-rwxr-xr-x | scripts/xdg-open.in | 6 | ||||
-rwxr-xr-x | scripts/xdg-su | 13 | ||||
-rwxr-xr-x | scripts/xdg-su.in | 6 | ||||
-rw-r--r-- | scripts/xdg-utils-common.in | 1 |
19 files changed, 367 insertions, 7 deletions
@@ -4,6 +4,9 @@ * 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 diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 9d24ae0..1839f19 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -22,8 +22,6 @@ SCRIPTS = \ xdg-copy \ xdg-file-dialog -do_subst = sed -e '/[@]xdg-utils-common[@]/ r xdg-utils-common.in' | sed -e '/LICENSE:/ r ../LICENSE' - all: scripts: README $(SCRIPTS) @@ -68,8 +66,8 @@ uninstall: done -$(RMDIR) $(bindir) -%: %.in %.usage %.1 %.html - cat $@.in | $(do_subst) | sed -e '/<< _USAGE/ r '$@.usage >$@ +%: %.in %.txt %.1 %.html + awk -f generate-help-script.awk $@.in > $@ chmod a+x $@ xdg-menu: xdg-menu.in xdg-utils-common.in @@ -90,6 +88,3 @@ xdg-file-dialog: xdg-file-dialog.in xdg-utils-common.in %.txt: desc/%.xml $(XMLTO) txt $< -%.usage: %.txt - grep -B 100 Description $< | sed -e '1,2d' -e '$$d' > $@ - diff --git a/scripts/generate-help-script.awk b/scripts/generate-help-script.awk new file mode 100644 index 0000000..b59dfd6 --- /dev/null +++ b/scripts/generate-help-script.awk @@ -0,0 +1,106 @@ +#!/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 << _EXAMPLES" line +/^cat << _EXAMPLES/ { + # 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 + } + } + 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) { + 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/xdg-copy b/scripts/xdg-copy index 027727b..d8b0718 100755 --- a/scripts/xdg-copy +++ b/scripts/xdg-copy @@ -32,6 +32,18 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +Examples + +xdg-copy "http://portland.freedesktop.org/png/freedesktop-logo.png" . + +xdg-copy "/tmp/foobar.png" "/home/user/foobar-copy.png" + +_EXAMPLES +} + usage() { cat << _USAGE @@ -135,6 +147,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-copy.in b/scripts/xdg-copy.in index 42a77ab..6020ee0 100755 --- a/scripts/xdg-copy.in +++ b/scripts/xdg-copy.in @@ -14,6 +14,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-desktop b/scripts/xdg-desktop index b1147b9..a8462fe 100755 --- a/scripts/xdg-desktop +++ b/scripts/xdg-desktop @@ -135,6 +135,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-email b/scripts/xdg-email index 992283e..1a4334e 100755 --- a/scripts/xdg-email +++ b/scripts/xdg-email @@ -32,6 +32,18 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +Examples + +xdg-email 'mailto:jwhite@codeweavers.com?subject=Logo contest&' \ + 'body=Attached you find the logo for the contest.&' \ + 'attachment=/tmp/logo.png' + +_EXAMPLES +} + usage() { cat << _USAGE @@ -136,6 +148,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-email.in b/scripts/xdg-email.in index 2fdf058..e16e530 100755 --- a/scripts/xdg-email.in +++ b/scripts/xdg-email.in @@ -14,6 +14,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-file-dialog b/scripts/xdg-file-dialog index 33524e0..9bfb3c4 100755 --- a/scripts/xdg-file-dialog +++ b/scripts/xdg-file-dialog @@ -31,6 +31,25 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +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 --title "Select a target folder" --directory /tmp + + +Asks for a directory name starting in directory /tmp using the text "Select a +target folder" as the dialog's title/caption. + +_EXAMPLES +} + usage() { cat << _USAGE @@ -136,6 +155,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-file-dialog.in b/scripts/xdg-file-dialog.in index 0f6d6b8..90545d2 100755 --- a/scripts/xdg-file-dialog.in +++ b/scripts/xdg-file-dialog.in @@ -13,6 +13,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-menu b/scripts/xdg-menu index d770107..17d94c3 100755 --- a/scripts/xdg-menu +++ b/scripts/xdg-menu @@ -33,6 +33,122 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +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: + +webmirror.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror + Icon=webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + + Categories=Network;WebDevelopment; + +Now the xdg-menu tool can be used to add the webmirror.desktop file to the +desktop application menu: + +xdg-menu --system --vendor shinythings --install ./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. wants to 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, this time no Categories item is needed: + +webmirror.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror + Icon=webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + + +webmirror-admin.desktop: + + [Desktop Entry] + Encoding=UTF-8 + Type=Application + + Exec=webmirror-admintool + Icon=webmirror-admintool + + Name=WebMirror Admin Tool + Name[nl]=WebSpiegel Administratie Tool + +The files can be installed with: + +xdg-menu --system --noupdate --vendor shinythings --install ./webmirror.desktop +xdg-menu --system --noupdate --vendor shinythings --install ./webmirror-admin.desktop + +Because multiple items are added the --noupdate option has been used. + +In addition a .directory file needs to be created to provide a title and icon +for the sub-menu itself: + +webmirror.directory: + + [Desktop Entry] + Encoding=UTF-8 + + Icon=webmirror + + Name=WebMirror + Name[nl]=WebSpiegel + +This webmirror.directorty file can be installed with: + +xdg-menu --system --noupdate --vendor shinythings --install ./webmirror.directory + +The last step is to provide a .menu file that links it all togther: + +webmirror.menu: + + <!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 0.8//EN" + "http://www.freedesktop.org/standards/menu-spec/menu-0.8.dtd"> + <Menu> + <Menu> + <Name>WebMirror</Name> + <Directory>shinythings-webmirror.directory</Directory> + <Include> + <Filename>shinythings-webmirror.desktop</Filename> + <Filename>shinythings-webmirror-admin.desktop</Filename> + </Include> + </Menu> + </Menu> + +The webmirror.menu file can be installed with: + +xdg-menu --system --noupdate --vendor shinythings --install ./webmirror.menu + +After installing multiple files with --noupdate make sure to force an update: + +xdg-menu --system --forceupdate + +_EXAMPLES +} + usage() { cat << _USAGE @@ -139,6 +255,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-menu.in b/scripts/xdg-menu.in index 7638d80..d574bd7 100755 --- a/scripts/xdg-menu.in +++ b/scripts/xdg-menu.in @@ -15,6 +15,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-mime b/scripts/xdg-mime index 8504317..8e06205 100755 --- a/scripts/xdg-mime +++ b/scripts/xdg-mime @@ -32,6 +32,23 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +Examples + +xdg-mime --info /tmp/foobar.png + +Prints the MIME type of the file /tmp/foobar.png + +xdg-mime --defapp /tmp/foobar.png + +Prints the name of the .desktop file of the application which is registered to +open files of the MIME type the file /tmp/foobar.png has + +_EXAMPLES +} + usage() { cat << _USAGE @@ -135,6 +152,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-mime.in b/scripts/xdg-mime.in index 162552a..ff2d7a5 100755 --- a/scripts/xdg-mime.in +++ b/scripts/xdg-mime.in @@ -14,6 +14,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-open b/scripts/xdg-open index 71ceceb..1c96780 100755 --- a/scripts/xdg-open +++ b/scripts/xdg-open @@ -31,6 +31,23 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +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. + +_EXAMPLES +} + usage() { cat << _USAGE @@ -134,6 +151,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in index 5a9b8cd..1de47bc 100755 --- a/scripts/xdg-open.in +++ b/scripts/xdg-open.in @@ -13,6 +13,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-su b/scripts/xdg-su index cad738b..11a6b2c 100755 --- a/scripts/xdg-su +++ b/scripts/xdg-su @@ -33,6 +33,18 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +Examples + +xdg-su -u root -c "/opt/shinythings/bin/install-GUI --install fast" + +Runs the /opt/shinythings/bin/install-GUI command with root permissions. + +_EXAMPLES +} + usage() { cat << _USAGE @@ -136,6 +148,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; diff --git a/scripts/xdg-su.in b/scripts/xdg-su.in index 68a7242..9d0a847 100755 --- a/scripts/xdg-su.in +++ b/scripts/xdg-su.in @@ -15,6 +15,12 @@ # #--------------------------------------------- +examples() +{ +cat << _EXAMPLES +_EXAMPLES +} + usage() { cat << _USAGE diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in index 0c2935c..0b8684d 100644 --- a/scripts/xdg-utils-common.in +++ b/scripts/xdg-utils-common.in @@ -88,6 +88,7 @@ check_common_commands() case $parm in --help) usage + examples exit_success ;; |