This repository contains a Bash script for enabling scroll functionality on the Magic Mouse 2 in Ubuntu. The script utilizes parameters for the hid-magicmouse module to emulate scroll wheel behavior, middle click functionality, and adjust scroll acceleration and speed.
![Magic Mouse Gestures](https://private-user-images.githubusercontent.com/52969662/329823105-db06c8de-5ee5-4ca0-8a79-3ad5887ac5a4.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI4MDE4OTksIm5iZiI6MTcyMjgwMTU5OSwicGF0aCI6Ii81Mjk2OTY2Mi8zMjk4MjMxMDUtZGIwNmM4ZGUtNWVlNS00Y2EwLThhNzktM2FkNTg4N2FjNWE0LmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODA0VDE5NTk1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3ZmFmYzhkZjI0M2RlMTMwZmU3ZjU4MjEzZjU5MzRjNzk4MmI5NGY0YzU5OTVmMTQ3ZjdkYzBjYzkzZGE2OTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FOfWOUOqPLD0P_UEvxAbw9DVM3KmVz4BnXoSOVO7XSI)
-
Create the Script:
- Create a file named
scroll.sh
and paste the following content:#!/bin/bash sudo modprobe -r hid-magicmouse sudo modprobe hid-magicmouse emulate_scroll_wheel=Y emulate_3button=Y middle_click_3finger=Y scroll_acceleration=Y scroll_speed=12
- Ensure the script has executable permissions.
- Create a file named
-
Move the Script:
- Move the
scroll.sh
script to the user's root folder~/
using themv
command:mv scroll.sh ~/scroll.sh
- Move the
-
Add an Alias to .bashrc:
- Open the
.bashrc
file in a text editor (e.g., nano or vim):nano ~/.bashrc
- Add the following line at the end of the file:
alias scroll='~/scroll.sh'
- Save the changes and exit the text editor.
- Open the
-
Execute the Script:
- Once the Magic Mouse 2 is connected using bluetooth, open a terminal and type
scroll
to execute the script. This will enable the configured scroll functionality for the device.
- Once the Magic Mouse 2 is connected using bluetooth, open a terminal and type
- The script must be executed with
sudo
or as a user with sufficient permissions to load/unload kernel modules. - Adjust parameters in the script (
emulate_scroll_wheel
,emulate_3button
,middle_click_3finger
,scroll_acceleration
,scroll_speed
) as needed to customize mouse behavior.