From dcbb02b43a80e2be6ac2b77a4775b7df623d4809 Mon Sep 17 00:00:00 2001 From: "Ja.KooLit" Date: Fri, 29 Dec 2023 01:26:59 +0900 Subject: adjustments of scripts --- config/hypr/scripts/TouchPad.sh | 44 +++++++++++++---------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'config/hypr/scripts/TouchPad.sh') diff --git a/config/hypr/scripts/TouchPad.sh b/config/hypr/scripts/TouchPad.sh index 7b9a1806..1fcb3249 100755 --- a/config/hypr/scripts/TouchPad.sh +++ b/config/hypr/scripts/TouchPad.sh @@ -1,38 +1,22 @@ #!/bin/bash +HYPRLAND_DEVICE="asue1209:00-04f3:319f-touchpad" notif="$HOME/.config/swaync/images/bell.png" -# NOTE: find the right device using hyprctl devices - HYPRLAND_DEVICE="asue1209:00-04f3:319f-touchpad" +XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} +STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status" -if [ -z "$XDG_RUNTIME_DIR" ]; then - export XDG_RUNTIME_DIR=/run/user/$(id -u) -fi - -export STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status" - -enable_touchpad() { - printf "true" > "$STATUS_FILE" - - notify-send -u low -i "$notif" "Enabling Touchpad" - - hyprctl keyword "device:$HYPRLAND_DEVICE:enabled" true -} - -disable_touchpad() { - printf "false" > "$STATUS_FILE" - - notify-send -u low -i "$notif" "Disabling Touchpad" +toggle_touchpad() { + if [ ! -f "$STATUS_FILE" ] || [ "$(cat "$STATUS_FILE")" = "false" ]; then + echo "true" > "$STATUS_FILE" + action="enabled" + else + echo "false" > "$STATUS_FILE" + action="disabled" + fi - hyprctl keyword "device:$HYPRLAND_DEVICE:enabled" false + notify-send -u low -i "$notif" "Touchpad $action" + hyprctl keyword "device:$HYPRLAND_DEVICE:enabled" "$(cat "$STATUS_FILE")" } -if ! [ -f "$STATUS_FILE" ]; then - enable_touchpad -else - if [ $(cat "$STATUS_FILE") = "true" ]; then - disable_touchpad - elif [ $(cat "$STATUS_FILE") = "false" ]; then - enable_touchpad - fi -fi +toggle_touchpad -- cgit v1.2.3