aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/TouchPad.sh
diff options
context:
space:
mode:
authorMartin Guzman <55927935+brockar@users.noreply.github.com>2026-01-21 16:18:43 -0300
committerGitHub <noreply@github.com>2026-01-21 16:18:43 -0300
commitc6198c1bedeffd08ec3f60f7ba3a41e6c5870885 (patch)
tree458c030873b4e70ff9eda0baed5df257434871f4 /config/hypr/scripts/TouchPad.sh
parent7dedbe3d4a4560ac15987fdf8164dbbb1f4701bf (diff)
parent88a09344e8cc7cffe69a017eb752e8c6fa17ddcb (diff)
Merge pull request #927 from JaKooLit/development
Merge Development to main branch for release
Diffstat (limited to 'config/hypr/scripts/TouchPad.sh')
-rwxr-xr-xconfig/hypr/scripts/TouchPad.sh48
1 files changed, 35 insertions, 13 deletions
diff --git a/config/hypr/scripts/TouchPad.sh b/config/hypr/scripts/TouchPad.sh
index 030c36de..f14165a0 100755
--- a/config/hypr/scripts/TouchPad.sh
+++ b/config/hypr/scripts/TouchPad.sh
@@ -5,28 +5,50 @@
# use hyprctl devices to get your system touchpad device name
# source https://github.com/hyprwm/Hyprland/discussions/4283?sort=new#discussioncomment-8648109
+set -euo pipefail
+
notif="$HOME/.config/swaync/images/ja.png"
+laptops_conf="$HOME/.config/hypr/UserConfigs/Laptops.conf"
+
+touchpad_device="${TOUCHPAD_DEVICE:-}"
+if [[ -z "$touchpad_device" && -f "$laptops_conf" ]]; then
+ touchpad_device="$(
+ awk -F= '/^\$Touchpad_Device/ {
+ gsub(/[[:space:]]*/, "", $1);
+ gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2);
+ print $2;
+ exit
+ }' "$laptops_conf"
+ )"
+fi
+
+if [[ -z "$touchpad_device" ]]; then
+ notify-send -u low -i "$notif" " Touchpad" " Device name not set (check Laptops.conf)"
+ exit 1
+fi
-export STATUS_FILE="$XDG_RUNTIME_DIR/touchpad.status"
+touchpad_keyword="${TOUCHPAD_KEYWORD:-device:${touchpad_device}:enabled}"
+status_file="${XDG_RUNTIME_DIR:-/tmp}/touchpad.status"
enable_touchpad() {
- printf "true" >"$STATUS_FILE"
- notify-send -u low -i $notif " Enabling" " touchpad"
- hyprctl keyword '$TOUCHPAD_ENABLED' "true" -r
+ printf "true" >"$status_file"
+ notify-send -u low -i "$notif" " Enabling" " touchpad"
+ hyprctl keyword "$touchpad_keyword" true -r
}
disable_touchpad() {
- printf "false" >"$STATUS_FILE"
- notify-send -u low -i $notif " Disabling" " touchpad"
- hyprctl keyword '$TOUCHPAD_ENABLED' "false" -r
+ printf "false" >"$status_file"
+ notify-send -u low -i "$notif" " Disabling" " touchpad"
+ hyprctl keyword "$touchpad_keyword" false -r
}
-if ! [ -f "$STATUS_FILE" ]; then
- enable_touchpad
-else
- if [ $(cat "$STATUS_FILE") = "true" ]; then
+current_state="false"
+if [[ -f "$status_file" ]]; then
+ current_state="$(<"$status_file")"
+fi
+
+if [[ "$current_state" == "true" ]]; then
disable_touchpad
- elif [ $(cat "$STATUS_FILE") = "false" ]; then
+else
enable_touchpad
- fi
fi
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage