Skip to main content
Solved

Enable right-click by default for new users in Monterey


Forum|alt.badge.img+3

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-

Best answer by PaulHazelden

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 original
Did this topic help you find an answer to your question?

9 replies

PaulHazelden
Forum|alt.badge.img+12
  • Jamf Heroes
  • 378 replies
  • Answer
  • March 16, 2022

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.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • March 16, 2022

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-


PaulHazelden
Forum|alt.badge.img+12
  • Jamf Heroes
  • 378 replies
  • March 17, 2022
Dpatschke wrote:

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


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • March 17, 2022
PaulHazelden wrote:

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.


PaulHazelden
Forum|alt.badge.img+12
  • Jamf Heroes
  • 378 replies
  • March 17, 2022
Dpatschke wrote:

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
Forum|alt.badge.img+5

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


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 6 replies
  • September 6, 2023

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
Forum|alt.badge.img+12
  • Jamf Heroes
  • 378 replies
  • September 6, 2023

Works on our wired Cherry mouses


stephaniemm77
Forum|alt.badge.img+5
PaulHazelden wrote:

Works on our wired Cherry mouses


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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings