-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpointer_toggle.sh
More file actions
executable file
·57 lines (49 loc) · 1.19 KB
/
pointer_toggle.sh
File metadata and controls
executable file
·57 lines (49 loc) · 1.19 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# path: /home/klassiker/.local/share/repos/shell/pointer_toggle.sh
# author: klassiker [mrdotx]
# url: https://github.com/mrdotx/shell
# date: 2025-12-28T05:29:35+0100
# speed up script and avoid language problems by using standard c
LC_ALL=C
LANG=C
# config
notify_title="Toggle Pointer"
xinput_device="$1"
[ -z "$1" ] \
&& xinput list | grep -E '\[(master|slave|floating).*(pointer|master|slave)' \
&& exit
# helper
notification() {
case "$1" in
-n | --notify)
notify-send \
-t 2000 \
-u low \
"$notify_title" \
"$xinput_device $2" \
-h string:x-canonical-private-synchronous:"$xinput_device"
;;
esac
}
device="$(xinput list \
| sed -nre "/$xinput_device/s/.*id=([0-9]*).*/\1/p" \
| head -n1 \
)"
status="$(xinput list-props "$device" \
| grep "Device Enabled" \
| grep -o "[01]$" \
)"
# main
case "$status" in
1)
xinput disable "$device"
notification "$2" "DISABLED"
;;
0)
xinput enable "$device"
notification "$2" "ENABLED"
;;
*)
notification "$2" "NOT FOUND"
;;
esac