5

I'm trying to get the magic mouse 2 scrolling setup on Ubuntu 20.04. I've followed the instructions from the Github driver page - https://github.com/rohitpid/Linux-Magic-Trackpad-2-Driver and this great blog post on tuning the variables http://sneclacson.blogspot.com/2016/09/using-apple-magic-mouse-with-ubuntu-1604.html

I understand these were based on 16.04 which relied on Xorg and since 18 this has moved to Wayland so it's not 100% applicable to this scenario.

I've got scrolling working but i'm unable to make it persistent across reboots. Everytime I restart I need to unload/load the hid_magicmouse module to get it working again.

I created a service to run a script that does this automatically after the user session has loaded but this doesn't appear to be work (I'm guessing it's still executing prior to the mouse connecting):

cat mouse.service 

[Unit]
Description=mouse scroll
After=systemd-user-sessions.service

[Service]
ExecStart=/Scripts/mouse.sh

[Install]
WantedBy=multi-user.target
cat /Scripts/mouse.sh 
#!/bin/sh
rmmod hid_magicmouse
modprobe hid_magicmouse

Is there a simple way to run this script/service as root when a user logs in given the mouse connects prior to a user logging in?

1
  • 1
    This question could be asked in the AskUbuntu forum.
    – waltinator
    Sep 23, 2020 at 2:18

1 Answer 1

4

Yes, via a 3 step process:

First, read man sudoers sudo, and set up passwordless sudo access to rmmod and modprobe for that particular user..

Second, write a bash script:

#!/bin/bash 
sudo rmmod hid_magicmouse
sudo modprobe hid_magicmouse
exit 0

Finally, invoke the script at (GUI) login time by putting a magicmouse.desktop file in $HOME/.config/autostart/.

Use locate .desktop to find many examples of .desktop files.

1
  • Thanks, that's working now! I've also learned about visudo and locate as part of this answer.
    – liftconfig
    Sep 23, 2020 at 5:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .