-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmouse-acceleration-toggle
44 lines (37 loc) · 1.63 KB
/
mouse-acceleration-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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/bash
#----------------------------------------------------------------------
# Description: toggle or change mouse acceleration using libinput
# Wed Jan 23 00:25:46 2019 : on/off argument
# Author: Artem S. Tashkinov
# Created at: Sun Jan 20 18:26:25 2019
# 2019-01-23 00:31:42 changes unknown
# 2022-10-21 01:54:22 fixes for new xinput output
# Computer: localhost.localdomain
# System: Linux 4.19.15-300.fc29.x86_64 on x86_64
#
# Copyright (c) 2019-2022 Artem S. Tashkinov All rights reserved.
#
#----------------------------------------------------------------------
test -z "$DISPLAY" && echo "DISPLAY is not set. Exiting" && exit -1
# sed 's/.*id=\(.\).*/\1/'` - this should have never worked
mouse=`xinput list | grep Mouse | grep -v Keyboard | sed 's/.*id=\([0-9]*\).*/\1/'`
# was "Accel Profile Enabled (303)" - now 304, why? Let's remove the number
current=`xinput --list-props "$mouse" | grep -i "Accel Profile Enabled (" | rev | cut -c -4 | rev` # alternatively tail -c 5
w=`echo "$1" | tr '[:upper:]' '[:lower:]'`
echo -n "[$current]"
if [ "$current" = "1, 0" ]; then
echo -n " Mouse acceleration is ENABLED. "
test "$w" = "on" && echo "" && exit 0
status="on"
else
echo -n " Mouse acceleration is disabled. "
test "$w" = "off" && echo "" && exit 0
status="off"
fi
if [ "$status" = "on" -o "$w" = "off" ]; then
echo -n "Disabling ... "
xinput --set-prop "$mouse" 'libinput Accel Profile Enabled' 0, 1 && echo OK
elif [ "$status" = "off" -o "$w" = "on" ]; then
echo -n "ENABLING ... "
xinput --set-prop "$mouse" 'libinput Accel Profile Enabled' 1, 0 && echo OK
fi