-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtouchpad-toggle
executable file
·27 lines (22 loc) · 1014 Bytes
/
touchpad-toggle
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
26
27
#!/bin/bash
#=======================================================================================================================
# Toggle the touchpad on/off
#=======================================================================================================================
. "$(dirname "$(realpath "$0")")/common.sh"
# Try to find a touchpad
DEV_NAME="$(xinput list --name-only | grep -i touchpad | head -n 1)"
[[ -z "$DEV_NAME" ]] && err "No touchpad found among the input devices"
# Get device ID
DEV_ID=$(xinput list --id-only "$DEV_NAME")
[[ -z "$DEV_ID" ]] && echo "Failed to get device ID" && exit 1
log "Device '$DEV_NAME', id=$DEV_ID"
# Get device state
DEV_ENABLED=$(xinput list-props $DEV_ID | grep "Device Enabled" | cut -d$'\t' -f3 | tr -d '\n')
# Toggle the device state
if ((DEV_ENABLED == 0)); then
xinput enable $DEV_ID
notify-send -i "gtk-yes" "Touchpad" "Touchpad is enabled"
else
xinput disable $DEV_ID
notify-send -i "gtk-no" "Touchpad" "Touchpad is disabled"
fi