diff --git a/config/eww/scripts/on-release.sh b/config/eww/scripts/on-release.sh index 4f22254d..30cbd0ff 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 00000000..3f765f9b --- /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 40362c94..e2f1aa4d 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"