* Remove unused device and stamp from swipe_impl
* Use constants for regex patterns
* Compile regex outside of buffer function to avoid runtime hiccup
* Optimize reading of config file
* Revert "Optimize reading of config file"
This reverts commit 88b85d3941.
* Improve tokenizing of config file
* Make sentence string static
* Improve README; change default threshold to 20.0
* Add a flag for gesture begin to ignore unneeded update/end
* Pre-compute for square of threshold and scale to lessen computation
* Compare fingers string with only one digit
* Use fgets_unlocked for faster input stream reading
* Don't buffer error stream
* Set some variables to static
* Catch dash symbol before event, remove trimming
* Use const char* for conf_filename
* Fix error in printing help
* Add some test scripts
* Add service module
* Add gesture module
* Add util module
* Add index files
* Decouple header files
* Add licenses in headers
* Move files to lib
* Modify install script
* Update install script
66 lines
2.0 KiB
Bash
Executable File
66 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# prefer running as root
|
|
DIR=$(dirname $0)
|
|
PROGRAM=/usr/local/bin/comfortable-swipe
|
|
CONF_PATH=/usr/local/share/comfortable-swipe/comfortable-swipe.conf
|
|
DCONF_PATH=$DIR/src/defaults.conf
|
|
OLD_CONF_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/comfortable-swipe.conf
|
|
|
|
if [ -x "$(command -v $PROGRAM)" ]; then
|
|
# stop any running comfortable-swipe if it exists
|
|
$PROGRAM stop
|
|
fi
|
|
|
|
#copy config file
|
|
abort () {
|
|
exec echo "Installation aborted"
|
|
}
|
|
sudo mkdir -p $(dirname $CONF_PATH) || abort
|
|
sudo chown $USER $(dirname $CONF_PATH)
|
|
if [ ! -f $CONF_PATH ]; then
|
|
if [ ! -f $OLD_CONF_PATH ]; then
|
|
# old config file not found, create from scratch
|
|
cat $DCONF_PATH > $CONF_PATH || abort
|
|
else
|
|
# old config file found, move to the new path
|
|
cat $OLD_CONF_PATH > $CONF_PATH || abort
|
|
echo "Configuration copied from $OLD_CONF_PATH to $CONF_PATH"
|
|
fi
|
|
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 || abort
|
|
else
|
|
abort
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo "Installing..."
|
|
|
|
# remove existing comfortable-swipe
|
|
if [ -x "$(command -v $PROGRAM)" ]; then
|
|
sudo rm -f $(which comfortable-swipe)
|
|
fi
|
|
|
|
# compile library
|
|
sudo $DIR/src/compile $PROGRAM || abort
|
|
|
|
# add permissions to input group (defer)
|
|
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort
|
|
|
|
# toggle autostart twice to refresh any changes
|
|
$PROGRAM autostart > /dev/null || abort
|
|
$PROGRAM autostart > /dev/null || abort
|
|
|
|
echo "Successfully installed comfortable-swipe."
|
|
echo "Configuration file is located at $CONF_PATH"
|
|
echo ""
|
|
echo "Try running 'comfortable-swipe start' to test."
|