diff packaging/linux-installer.inc.in @ 872:02e357826417

(issue81) Add desktop file
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 Aug 2014 18:56:23 +0200
parents 3f23130b16b2
children 78096ad6f418
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Wed Aug 06 18:03:23 2014 +0200
+++ b/packaging/linux-installer.inc.in	Wed Aug 06 18:56:23 2014 +0200
@@ -15,6 +15,7 @@
 SYSINST=0
 DEINSTALL=0
 BINNAMES="###BINNAMES###"
+ICONNAME="###ICONNAME###"
 
 declare -A instcfg oldinstcfg
 declare inst_default_prefix instdata_path instcfg_path instcfg_file
@@ -162,11 +163,13 @@
       instcfg_path="${SYSCFGPATH}"
       instdata_path="${SYSDATAPATH}"
       autostart_path="$(getent passwd "${SUDO_USER}" | cut -d ':' -f 6)/.config/autostart"
+      startmenu_path="/usr/share/applications"
   else
     inst_default_prefix="$DEFAULT_PREFIX"
     instcfg_path="${CFGPATH}"
     instdata_path="${DATAPATH}"
     autostart_path=${XDG_CONFIG_HOME:-~/.config/autostart}
+    startmenu_path=${XDG_DATA_HOME:-~/.local/share/applications}
   fi
     instcfg_file="${instcfg_path}/${INSTCFGNAME}"
 }
@@ -295,6 +298,9 @@
 
   getxt "Removing TrustBridge from autostart\n"
   rm_files "${autostart_path}/trustbridge.desktop"
+
+  getxt "Removing TrustBridge from start menu\n"
+  rm_files "${startmenu_path}/trustbridge.desktop"
 }
 
 deinstall()
@@ -311,6 +317,19 @@
         rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
       done
       rm_empty_dirs "$deinstdir"
+      deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps/trustbridge"
+      getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}"
+      for file in $ICONNAME; do
+        local path="${deinstdir}/$file"
+        getxt "Deleting '%s' ...\n" "$path"
+        rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path"
+      done
+      deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps/trustbridge"
+      rm_empty_dirs "$deinstdir"
+      deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps"
+      rm_empty_dirs "$deinstdir"
+      deinstdir="${oldinstcfg[PREFIX]}/share"
+      rm_empty_dirs "$deinstdir"
       deinstall_etc
       getxt "Deinstallation finished.\n"
   else
@@ -330,6 +349,36 @@
   chmod 700 "$1"
 }
 
+write_startmenu()
+{
+  cat > "$1" << EOF
+[Desktop Entry]
+Type=Application
+Name=TrustBridge
+Comment=Install and update trusted root certificates
+Comment[de]=Vertrauenswürdige Wurzelzertifikate installieren und aktualisieren
+Exec=${instcfg[PREFIX]}/bin/trustbridge
+Icon=${instcfg[PREFIX]}/share/pixmaps/trustbridge/trustbridge.png
+Terminal=false
+Categories=Network;Qt;
+StartupNotify=false
+EOF
+}
+
+setup_startmenu()
+{
+  # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE
+  # System wide installation with a nonstandard XDG_DATA_HOME is not
+  # respected with regards to autostart.
+  if [ ! -d "${startmenu_path}" ]; then
+    install -d "${startmenu_path}" || \
+      fatal "Failed to create startmenu directory: '%s'\n" "$startmenu_path"
+  fi
+
+  write_startmenu "${startmenu_path}/trustbridge.desktop"
+  update-desktop-database 2>&1 || true
+}
+
 setup_autostart()
 {
   # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE
@@ -415,6 +464,9 @@
 getxt "Setting up autostart ...\n"
 setup_autostart
 
+getxt "Setting up start menu entries ...\n"
+setup_startmenu
+
 getxt "Writing installation configuration to: %s ...\n" "$instcfg_file"
 write_instcfg
 exit 0

http://wald.intevation.org/projects/trustbridge/