From 48529936636553eb49c3cff31f38acd3b7652610 Mon Sep 17 00:00:00 2001 From: Rico Tiongson Date: Fri, 15 Mar 2019 10:40:54 +0800 Subject: [PATCH] Update readme and version (#64) * 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 --- README.md | 23 +++++- VERSION | 1 + comfortable-swipe.compile.sh | 7 +- install | 145 +++++++++++++++++++---------------- lib/index.hpp | 5 ++ lib/service/help.cpp | 2 +- lib/service/status.cpp | 12 ++- 7 files changed, 115 insertions(+), 80 deletions(-) create mode 100644 VERSION diff --git a/README.md b/README.md index 57d13fa..1a03409 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Comfortable Swipe (Ubuntu) +[![comfortable-swipe version](https://img.shields.io/github/release/Hikari9/comfortable-swipe.svg?label=comfortable-swipe&color=orange)](https://github.com/Hikari9/comfortable-swipe/releases) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures for Ubuntu 14.04 LTS and beyond. May work for other Linux distros that support `libinput`. @@ -15,7 +16,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures ```bash git clone https://github.com/Hikari9/comfortable-swipe.git --depth 1 - cd comfortable-swipe-ubuntu + cd comfortable-swipe ``` 3. Install @@ -24,7 +25,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures bash install ``` -4. You may delete the downloaded `comfortable-swipe-ubuntu` folder after installation. +4. You may delete the downloaded `comfortable-swipe` folder after installation. ## How to Run @@ -49,7 +50,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures ## Configurations Comfortable swipe makes use of keyboard shortcuts for configurations. Edit by running ``` -nano $(comfortable-swipe config) +gedit $(comfortable-swipe config) ``` Make sure to run after making changes: @@ -126,4 +127,18 @@ Download the `uninstall` script then run `bash uninstall` ## Bug Reports -Create an issue [here](https://github.com/Hikari9/comfortable-swipe-ubuntu/issues/new) to report a bug. +Search in [Issues](https://github.com/Hikari9/comfortable-swipe/issues?utf8=%E2%9C%93&q=is%3Aissue) if the problem has already been solved. + +Otherwise, [create a new issue](https://github.com/Hikari9/comfortable-swipe/issues/new) to report your bug. + +Please include the output of the following: + +1. `lsb_release -a` +2. `g++ --version` +3. `ls -l /dev/input/event*` +3. `xinput list | grep touchpad -i` +4. `lsmod | grep hid` +5. `comfortable-swipe status` +6. `comfortable-swipe start` (if you can run it) +7. `comfortable-swipe debug` (try swiping if you can see `GESTURE_SWIPE_XXX`) +8. `cat $(comfortable-swipe config)` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..79ff5a5 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v1.0.3 diff --git a/comfortable-swipe.compile.sh b/comfortable-swipe.compile.sh index d839b64..2425f6d 100755 --- a/comfortable-swipe.compile.sh +++ b/comfortable-swipe.compile.sh @@ -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:]')\"" diff --git a/install b/install index 9de80c6..1bbc844 100755 --- a/install +++ b/install @@ -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 diff --git a/lib/index.hpp b/lib/index.hpp index b54cc3e..3ce48a6 100644 --- a/lib/index.hpp +++ b/lib/index.hpp @@ -28,6 +28,11 @@ along with this program. If not, see . #define __COMFORTABLE_SWIPE__CONFIG__ "/usr/local/share/comfortable-swipe/comfortable-swipe.conf" #endif /* __COMFORTABLE_SWIPE__CONFIG__ */ +#ifndef COMFORTABLE_SWIPE_VERSION +#warning COMFORTABLE_SWIPE_VERSION is not defined +#define COMFORTABLE_SWIPE_VERSION "v(UNKNOWN)" +#endif /* COMFORTABLE_SWIPE_VERSION */ + #include // std::map #include // std::string diff --git a/lib/service/help.cpp b/lib/service/help.cpp index 80c2c85..9654132 100644 --- a/lib/service/help.cpp +++ b/lib/service/help.cpp @@ -30,7 +30,7 @@ namespace comfortable_swipe::service void help() { using comfortable_swipe::util::conf_filename; - std::puts("comfortable-swipe [start|stop|restart|autostart|buffer|help|config|debug|status]"); + std::puts("comfortable-swipe " COMFORTABLE_SWIPE_VERSION " [start|stop|restart|autostart|buffer|help|config|debug|status]"); std::puts(""); std::puts("start - starts 3/4-finger gesture service"); std::puts("stop - stops 3/4-finger gesture service"); diff --git a/lib/service/status.cpp b/lib/service/status.cpp index a084de4..b20cfd3 100644 --- a/lib/service/status.cpp +++ b/lib/service/status.cpp @@ -50,19 +50,13 @@ namespace comfortable_swipe::service auto autostart_f = comfortable_swipe::util::autostart_filename(); bool autostart_on = access(autostart_f, F_OK) != -1; - // print status - std::printf("program is %s\n", running ? "ON" : "OFF"); - std::printf("autostart is %s\n", autostart_on ? "ON" : "OFF"); - std::printf("config file at %s\n", comfortable_swipe::util::conf_filename()); + std::puts(comfortable_swipe::util::conf_filename()); // check status of configuration file try { auto config = comfortable_swipe::util::read_config_file(comfortable_swipe::util::conf_filename()); - // print keys and values of config file - std::printf("\nConfigurations:\n"); - // print threshold if (config.count("threshold") > 0) { @@ -91,6 +85,10 @@ namespace comfortable_swipe::service { std::printf("config error: %s\n", e.what()); } + + // print status + std::printf("autostart is %s\n", autostart_on ? "ON" : "OFF"); + std::printf("comfortable-swipe program is %s\n", running ? "RUNNING" : "STOPPED"); } }