Enable right-click by default for new users in Monterey

Dpatschke
New Contributor II

Has anyone been able to get mice to have right-click enabled by default? We are running lab machines with new users logging in all the time and would prefer they not have to enable that for themselves each time. I have seen (and tried) various solutions here on Jamf (scripts run in a policy) but have not been able to get it to work. I am interested if anyone has had any success while running Monterey.

Thanks-

1 ACCEPTED SOLUTION

PaulHazelden
Valued Contributor

I use a script It is run in a loop and adds the setting to the Templates, but you can change that and make it run on existing accounts. ${USER_TEMPLATE} is the variable from the loop.

# Mouse secondary button

/usr/bin/defaults write /Library/User\ Template/${USER_TEMPLATE}/Library/Preferences/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

I have no problem with this running on Monterey.

/usr/bin/defaults write /Users/<USER HOME>/Library/Preferences/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

Should, if you replace <USER HOME> with a valid account, work just fine.

View solution in original post

9 REPLIES 9

PaulHazelden
Valued Contributor

I use a script It is run in a loop and adds the setting to the Templates, but you can change that and make it run on existing accounts. ${USER_TEMPLATE} is the variable from the loop.

# Mouse secondary button

/usr/bin/defaults write /Library/User\ Template/${USER_TEMPLATE}/Library/Preferences/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

I have no problem with this running on Monterey.

/usr/bin/defaults write /Users/<USER HOME>/Library/Preferences/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

Should, if you replace <USER HOME> with a valid account, work just fine.

Dpatschke
New Contributor II

Thanks so much for the quick reply! This worked well for me - not sure why I found it so difficult. BTW, what do you mean by you have it run in a loop? Also, I have seen your solution for deleting existing local accounts and am looking forward to experimenting with it, it looks perfect for lab machines-

A loop will be something like this. This one would loop through all of the folders it finds in the /Users folder, and apply the setting to each one. You really need to refine the output of the ls command, because you want to ignore stuff like the Shared folder.

 

# Look for User accounts

Accounts=$(ls -l /Users | /usr/bin/awk '{print $9}' | /usr/bin/grep -viE '(shared|Guest|.DS_Store|.localized)')

for UserAccounts in $Accounts

do

/usr/bin/defaults write /Users/$UserAccounts/Library/Preferences/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

done

Ah, so this would be done for existing local accounts. I'm mainly concerned with having it enabled for each new user that logs into these public/lab machines - so I imagine the script alone will suffice.

For the templates you would need something like

$(ls /Library/User\ Template/ | grep -v "__" )
as the lookup bit of the loop

There are quite a few Templates, and whilst in theory just adding this to the non-localised one should work on its own, I throw it to them all.

# Look for User templates

Templates=$(ls /Library/User\ Template/ | grep -v "__" )

for USER_TEMPLATE in $Templates

do

/usr/bin/defaults write /Library/User\ Template/$USER_TEMPLATE/Library/Preferences/com.apple.driver.AppleHIDMouse.plist Button2 -int 2

done

stephaniemm77
Contributor II

Does this work only for the Apple mouse, we are using wired Logitech mice in our classroom.

Dpatschke
New Contributor II

It's worth a shot, I imagine right-click on any mouse triggers the same response in the OS, so it seems like it should?

PaulHazelden
Valued Contributor

Works on our wired Cherry mouses

Thank you, we are in session not a lot of options to test so I appreciate the feedback