comfortable-swipe/install
Rico Tiongson b491d8179b [bugfix-kde-startup] Defer to bash when executing autostart script
PATH is not reliable especially for .zshrc when running autostart script. Prefer executing autostart from bash by default instead. Fixes autostart bug is present in KDE neon v5.11 (plasma v5.11.2).
2017-11-07 00:44:47 +08:00

40 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
DIR=$(dirname $0)
PROGRAM=$HOME/.local/bin/comfortable-swipe
if [ -x "$(command -v git)" ]; then
# stop any running comfortable-swipe if it exists
$PROGRAM stop
fi
#copy config file
mkdir -p ~/.config
DCONF_PATH=$DIR/src/defaults.conf
CONF_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/comfortable-swipe.conf
if [ ! -f $CONF_PATH ]; then
cat $DCONF_PATH > $CONF_PATH
else
# config file found, ask user if overwrite
echo "Old conf file found in $CONF_PATH"
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response
response=${response,,} # tolower
if [[ "$response" =~ ^(no|n)$ ]]; then
read -r -p "Conf file will be overwritten. Are you sure? [Y/n] " response
response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]]; then
cat $DCONF_PATH > $CONF_PATH
else
exec echo "Installation aborted."
fi
fi
fi
echo "Installing..."
mkdir -p ~/.local/bin
g++ -std=c++11 -O2 $DIR/src/comfortable-swipe.cpp -lxdo -o $PROGRAM || exec echo "Installation aborted"
# toggle autostart twice to refresh any changes
$PROGRAM autostart > /dev/null || exec echo "Installation aborted"
$PROGRAM autostart > /dev/null || exec echo "Installation aborted"
echo "Successfully installed. You may now run 'comfortable-swipe start'."