Setting right click and scroll direction on Apple Wired Mouse in Mojave?

stiermanc
New Contributor

I've been struggling since upgrading a lab to Mojave with getting both the right click setting to work as well as setting the scroll direction to be not natural. We remove the users profile at every logout.

I've managed to get the right mouse button to be set to right click in the system preference but the OS is ignoring the setting and the right click doesn't work despite the preference pane saying it is enabled.

I wrote this setting to my desktop:
defaults write /Users/$USER/Desktop/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

Then updated the plist file to be able to be imported: /usr/bin/plutil -convert xml1 /Users/$USER/Desktop/com.apple.driver.AppleHIDMouse.plist

Then deployed using a configuration profile with custom settings.

I did the same for the scroll direction using this key: defaults write /Library/Preferences/.GlobalPreferences.plist com.apple.swipescrolldirecton -bool false

The swipe scroll seems to be getting applied to the .GlobalPreferences in the Library/Preferences folder instead of the User/Library/Preference folder.

Anyone have an idea on how to get this working?

4 REPLIES 4

kacey3
Contributor

I was looking for this same thing. Sad to see that there are no responses as of yet.

snowfox
Contributor II

"We remove the users profile at every logout." O_O! I used to do that with a logout hook. End result was that it started interfering with what Jamf was doing during log out and all my lab MDM.config clients started slowly becoming unresponsive. This year I changed it to a new script that runs once per computer start-up and once every 24 hours ongoing.

I'm rolling out 10.15.6 this year and I'm finding the mouse scroll direction along with other .globalpreference settings seems to have moved. The only 2x settings that still worked for me were: 'Disable fast user switching' and 'enable or disable auto logout after 60 minutes'.

I got the right click working ok. I tore my hair out trying to get a config profile working before running out of time and had to revert back to the old way of doing it which still works fine.

I customize the default user template which you can still do and still works. They moved it to /Library instead of /System. I run this script after (trigger) (Automated Device) Enrollment Completes - Ongoing

#!/bin/sh

# Mouse Button Settings 

#--------------------------------------------------------
# Defaults

# Set Apple Mouse button 1 to Primary click and button 2 to Secondary click
sudo defaults write /Library/User Template/Non_localized/Library/Preferences/com.apple.driver.AppleHIDMouse Button1 -int 1
sudo defaults write /Library/User Template/Non_localized/Library/Preferences/com.apple.driver.AppleHIDMouse Button2 -int 2

#--------------------------------------------------------

exit 0

The right click works fine on every new 'standard' user account profile that gets created. (For some reason it doesn't apply to the default Admin account but works on every other account that gets created.)
I can't help you with the mouse scrolling unfortunatelly as I never got it working and ran out of time.

snowfox
Contributor II

Hold on I take that back. Sorry, I was referring to the .GlobalPreferences file in the /Library/Preferences folder which confused me. I've just done a quick check with fsmonitor and the natural scrolling option under mouse settings does indeed refer to the .GlobalPreferences file located in the users profile. In that case do the same thing as the above example but do it for your scroll direction setting. I haven't tested this but it should work:

#!/bin/sh

# Mouse Natural Scolling Setting 

#--------------------------------------------------------
# Defaults

# Set Apple Mouse Scroll Direction
sudo defaults write /Library/User Template/Non_localized/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirecton -bool false

#--------------------------------------------------------

exit 0

Adminham
New Contributor III

I would just like to add that there is a spelling error in com.apple.swipescrolldirecton.
It should be com.apple.swipescrolldirection - made all the difference in our labs! :)
Working well under Catalina

#!/bin/sh

# Mouse Natural Scolling Setting 

#--------------------------------------------------------
# Defaults

# Set Apple Mouse Scroll Direction
sudo defaults write /Library/User Template/Non_localized/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool false

#--------------------------------------------------------

# Mouse Button Settings 

#--------------------------------------------------------
# Defaults

# Set Apple Mouse button 1 to Primary click and button 2 to Secondary click
sudo defaults write /Library/User Template/Non_localized/Library/Preferences/com.apple.driver.AppleHIDMouse Button1 -int 1
sudo defaults write /Library/User Template/Non_localized/Library/Preferences/com.apple.driver.AppleHIDMouse Button2 -int 2

#--------------------------------------------------------

    for USER_HOME in /Users/*
        do
            USER_UID=`basename "${USER_HOME}"`
            if [ ! "${USER_UID}" = "Shared" ]; then
                if [ ! -d "${USER_HOME}"/Library/Preferences ]; then
                    /bin/mkdir -p "${USER_HOME}"/Library/Preferences
                    /usr/sbin/chown "${USER_UID}" "${USER_HOME}"/Library
                    /usr/sbin/chown "${USER_UID}" "${USER_HOME}"/Library/Preferences
                fi
            if [ -d "${USER_HOME}"/Library/Preferences ]; then
                /usr/bin/defaults write "${USER_HOME}"/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool false
                /usr/bin/defaults write "${USER_HOME}"/Library/Preferences/com.apple.driver.AppleHIDMouse Button1 -int 1
                /usr/bin/defaults write "${USER_HOME}"/Library/Preferences/com.apple.driver.AppleHIDMouse Button2 -int 2
                /usr/sbin/chown "${USER_UID}" "${USER_HOME}"/Library/Preferences/.GlobalPreferences.plist
                /usr/sbin/chown "${USER_UID}" "${USER_HOME}"/Library/Preferences/com.apple.driver.AppleHIDMouse.plist
            fi
        fi
    done


exit 0