Last active
September 1, 2021 21:25
-
-
Save mijorus/f7c127a62230490df4e796207ce540bf to your computer and use it in GitHub Desktop.
imwheel script gui modified to disable the service on 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Comments and complaints http://www.nicknorton.net, last modification | |
# by mijorus here https://gist.github.com/mijorus/f7c127a62230490df4e796207ce540bf. | |
# GUI for mouse wheel speed using imwheel in Gnome | |
# imwheel needs to be installed for this script to work | |
# sudo apt-get install imwheel | |
# Pretty much hard wired to only use a mouse with | |
# left, right and wheel in the middle. | |
# If you have a mouse with complications or special needs, | |
# use the command xev to find what your wheel does. | |
# | |
### see if imwheel config exists, if not create it ### | |
if [ ! -f ~/.imwheelrc ] | |
then | |
cat >~/.imwheelrc<<EOF | |
".*" | |
None, Up, Button4, 1 | |
None, Down, Button5, 1 | |
Control_L, Up, Control_L|Button4 | |
Control_L, Down, Control_L|Button5 | |
Shift_L, Up, Shift_L|Button4 | |
Shift_L, Down, Shift_L|Button5 | |
EOF | |
fi | |
########################################################## | |
CURRENT_VALUE=$(awk -F 'Button4,' '{print $2}' ~/.imwheelrc) | |
NEW_VALUE=$(zenity --scale --window-icon=info --ok-label=Apply --title="Wheelies" --text "Mouse wheel speed:" --min-value=0 --max-value=100 --value="$CURRENT_VALUE" --step 1) | |
if [ "$NEW_VALUE" == "" ] || [ "$NEW_VALUE" == "0" ]; | |
then | |
pkill -f imwheel | |
exit 0 | |
fi | |
sed -i "s/\($TARGET_KEY *Button4, *\).*/\1$NEW_VALUE/" ~/.imwheelrc # find the string Button4, and write new value. | |
sed -i "s/\($TARGET_KEY *Button5, *\).*/\1$NEW_VALUE/" ~/.imwheelrc # find the string Button5, and write new value. | |
cat ~/.imwheelrc | |
imwheel -kill -b "4 5" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This small modification will make sure that the imwheel service will be killed completely when the value is set to 0. Additionally, it should not interfere with back and forward size-buttons