Set Hot Corners with Configuration Profile

jacopo_pulici
Contributor

Hi,
I'm struggling with Mission Control's hot corners.
I created a Config Profile from a cleaned com.apple.dock.plist. Everything works, the settings are applied.
The problem is that if the users try to change these hot corners, they get reverted to the ones I set up in the Config Profile.
I used MCXtoProfile with the "--once" option and uploaded the profile but it does the same.
I'd like to avoid the use of a dedicated script and instead use the config profile.
Any tips? Any idea how can set them "once"?
Below the plist file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>wvous-bl-corner</key>
    <integer>4</integer>
    <key>wvous-bl-modifier</key>
    <integer>0</integer>
    <key>wvous-br-corner</key>
    <integer>5</integer>
    <key>wvous-br-modifier</key>
    <integer>0</integer>
    <key>wvous-tr-corner</key>
    <integer>2</integer>
    <key>wvous-tr-modifier</key>
    <integer>0</integer>
</dict>
</plist>
5 REPLIES 5

MrP
Contributor III

Do it via script. I'm doing something like this, except allowing users to set whatever they want but never allowing A: adding a disable screensaver/lockscreen hotcorner, and B: removal of the lock/screensaver hotcorner.

# Get user logged into console and put into variable "user"
user=`ls -l /dev/console | cut -d " " -f 4`
    ###
    #   Set hotcorner actions.  Disable "Disable Screen Saver" when found.
    ###
    ## The following are the values of each option in the GUI
    # Start Screen Saver = 5
    #   Modifier = 0
    # Disable Screen Saver = 6
    #   Modifier = 0
    # Mission Control = 2
    #   Modifier = 0
    # Application Windows = 3
    #   Modifier = 0
    # Desktop = 4
    #   Modifier = 0
    # Dashboard = 7
    #   Modifier = 0
    # Notification Center = 12
    #   Modifier = 0
    # Launchpad = 11 
    #   Modifier = 0
    # Put Display to Sleep = 10
    #   Modifier = 0
    # None = 1
    #   Modifier = 1048576
    ##
    a=`defaults read /Users/$user/Library/Preferences/com.apple.dock.plist | grep  "-corner""`
    for corner in $a
    do
     cornerval=`echo $corner | cut -d "=" -f2 | cut -d ";" -f1 | sed 's/ //g'`
     corner=`echo $corner | cut -d """ -f 2 | cut -d "-" -f 1,2`
     if [ "$cornerval" = "6" ];
     then
        echo User:Hotcorner - Disable screensaver found on $corner, fixing...
        # Setting the corner action to 1(None)
        sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock.plist $corner-corner -int 1
        sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock.plist $corner-modifier -int 1048576
        changesmade="yes"
     fi
    done
    ##
    #  Set bottom left corner of the screen "hotcorner" action to immediately invoke the  screensaver
    ##
    needsFixed=0
    defaults read /Users/$user/Library/Preferences/com.apple.dock.plist| grep bl-corner | grep 5 > /dev/null
    if [ $? != 0 ]; then needsFixed=1;fi
    defaults read /Users/$user/Library/Preferences/com.apple.dock.plist | grep bl-modifier | grep -i "s0;" > /dev/null
    if [ $? != 0 ]; then needsFixed=1;fi
    if [ $needsFixed == 1 ];
    then
        sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock.plist wvous-bl-corner -int 5
        sudo -u $user defaults write /Users/$user/Library/Preferences/com.apple.dock.plist wvous-bl-modifier -int 0
        changesmade="yes"
    fi

    # If changes were made then the dock needs to be restarted for them to take affect
    if [ "$changesmade" = "yes" ]; then sudo killall -hup cfprefsd; sudo killall -hup Dock; fi

fsck8
New Contributor

I did something a little different. In the example below it sets the lower left (screen saver start) and right hot corners (screensaver delay). Users can't change the two hot corners I set but can change the other two.

  1. Make a copy of com.apple.dock.plist in the user library. This plist has the details we need about the Hot Corners.
  2. Open the copy of the plist in Xcode.
  3. Remove all the lines except the wvous-bl-corner and wvous-br.corner
  4. Save
  5. Export and save the File Format as Property List XML
  6. Create a new Configuration Profile in the JSS
  7. Click Custom Settings
  8. Enter com.apple.dock as the Preference Domain
  9. Upload the plist

MrP
Contributor III

Sorry, just saw you'd like to avoid using a script. Where is your profile? If it's in the user's Library/Preferences folder and they have write access to it, AND you aren't re-deploying it to the user there shouldn't be any problems with the overwriting it.

jacopo_pulici
Contributor

Unfortunately not. If I set the config profile at Computer Level, the users' changes keep getting reverted.

bpavlov
Honored Contributor

This isn't specific to the dock, but rather config profiles and the JSS. I would avoid using any SET ONCE custom config profiles through Casper. In my testing a year ago or so, the preference being managed "once" will get reset on reboot. Not a good experience obviously. This may also be the case if you deploy a custom config outside of the JSS's MDM (package up the profile and install using the profiles command), but I never tested that.

I would recommend using dockutil and scripting this out even if that's not what you want to do.