aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/hyprland/.local/bin/toggle-touchpad
blob: ed116749a3639f54ddbda805a68cc5cc359ab3f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# Toggle the laptop touchpad on/off

TOUCHPAD="pixa3854:00-093a:0274-touchpad"
STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/touchpad-state"

# Default to enabled if no state file
if [ ! -f "$STATE_FILE" ]; then
    echo "enabled" > "$STATE_FILE"
fi

state=$(cat "$STATE_FILE")

if [ "$state" = "enabled" ]; then
    hyprctl keyword "device[$TOUCHPAD]:enabled" false >/dev/null
    echo "disabled" > "$STATE_FILE"
    notify info "Touchpad" "Disabled" --silent
else
    hyprctl keyword "device[$TOUCHPAD]:enabled" true >/dev/null
    echo "enabled" > "$STATE_FILE"
    notify info "Touchpad" "Enabled" --silent
fi

# Refresh the waybar indicator immediately (custom/touchpad listens on signal 9).
pkill -RTMIN+9 waybar 2>/dev/null