From 568876794b933a04500cfec3edce175911dce0af Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 13 Aug 2023 15:12:49 -0400 Subject: [PATCH] feat(eww): fix touch_up bug --- config/eww/scripts/on-release.sh | 5 +++-- config/eww/scripts/run.sh | 23 +++++++++++++++++++++++ config/eww/traybuttons/traybuttons.yuck | 10 ++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100755 config/eww/scripts/run.sh diff --git a/config/eww/scripts/on-release.sh b/config/eww/scripts/on-release.sh index 4f22254..30cbd0f 100755 --- a/config/eww/scripts/on-release.sh +++ b/config/eww/scripts/on-release.sh @@ -9,12 +9,13 @@ function run() { while IFS='$\n' read -r line; do if [[ $(echo "$line" | grep TOUCH_UP) != "" ]]; then run + if [[ $(echo "$line" | grep '1 (1)') != "" ]]; then + eww update cancel_touch=false + fi elif [[ $(echo "$line" | grep release) != "" ]]; then run elif [[ $(echo "$line" | grep 'TOUCH_DOWN.*1 (1)') != "" ]]; then eww update cancel_touch=true - elif [[ $(echo "$line" | grep 'TOUCH_UP.*1 (1)') != "" ]]; then - eww update cancel_touch=false else echo "other" > "$FILE" fi diff --git a/config/eww/scripts/run.sh b/config/eww/scripts/run.sh new file mode 100755 index 0000000..3f765f9 --- /dev/null +++ b/config/eww/scripts/run.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +FILE="$HOME/.config/.on-release" +SCRIPT="$1" +VAR="$2" + +function run() { + if [[ $(eww get "$VAR") == "true" ]]; then + if [[ $(eww get cancel_touch) == "false" ]]; then + bash -c "$SCRIPT" + fi + else + eww open on-release-fix + sleep 0.1 + input-emulator mouse button left + fi + echo "cant_run" > "$FILE" +} + +while IFS='$\n' read -r line; do + [[ $(grep "can_run" "$FILE") != "" ]] && run + [[ $(grep "cant_run" "$FILE") != "" ]] && exit 0 +done < <(stdbuf -oL tail -f "$FILE") diff --git a/config/eww/traybuttons/traybuttons.yuck b/config/eww/traybuttons/traybuttons.yuck index 40362c9..e2f1aa4 100644 --- a/config/eww/traybuttons/traybuttons.yuck +++ b/config/eww/traybuttons/traybuttons.yuck @@ -46,10 +46,13 @@ ;; Tablet Mode Toggle ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar tablet-ts false) +(defvar tablet-run-off "false") (defwidget tablet-toggle-on [] (eventbox :class "toggle-on" - :onclick "$HYPR_PATH/laptop-mode.sh &" + :onclick "$EWW_PATH/run.sh '$HYPR_PATH/laptop-mode.sh' tablet-run-off &" :cursor "pointer" + :onhover "eww update tablet-run-off=true" + :onhoverlost "eww update tablet-run-off=false" (box :class "tablet-toggle" :orientation "h" @@ -57,10 +60,13 @@ ) ) ) +(defvar tablet-run-on "false") (defwidget tablet-toggle-off [] (eventbox :class "toggle-off" - :onclick "$HYPR_PATH/tablet-mode.sh &" + :onclick "$EWW_PATH/run.sh '$HYPR_PATH/tablet-mode.sh' tablet-run-on &" :cursor "pointer" + :onhover "eww update tablet-run-on=true" + :onhoverlost "eww update tablet-run-on=false" (box :class "tablet-toggle" :orientation "h"