doc: Use icons for admonitions
[fw/altos] / altosui / linux-install.sh
index c5101eb4136e1bb35fc10fc670c47db90c40bc94..2e44c2aacf1b26f83afe2850400a3140d34bdf0e 100644 (file)
@@ -130,6 +130,7 @@ esac
 #
 # Create the .desktop file by editing the paths
 #
+
 case "$target" in
 /*)
     target_abs="$target"
@@ -141,49 +142,102 @@ esac
 
 BIN="$target_abs"/AltOS
 
-desktop="$target"/AltOS/altos.desktop
+for infile in "$target"/AltOS/*.desktop.in; do
+    desktop="$target"/AltOS/`basename "$infile" .in`
+    rm -f "$desktop"
+    sed -e "s;%bindir%;$BIN;" -e "s;%icondir%;$BIN;" "$infile" > "$desktop"
+    chmod +x "$desktop"
+done
 
-rm -f "$desktop"
-sed "s;%BIN%;$BIN;" "$target"/AltOS/altos.desktop.in > "$desktop"
+#
+# Install the .desktop file
+#
+
+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
 
 #
-# Figure out where to install the .desktop file. If we can, write it
-# to the public /usr/share/applications, otherwise, write it to the
-# per-user ~/.local/share/applications
+# Install mime type file
 #
 
-public=/usr/share/applications
-private=$HOME/.local/share/applications
-apps=""
+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
 
-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"
+#
+# Install icons
+#
+
+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
-fi
-       
-case "$apps" in
-"")
-    echo "Cannot install application icon"
-    finish 1
-    ;;
-esac
+done
 
-echo -n "Installing .desktop file to $apps..."
 
-cp "$desktop" "$apps"
+#
+# Install icon to desktop if desired
+#
+
+if [ -d $HOME/Desktop ]; then
+    default_desktop=n
+    if [ "$can_ask" = "y" ]; then
+       :
+    else
+       default_desktop=y
+    fi
+
+    answered=n
+    while [ "$answered" = "n" ]; do
+       echo -n "Install icons to desktop? [default: $default_desktop] "
+       if [ "$can_ask" = "y" ]; then
+           read do_desktop
+       else
+           echo
+           do_desktop=""
+       fi
+
+       case "$do_desktop" in
+           "")
+           do_desktop=$default_desktop
+           ;;
+       esac
+
+       case "$do_desktop" in
+       [yYnN]*)
+           answered=y
+           ;;
+       esac
+    done
+
+    case "$do_desktop" in
+       [yY]*)
+           echo -n "Installing desktop icons..."
+           for d in "$target"/AltOS/*.desktop; do
+               base=`basename $d`
+               cp --remove-destination "$d" "$HOME/Desktop/"
+           done
+           ;;
+    esac
 
-case "$?" in
-0)
     echo " done."
-    ;;
-*)
-    echo " failed."
-    ;;
-esac
+fi
 
 finish 0