* Modularly separate keyboard swipe gesture from generic swipe * Set destructors virtual to avoid surprises * Prepare mouse swipe gesture skeleton * Modify mouse move update * Use xdo_move_mouse_relative instead of screen capture * Restructure and add compiler tests * Fix bash install script * Add experimental: mouse hold on defaults.conf * Update README and defaults.conf * Do mousedown only for buttons 1 to 3 * Fix stop script and mouse gesture on button 4/5 * Redirect restart command to null * Redirect using freopen * Add comments on experimental scrolling
97 lines
2.9 KiB
Bash
Executable File
97 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
function install {
|
|
# prefer running as root
|
|
local dir="$(dirname "$0")"
|
|
local program=comfortable-swipe
|
|
local program_exe=/usr/local/bin/$program
|
|
local compile_command="$dir/cpp.compile.sh"
|
|
local compile_target="$dir/command_line.cpp"
|
|
local conf_path=/usr/local/share/$program/$program.conf
|
|
local dconf_path="$dir/defaults.conf"
|
|
local old_conf_path="${XDG_CONFIG_HOME:-$HOME/.config}/$program.conf"
|
|
|
|
if [ -x "$(command -v $program_exe)" ]; then
|
|
# stop any running $program if it exists
|
|
$program_exe stop
|
|
fi
|
|
|
|
#copy config file
|
|
abort () {
|
|
exec echo "Installation aborted"
|
|
}
|
|
sudo mkdir -p "$(dirname $conf_path)" || abort
|
|
|
|
# check if "-y" or "--yes" is passed as an argument
|
|
YES=false
|
|
while test $# -gt 0
|
|
do
|
|
case "$1" in
|
|
-y) YES=true
|
|
;;
|
|
--yes) YES=true
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
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"
|
|
if [ "$YES" == false ]; then
|
|
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
|
|
fi
|
|
|
|
echo "Installing to $program_exe ..."
|
|
|
|
# remove existing $program
|
|
if [ -x "$(command -v $program_exe)" ]; then
|
|
sudo rm -f "$(which $program)"
|
|
fi
|
|
|
|
# compile library
|
|
sudo "$compile_command" "$compile_target" -o "$program_exe" || abort
|
|
|
|
# add permissions to input group (defer)
|
|
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort
|
|
|
|
# turn on autostart by default
|
|
local autostart_status="$($program_exe autostart)"
|
|
if [[ "$autostart_status" == *off* ]]; then
|
|
autostart_status="$($program_exe autostart)"
|
|
fi
|
|
|
|
echo "Successfully installed $program $(cat $dir/VERSION | tr -d '[:space:]')"
|
|
echo ""
|
|
echo "$autostart_status"
|
|
echo "Edit configuration file: gedit \$($program config)"
|
|
echo ""
|
|
echo "Try running: $program start"
|
|
}
|
|
|
|
install
|
|
unset -f install
|