Compare commits

..

2 Commits

Author SHA1 Message Date
Rico Tiongson
0065c565b1 Use filled heavy check mark 2020-05-08 00:01:54 +08:00
Rico Tiongson
5dbcfe300b Configure swipes ok for mouse3/4 = move 2020-05-08 00:00:36 +08:00
6 changed files with 42 additions and 89 deletions

View File

@ -48,7 +48,9 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
1. **_Important_**: After inputing your `sudo` password, log out then log back in
1. Start the Program
## List of Commands
1. **Start the Program**
```
comfortable-swipe start
@ -61,19 +63,24 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
Comfortable swipe is RUNNING in the background
```
1. (Optional) Toggle autostart
```bash
comfortable-swipe autostart on
```
1. (Optional) Stop the Program
1. **Stop the Program**
```
comfortable-swipe stop
```
1. (Optional) See program status
1. **Toggle Autostart** (optional)
```bash
comfortable-swipe autostart
comfortable-swipe autostart on
comfortable-swipe autostart off
comfortable-swipe autostart toggle
comfortable-swipe autostart status
comfortable-swipe autostart path
```
1. **Program status**
```bash
comfortable-swipe status
@ -101,7 +108,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
mouse4 is NOTSET
```
1. (Optional) Get config
1. **Get config**
```
comfortable-swipe <PROPERTY>
@ -121,7 +128,7 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
comfortable-swipe mouse4
```
1. (Optional) Set config
1. **Set config**
```bash
comfortable-swipe <PROPERTY> [=] <VALUES>
@ -155,16 +162,6 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
comfortable-swipe --help
```
1. Autostart commands
```bash
comfortable-swipe autostart on
comfortable-swipe autostart off
comfortable-swipe autostart toggle
comfortable-swipe autostart status
comfortable-swipe autostart path
```
1. Show output with `--attach`
Example output of 3-finger left, 4-finger left, 3-finger right, 3-finger up:
@ -278,16 +275,6 @@ Refer to https://www.linux.org/threads/xdotool-keyboard.10528/ for a complete li
- [KDE Keyboard Shortcuts](https://community.linuxmint.com/tutorial/view/47)
- [PopOS Keyboard Shortcuts](https://support.system76.com/articles/pop-keyboard-shortcuts/)
## Known Issues: Pop!_OS 20.04+
Pop!_OS 20.04+ may be sensitive to capitalization (#76, #82). Make sure to capitalize every first letter:
```bash
# Pop!_OS
comfortable-swipe up3 = Super+Ctrl+Down
comfortable-swipe down3 = Super+Ctrl+Up
```
## Example Configurations
This section includes some example configurations which you can use for your swipe experience.
@ -316,8 +303,8 @@ This section includes some example configurations which you can use for your swi
```bash
# Pop OS
comfortable-swipe up3 = Super+Ctrl+Down
comfortable-swipe down3 = Super+Ctrl+Up
comfortable-swipe up3 = ctrl+super+Down
comfortable-swipe down3 = ctrl+super+Up
```
1. Move window to workspace (horizontal)
@ -517,13 +504,13 @@ If you can see `GESTURE_SWIPE_XXX` in your output, that means your touchpad supp
For the following reasons:
1. We want prioritize "comfort" over functionality, which we deliver through performance in our negligible-overhead implementation (that's why C++)
1. There are other gesture libraries that already do this properly (eg. [libinput gestures](https://github.com/bulletmark/libinput-gestures), [Fusuma](https://github.com/iberianpig/fusuma)), we don't want to be a clone of them
1. Running a new shell command with unpredictable process time will break our unthreaded optimizations (unlike native keystrokes)
1. We want prioritize "comfort" over functionality, which we deliver through performance in our near-zero-overhead implementation (that's why C++)
2. Running a new shell command with unpredictable process time will break our unthreaded optimizations (unlike native keystrokes)
3. There are other gesture libraries that already do this properly (eg. [libinput gestures](https://github.com/bulletmark/libinput-gestures), [Fusuma](https://github.com/iberianpig/fusuma)), we don't want to be a clone of them
That's why it's not possible... or not?
That's why it's not possible...
**Answer 2**: _... but actually **IT'S POSSIBLE**!_
**Answer 2**: _... but actually **YES**!_
Although we don't provide this out of the box in our config, this can definitely be
done with the default bash tools.

View File

@ -1 +1 @@
v1.2.5
v1.2.3

View File

@ -115,7 +115,7 @@ function start {
debug | buffer $@
else
# detach buffered output
nohup "$BASENAME" debug </dev/null 2>&1 | "$BASENAME" buffer $@ >/dev/null 2>&1 & disown
nohup "$BASENAME" debug </dev/null 2>&1 | "$BASENAME" buffer $@ >/dev/null 2>&1 &
echo "Comfortable swipe is RUNNING in the background"
fi
}

View File

@ -134,7 +134,7 @@ void gesture_swipe_xdokey::update() {
gesture_swipe::update();
// scale threshold to 1/10 when gesture is fresh
// acts like our static friction coefficient
const float scale = get_previous_gesture() == FRESH ? 0.01f : 1.0f;
float scale = get_previous_gesture() == FRESH ? 0.01f : 1.0f;
// we are working with floating points which are not exact
// make sure we compare with a very small value (1e-6f)
// if distance goes out of threshold, perform our swipe

View File

@ -112,22 +112,17 @@ int main(int argc, char *argv[]) {
// get input values
string mouse3 = config.count("mouse3") ? config["mouse3"] : config["hold3"];
string mouse4 = config.count("mouse4") ? config["mouse4"] : config["hold4"];
bool nomouse = mouse3.empty() || mouse4.empty(); // TODO: check if mouse invalid
// create our mouse gesture holder
gesture_swipe_xdomouse mousehold(mouse3.data(), mouse4.data());
// start reading lines from input one by one
for (string line; getline(cin, line);) {
if (nomouse) {
// optimization: if no mouse config is set, just run keyboard
if (mousehold.is_swiping() && mousehold.button == MOUSE_NONE) {
keyswipe.run(line.data());
} else {
// optimization: if no mouse config is set, just run keyboard
if (mousehold.is_swiping() && mousehold.button == MOUSE_NONE) {
} else if (mousehold.run(line.data())) {
// only allow keyswipe gestures on mouse move
if (mousehold.button == MOUSE_NONE || mousehold.button == MOUSE_MOVE) {
keyswipe.run(line.data());
} else if (mousehold.run(line.data())) {
// only allow keyswipe gestures on mouse move
if (mousehold.button == MOUSE_NONE || mousehold.button == MOUSE_MOVE) {
keyswipe.run(line.data());
}
}
}
}

47
install
View File

@ -2,11 +2,6 @@
set -e
if [[ "$USER" == root ]]; then
echo "Please run 'bash install' as non-root user" 2>&1
exit 1
fi
DIR="$(dirname "$0")"
VERSION="$(cat $DIR/VERSION | tr -d '[:space:]')"
@ -34,7 +29,7 @@ comfortable-swipe stop > /dev/null 2>&1 || true
# shorthand to abort the installation
function abort {
echo "Installation aborted" >&2
echo "Installation aborted"
exit 1
}
@ -67,23 +62,14 @@ function install_configuration_file {
# ask user if we overwrite configuration
echo "Old conf file found in $CONF_TARGET" >&2
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response >&2
# If response is empty, consider it as 'yes' (default)
if [[ -z "$response" ]]; then
response="y"
fi
if [[ "${response,,}" =~ ^(no|n)$ ]]; then
if ! [[ "${response,,}" =~ ^(yes|y)$ ]]; then
# MAKE SURE they really want to overwrite
read -r -p "Conf file will be overwritten! Are you sure? [Y/n] " response >&2
if [[ -z "$response" ]]; then
response="y"
fi
if [[ "${response,,}" =~ ^(no|n)$ ]]; then
abort
else
if [[ "${response,,}" =~ ^(yes|y)$ ]]; then
# They agreed... replace configuration
cat "$CONF_SOURCE" > "$CONF_TARGET"
else
abort
fi
fi
else
@ -112,15 +98,9 @@ function install_configuration_file {
function install_main_program {
# copy source to target with executable permissions
# install to target, with hardcoded version
if [[ -f "$TARGET" ]]; then
trysudo rm "$TARGET"
fi
trysudo cp "$SOURCE" "$TARGET"
trysudo sed -E "s/^VERSION=.*/VERSION=$VERSION/" -i "$TARGET"
# allow execute permissions with group
trysudo sed -E "s/^VERSION=.*/VERSION=$VERSION/" "$SOURCE" > "$TARGET"
# allow execute permissions
trysudo chmod +x "$TARGET"
# make sure non-root user is owner
trysudo chown "$USER" "$TARGET"
echo "Installed: $TARGET"
}
@ -134,17 +114,9 @@ function install_cpp_program {
# compile program to temporary file first
TMP_TARGET="$(mktemp)"
$COMPILE "$COMPILE_SOURCE" -o "$TMP_TARGET" -DCOMFORTABLE_SWIPE_VERSION="\"$VERSION\"" -DCOMFORTABLE_SWIPE_CONFIG="\"$CONF_TARGET\"" -DCOMFORTABLE_SWIPE_AUTOSTART="\"$AUTOSTART_TARGET\""
# compilation ok, now try to install with sudo
trysudo mkdir -p "$(dirname "$COMPILE_TARGET")"
# remove existing file for permissions to work
if [[ -f "$COMPILE_TARGET" ]]; then
sudo rm "$COMPILE_TARGET"
fi
# compilation ok, now try to install
# check permissions maybe if will need sudo
trysudo mv "$TMP_TARGET" "$COMPILE_TARGET"
# bugfix: add with group permissions
trysudo chmod go+x "$COMPILE_TARGET"
# make sure non-root user is owner
trysudo chown "$USER" "$COMPILE_TARGET"
echo "Installed: $COMPILE_TARGET"
}
@ -155,7 +127,6 @@ function install_cpp_program {
# /home/$USER/.config/autostart/comfortable-swipe.desktop
#
function install_autostart {
mkdir -p "$(dirname "$AUTOSTART_TARGET")"
cat "$AUTOSTART_SOURCE" > "$AUTOSTART_TARGET"
echo "Installed: $AUTOSTART_TARGET"
}