linux-fat: Fix up fat linux install icons, mime types and .desktop files
authorKeith Packard <keithp@keithp.com>
Tue, 15 Jul 2014 07:44:14 +0000 (00:44 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 15 Jul 2014 07:44:14 +0000 (00:44 -0700)
use the standard xdg utilities to install mime type and .desktop
files. The standard xdg icon installer doesn't handle svg icons, so we
have to do those manually.

With this patch, xfce, gnome3 and kde4 all place the applications in
user-visible menus, display correct file icons and launch correct
applications for our file types.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/Makefile.am
altosui/linux-install.sh
micropeak/Makefile.am
telegps/Makefile.am

index c79e27c..44258fd 100644 (file)
@@ -104,6 +104,14 @@ MACOSX_ICONS       =\
        $(ICONDIR)/application-vnd.altusmetrum.eeprom.icns \
        $(ICONDIR)/application-vnd.altusmetrum.telemetry.icns
 
+LINUX_ICONS    =\
+       $(ICONDIR)/altusmetrum-altosui.svg \
+       $(ICONDIR)/application-vnd.altusmetrum.eeprom.svg \
+       $(ICONDIR)/application-vnd.altusmetrum.telemetry.svg
+
+LINUX_MIMETYPE =\
+       $(ICONDIR)/org-altusmetrum-mimetypes.xml
+
 # Firmware
 FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx
 FIRMWARE_TD=$(FIRMWARE_TD_0_2)
@@ -152,7 +160,7 @@ FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFR
 
 LINUX_LIBS=libaltos32.so libaltos64.so
 
-LINUX_FILES=$(FAT_FILES) $(LINUX_LIBS) $(FIRMWARE) $(DOC) $(desktop_file).in $(ICONDIR)/altusmetrum-altosui.svg
+LINUX_FILES=$(FAT_FILES) $(LINUX_LIBS) $(FIRMWARE) $(DOC) $(desktop_file).in $(LINUX_ICONS) $(LINUX_MIMETYPE)
 LINUX_EXTRA=altosui-fat
 
 MACOSX_INFO_PLIST=Info.plist
index 957b1aa..2e44c2a 100644 (file)
@@ -130,6 +130,7 @@ esac
 #
 # Create the .desktop file by editing the paths
 #
+
 case "$target" in
 /*)
     target_abs="$target"
@@ -149,43 +150,46 @@ for infile in "$target"/AltOS/*.desktop.in; do
 done
 
 #
-# Figure out where to install the .desktop files. If we can, write it
-# to the public /usr/share/applications, otherwise, write it to the
-# per-user ~/.local/share/applications
+# Install the .desktop file
 #
 
-public=/usr/share/applications
-private=$HOME/.local/share/applications
-apps=""
+for desktop in "$target"/AltOS/*.desktop; do
+    case `id -u` in
+       0)
+           xdg-desktop-menu install --mode system "$desktop"
+           ;;
+       *)
+           xdg-desktop-menu install --mode user "$desktop"
+           ;;
+    esac
+done
 
-if [ -d "$public" -a -w "$public" ]; then
-    apps="$public"
-else
-    mkdir -p "$private" >/dev/null 2>&1 
-    if [ -d "$private" -a -w "$private" ]; then
-       apps="$private"
-    fi
-fi
-       
-case "$apps" in
-"")
-    echo "Cannot install application icon"
-    finish 1
-    ;;
-esac
+#
+# Install mime type file
+#
+
+for mimetype in "$target"/AltOS/*-mimetypes.xml; do
+    case `id -u` in
+       0)
+           xdg-mime install --mode system "$mimetype"
+           ;;
+       *)
+           xdg-mime install --mode user "$mimetype"
+           ;;
+    esac
+done
 
-echo -n "Installing .desktop files to $apps..."
+#
+# Install icons
+#
 
-cp "$target"/AltOS/*.desktop "$apps"
+for icon_dir in /usr/share/icons/hicolor/scalable/mimetypes "$HOME/.icons" "$HOME/.kde/share/icons"; do
+    if [ -w "$icon_dir" ]; then
+       cp "$target"/AltOS/*.svg "$icon_dir"
+       update-icon-caches "$icon_dir"
+    fi
+done
 
-case "$?" in
-0)
-    echo " done."
-    ;;
-*)
-    echo " failed."
-    ;;
-esac
 
 #
 # Install icon to desktop if desired
@@ -222,13 +226,14 @@ if [ -d $HOME/Desktop ]; then
        esac
     done
 
-    echo -n "Installing desktop icons..."
     case "$do_desktop" in
-    [yY]*)
-       for d in "$target"/AltOS/*.desktop; do
-           ln -f -s "$d" "$HOME/Desktop/"
-       done
-       ;;
+       [yY]*)
+           echo -n "Installing desktop icons..."
+           for d in "$target"/AltOS/*.desktop; do
+               base=`basename $d`
+               cp --remove-destination "$d" "$HOME/Desktop/"
+           done
+           ;;
     esac
 
     echo " done."
index e3b77c8..1586560 100644 (file)
@@ -82,6 +82,13 @@ MACOSX_ICONS =\
        ../icon/altusmetrum-micropeak.icns \
        ../icon/application-vnd.altusmetrum.micropeak.icns
 
+LINUX_ICONS    =\
+       $(ICONDIR)/altusmetrum-micropeak.svg \
+       $(ICONDIR)/application-vnd.altusmetrum.micropeak.svg
+
+LINUX_MIMETYPE =\
+       $(ICONDIR)/org-altusmetrum-mimetypes.xml
+
 desktopdir = $(datadir)/applications
 desktop_file = altusmetrum-micropeak.desktop
 desktop_SCRIPTS = $(desktop_file)
@@ -114,7 +121,7 @@ DOC=$(MICROPEAK_DOC)
 
 FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS)
 
-LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in ../icon/altusmetrum-micropeak.svg
+LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in $(LINUX_ICONS) $(LINUX_MIMETYPE)
 LINUX_EXTRA=micropeak-fat $(desktop_file).in
 
 MACOSX_DRIVER_URL=http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_2_18.dmg
index 6138b00..3b33428 100644 (file)
@@ -87,6 +87,14 @@ MACOSX_ICONS =\
        ../icon/application-vnd.altusmetrum.eeprom.icns \
        ../icon/application-vnd.altusmetrum.telemetry.icns
 
+LINUX_ICONS    =\
+       $(ICONDIR)/altusmetrum-altosui.svg \
+       $(ICONDIR)/application-vnd.altusmetrum.eeprom.svg \
+       $(ICONDIR)/application-vnd.altusmetrum.telemetry.svg
+
+LINUX_MIMETYPE =\
+       $(ICONDIR)/org-altusmetrum-mimetypes.xml
+
 # Firmware
 FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx
 FIRMWARE_TD=$(FIRMWARE_TD_0_2)
@@ -131,7 +139,7 @@ DOC=$(TELEGPS_DOC)
 
 FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS)
 
-LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in ../icon/altusmetrum-telegps.svg
+LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in $(LINUX_ICONS) $(LINUX_MIMETYPE)
 LINUX_EXTRA=telegps-fat $(desktop_file).in
 
 MACOSX_INFO_PLIST=Info.plist