diff packaging/linux-installer.inc.in @ 785:2fb539d4b1ff

Simply autostart creation by initializing the path in init_vars
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 14 Jul 2014 13:21:17 +0200
parents ca149bad8195
children 3a9b0c75f5a6
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Mon Jul 14 13:20:55 2014 +0200
+++ b/packaging/linux-installer.inc.in	Mon Jul 14 13:21:17 2014 +0200
@@ -139,10 +139,12 @@
       inst_default_prefix="$SYSDEFAULT_PREFIX"
       instcfg_path="${SYSCFGPATH}"
       instdata_path="${SYSDATAPATH}"
+      autostart_path="$(getent passwd "${SUDO_USER}" | cut -d ':' -f 6)/.config/autostart"
   else
     inst_default_prefix="$DEFAULT_PREFIX"
     instcfg_path="${CFGPATH}"
     instdata_path="${DATAPATH}"
+    autostart_path=${XDG_CONFIG_HOME:-~/.config/autostart}
   fi
     instcfg_file="${instcfg_path}/${INSTCFGNAME}"
 }
@@ -267,13 +269,7 @@
   rm_empty_dirs "$instcfg_path"
 
   echo "Removing TrustBridge from autostart"
-  if [ "${SUDO_USER+X}" ] ; then
-    homedir=$(getent passwd "${SUDO_USER}" | cut -d ':' -f 6)
-    rm_files "${homedir}/.config/autostart/tustbridge.desktop"
-  else
-    config_home=${XDG_CONFIG_HOME:-~/.config}
-    rm_files "${config_home}/autostart/tustbridge.desktop"
-  fi
+  rm_files "${autostart_path}/tustbridge.desktop"
 }
 
 deinstall()
@@ -312,25 +308,14 @@
 setup_autostart()
 {
   # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE
+  # System wide installation with a nonstandard XDG_CONFIG_HOME or KDEHOME is not
+  # respected with regards to autostart.
+  if [ ! -d "${autostart_path}" ]; then
+    install -d "${autostart_path}" || \
+      fatal "Failed to create autostart directory: '${autostart_path}'"
+  fi
 
-  if [ $SYSINST -eq 1 -a "${SUDO_USER+X}" ] ; then
-    homedir=$(getent passwd "${SUDO_USER}" | cut -d ':' -f 6)
-    install -d "${instcfg[PREFIX]}" || fatal "Could not create '${instcfg[PREFIX]}'!"
-    if [ ! -d "${homedir}/.config/autostart/" ]; then
-      install -d "${homedir}/.config/autostart/" || \
-        fatal "Failed to create autostart directory: '${homedir}/.config/autostart/'"
-    fi
-    write_autostart "${homedir}/.config/autostart/tustbridge.desktop"
-    # System wide installation with a nonstandard XDG_CONFIG_HOME or KDEHOME is not
-    # respected with regards to autostart.
-  else
-    config_home=${XDG_CONFIG_HOME:-~/.config}
-    if [ ! -d "${config_home}/autostart" ]; then
-      install -d "${config_home}/autostart" || \
-        fatal "Failed to create autostart directory: '${config_home}/autostart'"
-    fi
-    write_autostart "${config_home}/autostart/tustbridge.desktop"
-  fi
+  write_autostart "${autostart_path}/tustbridge.desktop"
 }
 
 #======================================================================

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