From 69dbe41a1c65e89bacbed4e85c91c5a443d685f0 Mon Sep 17 00:00:00 2001 From: The_miro Date: Fri, 28 Nov 2025 10:47:15 +0100 Subject: [PATCH] Add desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh --- .../scripts/hyprland-toggle-touchpad.sh | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh diff --git a/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh b/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh new file mode 100644 index 0000000..d5f65d0 --- /dev/null +++ b/desktopenvs/hyprland/scripts/hyprland-toggle-touchpad.sh @@ -0,0 +1,40 @@ + +#!/usr/bin/env bash + +STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status" + +# Detect touchpad name dynamically +TOUCHPAD_NAME=$(hyprctl devices | awk '/type: touchpad/{getline; print $2; exit}') +TOUCHPAD_KEYWORD="device:${TOUCHPAD_NAME}:enabled" + +# Functions +enable_touchpad() { + printf "true" >"$STATUS_FILE" + notify-send -u normal "Touchpad Enabled" + hyprctl keyword "$TOUCHPAD_KEYWORD" "true" -r +} + +disable_touchpad() { + printf "false" >"$STATUS_FILE" + notify-send -u normal "Touchpad Disabled" + hyprctl keyword "$TOUCHPAD_KEYWORD" "false" -r +} + +# Get current state from Hyprland (1 = enabled, 0 = disabled) +CURRENT_STATE=$(hyprctl getoption "$TOUCHPAD_KEYWORD" | grep "int:" | awk '{print $2}') + +# Initialize status file if missing +if ! [ -f "$STATUS_FILE" ]; then + if [ "$CURRENT_STATE" -eq 1 ]; then + printf "true" >"$STATUS_FILE" + else + printf "false" >"$STATUS_FILE" + fi +fi + +# Toggle based on status file +if [ "$(cat "$STATUS_FILE")" = "true" ]; then + disable_touchpad +else + enable_touchpad +fi