#!/bin/bash DIR=$(dirname $0) PROGRAM=/usr/local/bin/comfortable-swipe if [ -x "$(command -v $PROGRAM)" ]; then # stop any running comfortable-swipe if it exists $PROGRAM stop # remove existing comfortable-swipe rm $(which comfortable-swipe) 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'."