Compare commits
6 Commits
improve-in
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc117c0ab5 | ||
|
|
4cf3bf3d8d | ||
|
|
9393a96d3f | ||
|
|
179083a152 | ||
|
|
99f659c9db | ||
|
|
7728495350 |
26
README.md
26
README.md
@ -61,18 +61,18 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
|
|||||||
Comfortable swipe is RUNNING in the background
|
Comfortable swipe is RUNNING in the background
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1. (Optional) Toggle autostart
|
||||||
|
|
||||||
|
```bash
|
||||||
|
comfortable-swipe autostart on
|
||||||
|
```
|
||||||
|
|
||||||
1. (Optional) Stop the Program
|
1. (Optional) Stop the Program
|
||||||
|
|
||||||
```
|
```
|
||||||
comfortable-swipe stop
|
comfortable-swipe stop
|
||||||
```
|
```
|
||||||
|
|
||||||
1. (Optional) Toggle autostart
|
|
||||||
|
|
||||||
```bash
|
|
||||||
comfortable-swipe autostart
|
|
||||||
```
|
|
||||||
|
|
||||||
1. (Optional) See program status
|
1. (Optional) See program status
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -278,6 +278,16 @@ Refer to https://www.linux.org/threads/xdotool-keyboard.10528/ for a complete li
|
|||||||
- [KDE Keyboard Shortcuts](https://community.linuxmint.com/tutorial/view/47)
|
- [KDE Keyboard Shortcuts](https://community.linuxmint.com/tutorial/view/47)
|
||||||
- [PopOS Keyboard Shortcuts](https://support.system76.com/articles/pop-keyboard-shortcuts/)
|
- [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
|
## Example Configurations
|
||||||
|
|
||||||
This section includes some example configurations which you can use for your swipe experience.
|
This section includes some example configurations which you can use for your swipe experience.
|
||||||
@ -306,8 +316,8 @@ This section includes some example configurations which you can use for your swi
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pop OS
|
# Pop OS
|
||||||
comfortable-swipe up3 = ctrl+super+Down
|
comfortable-swipe up3 = Super+Ctrl+Down
|
||||||
comfortable-swipe down3 = ctrl+super+Up
|
comfortable-swipe down3 = Super+Ctrl+Up
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Move window to workspace (horizontal)
|
1. Move window to workspace (horizontal)
|
||||||
|
|||||||
@ -115,7 +115,7 @@ function start {
|
|||||||
debug | buffer $@
|
debug | buffer $@
|
||||||
else
|
else
|
||||||
# detach buffered output
|
# detach buffered output
|
||||||
nohup "$BASENAME" debug </dev/null 2>&1 | "$BASENAME" buffer $@ >/dev/null 2>&1 &
|
nohup "$BASENAME" debug </dev/null 2>&1 | "$BASENAME" buffer $@ >/dev/null 2>&1 & disown
|
||||||
echo "Comfortable swipe is RUNNING in the background"
|
echo "Comfortable swipe is RUNNING in the background"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,7 +134,7 @@ void gesture_swipe_xdokey::update() {
|
|||||||
gesture_swipe::update();
|
gesture_swipe::update();
|
||||||
// scale threshold to 1/10 when gesture is fresh
|
// scale threshold to 1/10 when gesture is fresh
|
||||||
// acts like our static friction coefficient
|
// acts like our static friction coefficient
|
||||||
float scale = get_previous_gesture() == FRESH ? 0.01f : 1.0f;
|
const float scale = get_previous_gesture() == FRESH ? 0.01f : 1.0f;
|
||||||
// we are working with floating points which are not exact
|
// we are working with floating points which are not exact
|
||||||
// make sure we compare with a very small value (1e-6f)
|
// make sure we compare with a very small value (1e-6f)
|
||||||
// if distance goes out of threshold, perform our swipe
|
// if distance goes out of threshold, perform our swipe
|
||||||
|
|||||||
@ -112,10 +112,14 @@ int main(int argc, char *argv[]) {
|
|||||||
// get input values
|
// get input values
|
||||||
string mouse3 = config.count("mouse3") ? config["mouse3"] : config["hold3"];
|
string mouse3 = config.count("mouse3") ? config["mouse3"] : config["hold3"];
|
||||||
string mouse4 = config.count("mouse4") ? config["mouse4"] : config["hold4"];
|
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
|
// create our mouse gesture holder
|
||||||
gesture_swipe_xdomouse mousehold(mouse3.data(), mouse4.data());
|
gesture_swipe_xdomouse mousehold(mouse3.data(), mouse4.data());
|
||||||
// start reading lines from input one by one
|
// start reading lines from input one by one
|
||||||
for (string line; getline(cin, line);) {
|
for (string line; getline(cin, line);) {
|
||||||
|
if (nomouse) {
|
||||||
|
keyswipe.run(line.data());
|
||||||
|
} else {
|
||||||
// optimization: if no mouse config is set, just run keyboard
|
// optimization: if no mouse config is set, just run keyboard
|
||||||
if (mousehold.is_swiping() && mousehold.button == MOUSE_NONE) {
|
if (mousehold.is_swiping() && mousehold.button == MOUSE_NONE) {
|
||||||
keyswipe.run(line.data());
|
keyswipe.run(line.data());
|
||||||
@ -126,6 +130,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
47
install
47
install
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [[ "$USER" == root ]]; then
|
||||||
|
echo "Please run 'bash install' as non-root user" 2>&1
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
DIR="$(dirname "$0")"
|
DIR="$(dirname "$0")"
|
||||||
VERSION="$(cat $DIR/VERSION | tr -d '[:space:]')"
|
VERSION="$(cat $DIR/VERSION | tr -d '[:space:]')"
|
||||||
|
|
||||||
@ -29,7 +34,7 @@ comfortable-swipe stop > /dev/null 2>&1 || true
|
|||||||
|
|
||||||
# shorthand to abort the installation
|
# shorthand to abort the installation
|
||||||
function abort {
|
function abort {
|
||||||
echo "Installation aborted"
|
echo "Installation aborted" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,14 +67,23 @@ function install_configuration_file {
|
|||||||
# ask user if we overwrite configuration
|
# ask user if we overwrite configuration
|
||||||
echo "Old conf file found in $CONF_TARGET" >&2
|
echo "Old conf file found in $CONF_TARGET" >&2
|
||||||
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response >&2
|
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response >&2
|
||||||
if ! [[ "${response,,}" =~ ^(yes|y)$ ]]; then
|
|
||||||
|
# If response is empty, consider it as 'yes' (default)
|
||||||
|
if [[ -z "$response" ]]; then
|
||||||
|
response="y"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${response,,}" =~ ^(no|n)$ ]]; then
|
||||||
# MAKE SURE they really want to overwrite
|
# MAKE SURE they really want to overwrite
|
||||||
read -r -p "Conf file will be overwritten! Are you sure? [Y/n] " response >&2
|
read -r -p "Conf file will be overwritten! Are you sure? [Y/n] " response >&2
|
||||||
if [[ "${response,,}" =~ ^(yes|y)$ ]]; then
|
if [[ -z "$response" ]]; then
|
||||||
|
response="y"
|
||||||
|
fi
|
||||||
|
if [[ "${response,,}" =~ ^(no|n)$ ]]; then
|
||||||
|
abort
|
||||||
|
else
|
||||||
# They agreed... replace configuration
|
# They agreed... replace configuration
|
||||||
cat "$CONF_SOURCE" > "$CONF_TARGET"
|
cat "$CONF_SOURCE" > "$CONF_TARGET"
|
||||||
else
|
|
||||||
abort
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -98,9 +112,15 @@ function install_configuration_file {
|
|||||||
function install_main_program {
|
function install_main_program {
|
||||||
# copy source to target with executable permissions
|
# copy source to target with executable permissions
|
||||||
# install to target, with hardcoded version
|
# install to target, with hardcoded version
|
||||||
trysudo sed -E "s/^VERSION=.*/VERSION=$VERSION/" "$SOURCE" > "$TARGET"
|
if [[ -f "$TARGET" ]]; then
|
||||||
# allow execute permissions
|
trysudo rm "$TARGET"
|
||||||
|
fi
|
||||||
|
trysudo cp "$SOURCE" "$TARGET"
|
||||||
|
trysudo sed -E "s/^VERSION=.*/VERSION=$VERSION/" -i "$TARGET"
|
||||||
|
# allow execute permissions with group
|
||||||
trysudo chmod +x "$TARGET"
|
trysudo chmod +x "$TARGET"
|
||||||
|
# make sure non-root user is owner
|
||||||
|
trysudo chown "$USER" "$TARGET"
|
||||||
echo "Installed: $TARGET"
|
echo "Installed: $TARGET"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +134,17 @@ function install_cpp_program {
|
|||||||
# compile program to temporary file first
|
# compile program to temporary file first
|
||||||
TMP_TARGET="$(mktemp)"
|
TMP_TARGET="$(mktemp)"
|
||||||
$COMPILE "$COMPILE_SOURCE" -o "$TMP_TARGET" -DCOMFORTABLE_SWIPE_VERSION="\"$VERSION\"" -DCOMFORTABLE_SWIPE_CONFIG="\"$CONF_TARGET\"" -DCOMFORTABLE_SWIPE_AUTOSTART="\"$AUTOSTART_TARGET\""
|
$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
|
# compilation ok, now try to install with sudo
|
||||||
# check permissions maybe if will need sudo
|
trysudo mkdir -p "$(dirname "$COMPILE_TARGET")"
|
||||||
|
# remove existing file for permissions to work
|
||||||
|
if [[ -f "$COMPILE_TARGET" ]]; then
|
||||||
|
sudo rm "$COMPILE_TARGET"
|
||||||
|
fi
|
||||||
trysudo mv "$TMP_TARGET" "$COMPILE_TARGET"
|
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"
|
echo "Installed: $COMPILE_TARGET"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +155,7 @@ function install_cpp_program {
|
|||||||
# /home/$USER/.config/autostart/comfortable-swipe.desktop
|
# /home/$USER/.config/autostart/comfortable-swipe.desktop
|
||||||
#
|
#
|
||||||
function install_autostart {
|
function install_autostart {
|
||||||
|
mkdir -p "$(dirname "$AUTOSTART_TARGET")"
|
||||||
cat "$AUTOSTART_SOURCE" > "$AUTOSTART_TARGET"
|
cat "$AUTOSTART_SOURCE" > "$AUTOSTART_TARGET"
|
||||||
echo "Installed: $AUTOSTART_TARGET"
|
echo "Installed: $AUTOSTART_TARGET"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user