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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; | 607 fi |
608 else DE="" | 608 |
| 609 if [ x"$DE" = x"" ]; then |
| 610 # fallback to checking $DESKTOP_SESSION |
| 611 case "$DESKTOP_SESSION" in |
| 612 LXDE) |
| 613 DE=lxde; |
| 614 ;; |
| 615 xfce|xfce4) |
| 616 DE=xfce; |
| 617 ;; |
| 618 esac |
| 619 fi |
| 620 |
| 621 if [ x"$DE" = x"" ]; then |
| 622 # fallback to uname output for other platforms |
| 623 case "$(uname 2>/dev/null)" in |
| 624 Darwin) |
| 625 DE=darwin; |
| 626 ;; |
| 627 esac |
| 628 fi |
| 629 |
| 630 if [ x"$DE" = x"gnome" ]; then |
| 631 # gnome-default-applications-properties is only available in GNOME 2.x |
| 632 # but not in GNOME 3.x |
| 633 which gnome-default-applications-properties 2> /dev/null || DE="gnome3" |
609 fi | 634 fi |
610 } | 635 } |
611 | 636 |
612 #---------------------------------------------------------------------------- | 637 #---------------------------------------------------------------------------- |
613 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 | 638 # kfmclient exec/openURL can give bogus exit value in KDE <= 3.5.4 |
614 # It also always returns 1 in KDE 3.4 and earlier | 639 # It also always returns 1 in KDE 3.4 and earlier |
615 # Simply return 0 in such case | 640 # Simply return 0 in such case |
616 | 641 |
617 kfmclient_fix_exit_code() | 642 kfmclient_fix_exit_code() |
618 { | 643 { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 DEBUG 2 "Found default apps for $MIME: $default_app" | 705 DEBUG 2 "Found default apps for $MIME: $default_app" |
681 default_app="$default_app;" | 706 default_app="$default_app;" |
682 break; | 707 break; |
683 fi | 708 fi |
684 done | 709 done |
685 DEBUG 2 "Current default apps for $MIME: $default_app" | 710 DEBUG 2 "Current default apps for $MIME: $default_app" |
686 if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then | 711 if echo "$default_app" | grep "$2" > /dev/null 2> /dev/null; then |
687 # App already listed as default | 712 # App already listed as default |
688 continue; | 713 continue; |
689 fi | 714 fi |
690 default_file="$1/defaults.list" | 715 default_file="$(readlink -f "$1/defaults.list")" |
691 DEBUG 1 "Updating $default_file" | 716 DEBUG 1 "Updating $default_file" |
692 grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null | 717 grep -v "$MIME=" $default_file > ${default_file}.new 2> /dev/null |
693 if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then | 718 if ! grep "[Default Applications]" ${default_file}.new > /dev/null; then |
694 echo "[Default Applications]" >> ${default_file}.new | 719 echo "[Default Applications]" >> ${default_file}.new |
695 fi | 720 fi |
696 echo $MIME="$default_app$2" >> ${default_file}.new | 721 echo $MIME="$default_app$2" >> ${default_file}.new |
697 mv ${default_file}.new $default_file | 722 mv ${default_file}.new $default_file |
698 done | 723 done |
699 } | 724 } |
700 | 725 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 | 1243 |
1219 ;; | 1244 ;; |
1220 esac | 1245 esac |
1221 done | 1246 done |
1222 | 1247 |
1223 if [ x"$update" = x"yes" ] ; then | 1248 if [ x"$update" = x"yes" ] ; then |
1224 update_desktop_database | 1249 update_desktop_database |
1225 fi | 1250 fi |
1226 | 1251 |
1227 exit_success | 1252 exit_success |
OLD | NEW |