summaryrefslogtreecommitdiffstats
path: root/toggle-mouse-wheel-emulation
blob: ddd524f63005ce745849919e9126d65f3f557882 (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
26
27
#!/bin/sh

swaymsg -q >/dev/null 2>&1
SWAY=$?

if [ $SWAY -ne 0 ] ; then
	ID=$(xinput --list --id-only "PS/2 Synaptics TouchPad")
	ENABLED=$(xinput list-props $ID | grep -E "Evdev Wheel Emulation \([0-9]*\):" | awk '{print $5}')

	if [ $ENABLED = 1 ] ; then
		xinput set-prop $ID --type=int --format=8 "Evdev Wheel Emulation" 0
		echo "disabled"
	else
		xinput set-prop $ID --type=int --format=8 "Evdev Wheel Emulation" 1
		echo "enabled"
	fi
else
	status=$(swaymsg -rt get_inputs | jq -r '.[] | select(.identifier == "2:10:TPPS/2_IBM_TrackPoint") | .libinput.scroll_method')

	if [ "$status" = 'on_button_down' ] ; then
		swaymsg input "2:10:TPPS/2_IBM_TrackPoint" scroll_method none
		echo "disabled"
	else
		swaymsg input "2:10:TPPS/2_IBM_TrackPoint" scroll_method on_button_down
		echo "enabled"
	fi
fi