-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README and increment version * Add comfortable-swipe version badge * Have macro guard warning for version * Improve README and install script * Expound bug reports statement
- Loading branch information
Showing
7 changed files
with
115 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v1.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
#!/bin/sh | ||
g++ $(dirname $0)/comfortable-swipe.cpp -std=c++11 -O2 -lxdo -Wno-unused-result -o $1 | ||
dir="$(dirname $0)" | ||
g++ "$dir/comfortable-swipe.cpp" \ | ||
-o "$1" \ | ||
-std=c++11 \ | ||
-O2 -lxdo -Wno-unused-result \ | ||
-DCOMFORTABLE_SWIPE_VERSION="\"$(cat $dir/VERSION | tr -d '[:space:]')\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,93 @@ | ||
#!/bin/bash | ||
# prefer running as root | ||
DIR=$(dirname $0) | ||
PROGRAM=/usr/local/bin/comfortable-swipe | ||
COMPILE=$DIR/comfortable-swipe.compile.sh | ||
CONF_PATH=/usr/local/share/comfortable-swipe/comfortable-swipe.conf | ||
DCONF_PATH=$DIR/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 | ||
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/$program.compile.sh" | ||
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" | ||
|
||
#copy config file | ||
abort () { | ||
exec echo "Installation aborted" | ||
} | ||
sudo mkdir -p $(dirname $CONF_PATH) || abort | ||
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 | ||
# 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 | ||
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 | ||
# 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 | ||
# 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 | ||
fi | ||
|
||
echo "Installing..." | ||
echo "Installing to $program_exe ..." | ||
|
||
# remove existing comfortable-swipe | ||
if [ -x "$(command -v $PROGRAM)" ]; then | ||
sudo rm -f $(which comfortable-swipe) | ||
fi | ||
# remove existing $program | ||
if [ -x "$(command -v $program_exe)" ]; then | ||
sudo rm -f "$(which $program)" | ||
fi | ||
|
||
# compile library | ||
sudo "$compile_command" "$program_exe" || abort | ||
|
||
# compile library | ||
sudo $COMPILE $PROGRAM || abort | ||
# add permissions to input group (defer) | ||
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || 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 | ||
|
||
# toggle autostart twice to refresh any changes | ||
$PROGRAM autostart > /dev/null || abort | ||
$PROGRAM autostart > /dev/null || abort | ||
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" | ||
} | ||
|
||
echo "Successfully installed comfortable-swipe." | ||
echo "Configuration file is located at $CONF_PATH" | ||
echo "" | ||
echo "Try running 'comfortable-swipe start' to test." | ||
install | ||
unset -f install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters