# HG changeset patch # User Andre Heinecke # Date 1405096269 -7200 # Node ID ca149bad819588f75e667b407fbbf2415935dffe # Parent 87387c5786ec10dc5f283ab097d718ee4d171b0a (issue51) Set up autostart on installation. diff -r 87387c5786ec -r ca149bad8195 packaging/linux-installer.inc.in --- 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