Forcing Hot Corners selections by script, policy or config profile.

kbreed27
Contributor

Hello JAMF-y boys and girls!

 

My management has tasked me with trying to figure out a way to set hot corners for some of our student labs to defined variables. At current, we have desktop picture and screensaver system preferences disabled through config profile for student access but some of the lab teachers want to have certain things available to students. The idea would be to set the Hot Corners while keeping the screensaver and desktop settings blocked from the System preferences pane. 

For instance, we if are trying to keep "Notes" In the bottom right corner, put "Application Windows" in the top right, "Mission control" in the bottom left and "Launchpad" in the top left, and then force these settings to set of computers, what is the best way to accomplish this?

I know this information lives in the com.apple.dock plist, but my attempts to "defaults write" to this file via script doesn't seem to produce any changes.

It seems like the script would be something along the lines of this, but I don't know what variable you would use to st the hot corners selections

sudo defaults write /Users/$USER/Library/Preferences/com.apple.dock wvous-tl-corner

 

Any help or info would be super appreciated!

5 REPLIES 5

PaulHazelden
Valued Contributor

They are integers. so on the end of your line would be something like 

-int 5

I found the numbers etc by setting them up on an account, and then using defaults read to inspect the plist
so 

wvous-tr-corner -int 5

and

wvous-tr-modifier -int 0

Will turn on the screensaver if you go to the top right corner. From what I recall they go in pairs.

There is an article in here https://community.jamf.com/t5/jamf-pro/systematically-configure-hot-corners/m-p/86516#M75633

Lists them all.

 

@PaulHazelden  - Thank you for taking the time to respond to my post. Management hasn't defined the user experience just yet, but in my testing when I set the Integer values in my script, it just clears out whatever is currently set and doesn't replace them with the new values. This what I have cobbled together, am I doing something wrong?

 

#!/bin/bash
user=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
defaults write /Users/$user/Library/Preferences/com.apple.dock.plist wvous-tl-corner -int 4
defaults write /Users/$user/Library/Preferences/com.apple.dock.plist wvous-tl-modifier -int 0
killall Dock

  

PaulHazelden
Valued Contributor

I have just tested it on a M1 Mac running Monterey, and it works just fine. Script I used was pretty much the same as you have there. 

If your script is running as the User, then you do not need to put in the 

/Users/$user/Library/Preferences/

But other than that the script was the same as yours.

I see, sorry I am bit new to the JAMF admin stuff. If I set the script to run in a policy through JAMF, it's going to run as the root account right? Or does the script know to the run as the logged in user? Or is this something that can be set in the actual policy? 

PaulHazelden
Valued Contributor

Running from Jamf, it will run as root.

Looking at your script above, then if you run this from Jamf, you will need to sudo the 2 defaults lines.

#!/bin/bash

user=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )

sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock.plist wvous-tl-corner -int 4

sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock.plist wvous-tl-modifier -int 0

killall Dock

You can get the script to run as the User, by creating the script and a LaunchAgent to run it. But this will then run every time the user logs in. If you want to force the settings on the User, this is a good way to go. They can change it, but everytime they log in it will rest, I find after a few tries most Users give up and leave it alone.