comfortable-swipe/install

34 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
DIR=$(dirname $0)
if [ -x "$(command -v git)" ]; then
# stop any running comfortable-swipe if it exists
comfortable-swipe 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 $HOME/.local/bin/comfortable-swipe || exec echo "Installation aborted"
echo "Successfully installed. You may now run 'comfortable-swipe start'."