changeset 777:ca149bad8195

(issue51) Set up autostart on installation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 11 Jul 2014 18:31:09 +0200
parents 87387c5786ec
children 3145399aa797
files packaging/linux-installer.inc.in
diffstat 1 files changed, 47 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Fri Jul 11 18:30:36 2014 +0200
+++ b/packaging/linux-installer.inc.in	Fri Jul 11 18:31:09 2014 +0200
@@ -265,6 +265,15 @@
   echo "Removing configuration files:"
   rm_files "${tbcfg_files[@]}"
   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
 }
 
 deinstall()
@@ -288,6 +297,41 @@
   fi
 }
 
+write_autostart()
+{
+  cat > "$1" << EOF
+[Desktop Entry]
+Type=Application
+Name=TrustBridge
+Exec="${instcfg[PREFIX]}/bin/trustbridge" --tray
+EOF
+  chown "${SUDO_USER:-${USER}}" "$1"
+  chmod 700 "$1"
+}
+
+setup_autostart()
+{
+  # Supported desktop environments: Unity, GNOME, XFCE, LXDE, KDE
+
+  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
+}
 
 #======================================================================
 # main()
@@ -358,6 +402,9 @@
 echo "Setting up cronjob ..."
 setup_cronjob
 
+echo "Setting up autostart ..."
+setup_autostart
+
 echo "Writing installation configuration to: $instcfg_file ..."
 write_instcfg
 exit 0

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