Skip to content

Instantly share code, notes, and snippets.

@kaiyom
Last active May 26, 2022 21:28
Show Gist options
  • Save kaiyom/e15173f7737fcab84715b5ed1199cecb to your computer and use it in GitHub Desktop.
Save kaiyom/e15173f7737fcab84715b5ed1199cecb to your computer and use it in GitHub Desktop.
This bash script helps you to change your Mouse wheel Speed. So that, you can scroll through page faster or slower depending on your preference.

Mouse wheel speed

change mouse wheel scroll speed in Gnome desktop enviroment (Linux)

Description

This bash script helps you to change your Mouse wheel Speed. So that, you can scroll through page faster or slower depending on your preference.

*Prerequisite

For Debian/Ubuntu/PopOS

sudo apt-get install imwheel gnome-tweaks

For Arch/Manjaro

sudo pacman -S imwheel gnome-tweaks

Installation

Just download the script and While being present in that folder through terminal where this script is located, Run

sh ./mouse-wheel-speed.sh

Now we will do something so that we don't have to run this script over and over, Search tweak and open/run that application from application search bar.

Click on Startup Applications then Click on + plus button to add new Application. In popup window click search icon and search for mouse wheel, And add that application for startup.

That's it. You are done.

Usage

If you need to change mouse wheel speed, Run this script again. No need to setup anything else.

Thank you.

FEEL FREE TO REPORT ANY BUG YOU HAVE DISCOVERED

If you found this script helpful, please give it * star. I have no other way to know is any one even using it or not.

#!/bin/bash
# Version 0.2
# Created: Tuesday, 07 May 2013
# Updated: Monday, 23 May 2022
# {Original} Comments and complaints http://www.nicknorton.net
# {Now} Comments and complaints https://gist.github.com/kaiyom
# GUI for mouse wheel speed using imwheel in Gnome
# imwheel needs to be installed for this script to work
# For Arch and sub distributions
# sudo pacman -S imwheel
# For Debian and sub distributions
# 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
# we are making this desktop shortcut, so that we run this
# shortcut at startup time through gnome tweaks tool
### see if desktop shortcut exists, if not create it ###
if [ ! -f ~/.local/share/applications/mouse-wheel-speed.desktop ]
then
cat >~/.local/share/applications/mouse-wheel-speed.desktop<<EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Mouse Wheel Speed (imwheel)
Icon=mouse
Exec="imwheel"
Comment=Change Mouse Wheel Speed
Keywords=mouse;imwheel;wheel;speed;mice;scroll;setting;
Categories=system;util;
Terminal=false
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=1 --max-value=50 --value="$CURRENT_VALUE" --step 1)
if [ "$NEW_VALUE" == "" ];
then 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment