| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 #--------------------------------------------- | 2 #--------------------------------------------- |
| 3 # xdg-desktop-menu | 3 # xdg-desktop-menu |
| 4 # | 4 # |
| 5 # Utility script to install menu items on a Linux desktop. | 5 # Utility script to install menu items on a Linux desktop. |
| 6 # Refer to the usage() function below for usage. | 6 # Refer to the usage() function below for usage. |
| 7 # | 7 # |
| 8 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org> | 8 # Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org> |
| 9 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org> | 9 # Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org> |
| 10 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> | 10 # Copyright 2006, Kevin Krammer <kevin.krammer@gmx.at> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 or more category keywords, or they can be added to a new submenu. | 75 or more category keywords, or they can be added to a new submenu. |
| 76 | 76 |
| 77 To add a menu entry to a predefined submenu the desktop file that | 77 To add a menu entry to a predefined submenu the desktop file that |
| 78 represents the menu entry must have a Categories= entry that lists one or | 78 represents the menu entry must have a Categories= entry that lists one or |
| 79 more keywords. The menu item will be included in an appropriate submenu | 79 more keywords. The menu item will be included in an appropriate submenu |
| 80 based on the included keywords. | 80 based on the included keywords. |
| 81 | 81 |
| 82 To add menu items to a new submenu the desktop-files must be preceded by a | 82 To add menu items to a new submenu the desktop-files must be preceded by a |
| 83 directory-file that describes the submenu. If multiple desktop-files are | 83 directory-file that describes the submenu. If multiple desktop-files are |
| 84 specified, all entries will be added to the same menu. If entries are | 84 specified, all entries will be added to the same menu. If entries are |
| 85 installed to a menu that has been created with a previous call to | 85 installed to a menu that has been created with a previous call to |
| 86 xdg-desktop-menu the entries will be installed in addition to any already | 86 xdg-desktop-menu the entries will be installed in addition to any already |
| 87 existing entries. | 87 existing entries. |
| 88 | 88 |
| 89 directory-file: The *.directory file indicated by directory-file represents | 89 directory-file: The *.directory file indicated by directory-file represents |
| 90 a submenu. The directory file provides the name and icon for a submenu. The | 90 a submenu. The directory file provides the name and icon for a submenu. The |
| 91 name of the directory file is used to identify the submenu. | 91 name of the directory file is used to identify the submenu. |
| 92 | 92 |
| 93 If multiple directory files are provided each file will represent a submenu | 93 If multiple directory files are provided each file will represent a submenu |
| 94 within the menu that preceeds it, creating a nested menu hierarchy | 94 within the menu that preceeds it, creating a nested menu hierarchy |
| 95 (sub-sub-menus). The menu entries themselves will be added to the last | 95 (sub-sub-menus). The menu entries themselves will be added to the last |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for
additional info." | 569 echo "Use 'man xdg-desktop-menu' or 'xdg-desktop-menu --manual' for
additional info." |
| 570 exit_success | 570 exit_success |
| 571 ;; | 571 ;; |
| 572 | 572 |
| 573 --manual) | 573 --manual) |
| 574 manualpage | 574 manualpage |
| 575 exit_success | 575 exit_success |
| 576 ;; | 576 ;; |
| 577 | 577 |
| 578 --version) | 578 --version) |
| 579 echo "xdg-desktop-menu 1.0.2" | 579 echo "xdg-desktop-menu 1.1.0 rc1" |
| 580 exit_success | 580 exit_success |
| 581 ;; | 581 ;; |
| 582 esac | 582 esac |
| 583 done | 583 done |
| 584 } | 584 } |
| 585 | 585 |
| 586 check_common_commands "$@" | 586 check_common_commands "$@" |
| 587 | 587 |
| 588 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; | 588 [ -z "${XDG_UTILS_DEBUG_LEVEL}" ] && unset XDG_UTILS_DEBUG_LEVEL; |
| 589 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then | 589 if [ ${XDG_UTILS_DEBUG_LEVEL-0} -lt 1 ]; then |
| 590 # Be silent | 590 # Be silent |
| 591 xdg_redirect_output=" > /dev/null 2> /dev/null" | 591 xdg_redirect_output=" > /dev/null 2> /dev/null" |
| 592 else | 592 else |
| 593 # All output to stderr | 593 # All output to stderr |
| 594 xdg_redirect_output=" >&2" | 594 xdg_redirect_output=" >&2" |
| 595 fi | 595 fi |
| 596 | 596 |
| 597 #-------------------------------------- | 597 #-------------------------------------- |
| 598 # Checks for known desktop environments | 598 # Checks for known desktop environments |
| 599 # set variable DE to the desktop environments name, lowercase | 599 # set variable DE to the desktop environments name, lowercase |
| 600 | 600 |
| 601 detectDE() | 601 detectDE() |
| 602 { | 602 { |
| 603 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; | 603 if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; |
| 604 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; | 604 elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; |
| 605 elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/D
Bus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/nul
l 2>&1` ; then DE=gnome; | 605 elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/D
Bus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/nul
l 2>&1` ; then DE=gnome; |
| 606 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; | 606 elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/nul
l 2>&1; then DE=xfce; |
| 607 elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde; |
| 608 else DE="" |
| 607 fi | 609 fi |
| 608 } | 610 } |
| 609 | 611 |
| 610 #---------------------------------------------------------------------------- | 612 #---------------------------------------------------------------------------- |
| 611 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 | 613 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 |
| 612 # It also always returns 1 in KDE 3.4 and earlier | 614 # It also always returns 1 in KDE 3.4 and earlier |
| 613 # Simply return 0 in such case | 615 # Simply return 0 in such case |
| 614 | 616 |
| 615 kfmclient_fix_exit_code() | 617 kfmclient_fix_exit_code() |
| 616 { | 618 { |
| 617 version=`kde${KDE_SESSION_VERSION}-config --version 2>/dev/null | grep KDE` | 619 [ x"$KDE_SESSION_VERSION" = x"4" ] && return 0; |
| 618 major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` | 620 version=`LC_ALL=C.UTF-8 kde-config --version 2>/dev/null | grep '^KDE'` |
| 619 minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` | 621 major=`echo $version | sed 's/KDE.*: \([0-9]\).*/\1/'` |
| 620 release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` | 622 minor=`echo $version | sed 's/KDE.*: [0-9]*\.\([0-9]\).*/\1/'` |
| 623 release=`echo $version | sed 's/KDE.*: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` |
| 621 test "$major" -gt 3 && return $1 | 624 test "$major" -gt 3 && return $1 |
| 622 test "$minor" -gt 5 && return $1 | 625 test "$minor" -gt 5 && return $1 |
| 623 test "$release" -gt 4 && return $1 | 626 test "$release" -gt 4 && return $1 |
| 624 return 0 | 627 return 0 |
| 625 } | 628 } |
| 626 | 629 |
| 627 update_desktop_database() | 630 update_desktop_database() |
| 628 { | 631 { |
| 629 # echo Update desktop database: $mode | 632 # echo Update desktop database: $mode |
| 630 if [ "$mode" = "system" ] ; then | 633 if [ "$mode" = "system" ] ; then |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 | 1218 |
| 1216 ;; | 1219 ;; |
| 1217 esac | 1220 esac |
| 1218 done | 1221 done |
| 1219 | 1222 |
| 1220 if [ x"$update" = x"yes" ] ; then | 1223 if [ x"$update" = x"yes" ] ; then |
| 1221 update_desktop_database | 1224 update_desktop_database |
| 1222 fi | 1225 fi |
| 1223 | 1226 |
| 1224 exit_success | 1227 exit_success |
| OLD | NEW |