summaryrefslogtreecommitdiffstats
path: root/toggle-mouse-wheel-emulation
diff options
context:
space:
mode:
Diffstat (limited to 'toggle-mouse-wheel-emulation')
-rwxr-xr-xtoggle-mouse-wheel-emulation29
1 files changed, 22 insertions, 7 deletions
diff --git a/toggle-mouse-wheel-emulation b/toggle-mouse-wheel-emulation
index 88fffe9..ddd524f 100755
--- a/toggle-mouse-wheel-emulation
+++ b/toggle-mouse-wheel-emulation
@@ -1,12 +1,27 @@
#!/bin/sh
-ID=$(xinput --list --id-only "PS/2 Synaptics TouchPad")
-ENABLED=$(xinput list-props $ID | grep -E "Evdev Wheel Emulation \([0-9]*\):" | awk '{print $5}')
+swaymsg -q >/dev/null 2>&1
+SWAY=$?
-if [ $ENABLED = 1 ] ; then
- xinput set-prop $ID --type=int --format=8 "Evdev Wheel Emulation" 0
- echo "disabled"
+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
- xinput set-prop $ID --type=int --format=8 "Evdev Wheel Emulation" 1
- echo "enabled"
+ 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