Posted on 03-16-2022 07:41 AM
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-
Solved! Go to Solution.
Posted on 03-16-2022 08:09 AM
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.
Posted on 03-16-2022 08:09 AM
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.
Posted on 03-16-2022 10:13 AM
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-
03-17-2022 05:52 AM - edited 03-17-2022 05:52 AM
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
Posted on 03-17-2022 05:59 AM
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.
Posted on 03-17-2022 08:25 AM
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
Posted on 09-06-2023 07:22 AM
Does this work only for the Apple mouse, we are using wired Logitech mice in our classroom.
Posted on 09-06-2023 07:30 AM
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?
Posted on 09-06-2023 07:40 AM
Works on our wired Cherry mouses
Posted on 09-06-2023 07:41 AM
Thank you, we are in session not a lot of options to test so I appreciate the feedback