Skip to content

Commit 4852993

Browse files
authored
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
1 parent 810a20f commit 4852993

File tree

7 files changed

+115
-80
lines changed

7 files changed

+115
-80
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Comfortable Swipe (Ubuntu)
2+
[![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)
23
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
34

45
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
1516

1617
```bash
1718
git clone https://github.com/Hikari9/comfortable-swipe.git --depth 1
18-
cd comfortable-swipe-ubuntu
19+
cd comfortable-swipe
1920
```
2021

2122
3. Install
@@ -24,7 +25,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
2425
bash install
2526
```
2627

27-
4. You may delete the downloaded `comfortable-swipe-ubuntu` folder after installation.
28+
4. You may delete the downloaded `comfortable-swipe` folder after installation.
2829

2930
## How to Run
3031

@@ -49,7 +50,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
4950
## Configurations
5051
Comfortable swipe makes use of keyboard shortcuts for configurations. Edit by running
5152
```
52-
nano $(comfortable-swipe config)
53+
gedit $(comfortable-swipe config)
5354
```
5455
5556
Make sure to run after making changes:
@@ -126,4 +127,18 @@ Download the `uninstall` script then run `bash uninstall`
126127

127128

128129
## Bug Reports
129-
Create an issue [here](https://github.com/Hikari9/comfortable-swipe-ubuntu/issues/new) to report a bug.
130+
Search in [Issues](https://github.com/Hikari9/comfortable-swipe/issues?utf8=%E2%9C%93&q=is%3Aissue) if the problem has already been solved.
131+
132+
Otherwise, [create a new issue](https://github.com/Hikari9/comfortable-swipe/issues/new) to report your bug.
133+
134+
Please include the output of the following:
135+
136+
1. `lsb_release -a`
137+
2. `g++ --version`
138+
3. `ls -l /dev/input/event*`
139+
3. `xinput list | grep touchpad -i`
140+
4. `lsmod | grep hid`
141+
5. `comfortable-swipe status`
142+
6. `comfortable-swipe start` (if you can run it)
143+
7. `comfortable-swipe debug` (try swiping if you can see `GESTURE_SWIPE_XXX`)
144+
8. `cat $(comfortable-swipe config)`

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.0.3

comfortable-swipe.compile.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
#!/bin/sh
2-
g++ $(dirname $0)/comfortable-swipe.cpp -std=c++11 -O2 -lxdo -Wno-unused-result -o $1
2+
dir="$(dirname $0)"
3+
g++ "$dir/comfortable-swipe.cpp" \
4+
-o "$1" \
5+
-std=c++11 \
6+
-O2 -lxdo -Wno-unused-result \
7+
-DCOMFORTABLE_SWIPE_VERSION="\"$(cat $dir/VERSION | tr -d '[:space:]')\""

install

Lines changed: 78 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,93 @@
11
#!/bin/bash
2-
# prefer running as root
3-
DIR=$(dirname $0)
4-
PROGRAM=/usr/local/bin/comfortable-swipe
5-
COMPILE=$DIR/comfortable-swipe.compile.sh
6-
CONF_PATH=/usr/local/share/comfortable-swipe/comfortable-swipe.conf
7-
DCONF_PATH=$DIR/defaults.conf
8-
OLD_CONF_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/comfortable-swipe.conf
92

10-
if [ -x "$(command -v $PROGRAM)" ]; then
11-
# stop any running comfortable-swipe if it exists
12-
$PROGRAM stop
13-
fi
3+
function install {
4+
# prefer running as root
5+
local dir="$(dirname $0)"
6+
local program=comfortable-swipe
7+
local program_exe=/usr/local/bin/$program
8+
local compile_command="$dir/$program.compile.sh"
9+
local conf_path=/usr/local/share/$program/$program.conf
10+
local dconf_path="$dir/defaults.conf"
11+
local old_conf_path="${XDG_CONFIG_HOME:-$HOME/.config}/$program.conf"
1412

15-
#copy config file
16-
abort () {
17-
exec echo "Installation aborted"
18-
}
19-
sudo mkdir -p $(dirname $CONF_PATH) || abort
13+
if [ -x "$(command -v $program_exe)" ]; then
14+
# stop any running $program if it exists
15+
$program_exe stop
16+
fi
17+
18+
#copy config file
19+
abort () {
20+
exec echo "Installation aborted"
21+
}
22+
sudo mkdir -p "$(dirname $conf_path)" || abort
2023

21-
# check if "-y" or "--yes" is passed as an argument
22-
YES=false
23-
while test $# -gt 0
24-
do
25-
case "$1" in
26-
-y) YES=true
27-
;;
28-
--yes) YES=true
29-
;;
30-
esac
31-
shift
32-
done
24+
# check if "-y" or "--yes" is passed as an argument
25+
YES=false
26+
while test $# -gt 0
27+
do
28+
case "$1" in
29+
-y) YES=true
30+
;;
31+
--yes) YES=true
32+
;;
33+
esac
34+
shift
35+
done
3336

34-
sudo chown $USER $(dirname $CONF_PATH)
35-
if [ ! -f $CONF_PATH ]; then
36-
if [ ! -f $OLD_CONF_PATH ]; then
37-
# old config file not found, create from scratch
38-
cat $DCONF_PATH > $CONF_PATH || abort
37+
sudo chown $USER "$(dirname $conf_path)"
38+
if [ ! -f "$conf_path" ]; then
39+
if [ ! -f "$old_conf_path" ]; then
40+
# old config file not found, create from scratch
41+
cat "$dconf_path" > "$conf_path" || abort
42+
else
43+
# old config file found, move to the new path
44+
cat "$old_conf_path" > "$conf_path" || abort
45+
echo "Configuration copied from $old_conf_path to $conf_path"
46+
fi
3947
else
40-
# old config file found, move to the new path
41-
cat $OLD_CONF_PATH > $CONF_PATH || abort
42-
echo "Configuration copied from $OLD_CONF_PATH to $CONF_PATH"
43-
fi
44-
else
45-
# config file found, ask user if overwrite
46-
echo "Old conf file found in $CONF_PATH"
47-
if [ $YES == false ]; then
48-
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response
49-
response=${response,,} # tolower
50-
if [[ "$response" =~ ^(no|n)$ ]]; then
51-
read -r -p "Conf file will be overwritten. Are you sure? [Y/n] " response
52-
response=${response,,}
53-
if [[ "$response" =~ ^(yes|y)$ ]]; then
54-
cat $DCONF_PATH > $CONF_PATH || abort
55-
else
56-
abort
48+
# config file found, ask user if overwrite
49+
echo "Old conf file found in $conf_path"
50+
if [ "$YES" == false ]; then
51+
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response
52+
response="${response,,}" # tolower
53+
if [[ "$response" =~ ^(no|n)$ ]]; then
54+
read -r -p "Conf file will be overwritten. Are you sure? [Y/n] " response
55+
response="${response,,}"
56+
if [[ "$response" =~ ^(yes|y)$ ]]; then
57+
cat "$dconf_path" > "$conf_path" || abort
58+
else
59+
abort
60+
fi
5761
fi
5862
fi
5963
fi
60-
fi
6164

62-
echo "Installing..."
65+
echo "Installing to $program_exe ..."
6366

64-
# remove existing comfortable-swipe
65-
if [ -x "$(command -v $PROGRAM)" ]; then
66-
sudo rm -f $(which comfortable-swipe)
67-
fi
67+
# remove existing $program
68+
if [ -x "$(command -v $program_exe)" ]; then
69+
sudo rm -f "$(which $program)"
70+
fi
71+
72+
# compile library
73+
sudo "$compile_command" "$program_exe" || abort
6874

69-
# compile library
70-
sudo $COMPILE $PROGRAM || abort
75+
# add permissions to input group (defer)
76+
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort
7177

72-
# add permissions to input group (defer)
73-
# GROUP=$(ls -l /dev/input/event* | awk '{print $4}' | head --line=1) || abort
78+
# turn on autostart by default
79+
local autostart_status="$($program_exe autostart)"
80+
if [[ "$autostart_status" == *off* ]]; then
81+
autostart_status="$($program_exe autostart)"
82+
fi
7483

75-
# toggle autostart twice to refresh any changes
76-
$PROGRAM autostart > /dev/null || abort
77-
$PROGRAM autostart > /dev/null || abort
84+
echo "Successfully installed $program $(cat $dir/VERSION | tr -d '[:space:]')"
85+
echo ""
86+
echo "$autostart_status"
87+
echo "Edit configuration file: gedit \$($program config)"
88+
echo ""
89+
echo "Try running: $program start"
90+
}
7891

79-
echo "Successfully installed comfortable-swipe."
80-
echo "Configuration file is located at $CONF_PATH"
81-
echo ""
82-
echo "Try running 'comfortable-swipe start' to test."
92+
install
93+
unset -f install

lib/index.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
#define __COMFORTABLE_SWIPE__CONFIG__ "/usr/local/share/comfortable-swipe/comfortable-swipe.conf"
2929
#endif /* __COMFORTABLE_SWIPE__CONFIG__ */
3030

31+
#ifndef COMFORTABLE_SWIPE_VERSION
32+
#warning COMFORTABLE_SWIPE_VERSION is not defined
33+
#define COMFORTABLE_SWIPE_VERSION "v(UNKNOWN)"
34+
#endif /* COMFORTABLE_SWIPE_VERSION */
35+
3136
#include <map> // std::map
3237
#include <string> // std::string
3338

lib/service/help.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace comfortable_swipe::service
3030
void help()
3131
{
3232
using comfortable_swipe::util::conf_filename;
33-
std::puts("comfortable-swipe [start|stop|restart|autostart|buffer|help|config|debug|status]");
33+
std::puts("comfortable-swipe " COMFORTABLE_SWIPE_VERSION " [start|stop|restart|autostart|buffer|help|config|debug|status]");
3434
std::puts("");
3535
std::puts("start - starts 3/4-finger gesture service");
3636
std::puts("stop - stops 3/4-finger gesture service");

lib/service/status.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,13 @@ namespace comfortable_swipe::service
5050
auto autostart_f = comfortable_swipe::util::autostart_filename();
5151
bool autostart_on = access(autostart_f, F_OK) != -1;
5252

53-
// print status
54-
std::printf("program is %s\n", running ? "ON" : "OFF");
55-
std::printf("autostart is %s\n", autostart_on ? "ON" : "OFF");
56-
std::printf("config file at %s\n", comfortable_swipe::util::conf_filename());
53+
std::puts(comfortable_swipe::util::conf_filename());
5754

5855
// check status of configuration file
5956
try
6057
{
6158
auto config = comfortable_swipe::util::read_config_file(comfortable_swipe::util::conf_filename());
6259

63-
// print keys and values of config file
64-
std::printf("\nConfigurations:\n");
65-
6660
// print threshold
6761
if (config.count("threshold") > 0)
6862
{
@@ -91,6 +85,10 @@ namespace comfortable_swipe::service
9185
{
9286
std::printf("config error: %s\n", e.what());
9387
}
88+
89+
// print status
90+
std::printf("autostart is %s\n", autostart_on ? "ON" : "OFF");
91+
std::printf("comfortable-swipe program is %s\n", running ? "RUNNING" : "STOPPED");
9492
}
9593
}
9694

0 commit comments

Comments
 (0)