0

I have figured out how to use Terminal to change my Apple Magic Mouse settings to be how I like them. I am using the following lines of code.

remove mouse module settings

$ sudo rmmod hid_magicmouse

add faster scrolling settings

e$ sudo modprobe hid_magicmouse emulate_3button=0 scroll_acceleration=1 scroll_speed=55

reverse scroll direction

xinput set-button-map 14 1 2 3 5 4

When I restart the computer, all these setting are lost and I have to re-input them into terminal.

How do I create a script, and where do I save it so that it will run every time I boot the computer.

I am a complete novice in Ubuntu so I don't even know what file extension to use. Thanks in advance for your help.

1 Answers1

0

To create a script so that it will run the commands by a single execution of that script, you need to create a file with '.sh' extension.

Open the terminal, and in a suitable directory, create a script file.

    $vi <name you prefer>.sh

This is will open the VI editor. Or you can choose any other editor if you prefer. Then add each command in a new line, and then save the file. Your file should look something like

    #!/bin/sh
    sudo rmmod hid_magicmouse
    sudo modprobe hid_magicmouse emulate_3button=0 scroll_acceleration=1 scroll_speed=55
    xinput set-button-map 14 1 2 3 5 4

Now set the executable permissions to this file,

    $chmod +x <nameoffile>.sh

And now execute the file,

    $sudo ./<nameoffile>.sh

Execute the file with sudo permissions as your commands need to executed as superuser. Your mouse settings should have taken their place.

To run the script at boot, you can check the answer here.

  • hi thanks for your help! I am able to have the sh file run when I manually type in the file name in Terminal. When I go to edit the /etc/rc.local file I type in the command /home/jono/Documents/scripts/magicMouseFix.sh || exit 1 and when I hit return I get an error stating "pattern not found: home" I am stuck at this point... not sure what to do next – JTMKoenig Apr 12 '17 at 02:57
  • Okay turns out I had to learn how to properly use the vim editor. thanks so much for your answer. I can now restart my computer and the mouse settings are correct. – JTMKoenig Apr 12 '17 at 03:12
  • You're welcome ! @JTMKoenig – Abhijit Nathwani Apr 12 '17 at 13:44