Posted on 03-13-2019 04:59 AM
I'm trying to set default settings for dock when users log in. As I can't chose non-system apps in Dock settings in Configuration Profiles I'm doing it through an ongoing policy upon login.
When the users logs in the screen flashes and the changes in Dock are not applied. When I check the logs it says completed.
I tried the policy upon recurring checkin and it works just fine.
How do I make it work when user logs in?
Posted on 03-13-2019 05:29 AM
Try using Dockutil - great tool. https://github.com/kcrawford/dockutil
create the shell script in jamf, create a policy (very similar to yours) ie. ongoing @ login.
I run 2 back to back. 1 to remove & 1 to add. I do this because I also have separate policies utilizing the scripts with custom event triggers set for them.
This is used for local user accounts, should work for guest account as well
Script 1. Removal of Dock Configurations (Runs 'Before')
#!/bin/bash
# Removes Dock Items
###########################################################
DOCKUTIL_BINARY="/DockUtilLocation/dockutil"
user=`stat -f "%Su" /dev/console`
#Remove Apple Defaults
$DOCKUTIL_BINARY --remove all /Users/$user
exit 0
Script 2. Customize your Dock (Runs 'After')
#!/bin/bash
# Adds Dock Items
###########################################################
DOCKUTIL_BINARY="/DockUtilLocation/dockutil"
user=`stat -f "%Su" /dev/console`
# Addition of Guest User Specific Dock Applications
###########################################################
$DOCKUTIL_BINARY --add "/Applications/App Store.app" --no-restart /Users/$user
$DOCKUTIL_BINARY --add "/Applications/Safari.app" --no-restart /Users/$user
$DOCKUTIL_BINARY --add "/Applications/Google Chrome.app" --no-restart /Users/$user
$DOCKUTIL_BINARY --add "/Applications/Photos.app" --no-restart /Users/$user
$DOCKUTIL_BINARY --add "/Applications/iTunes.app" --no-restart /Users/$user
$DOCKUTIL_BINARY --add "/Applications/Self Service.app" --no-restart /Users/$user
$DOCKUTIL_BINARY --add "/Applications/System Preferences.app" /Users/$user
exit 0
Posted on 03-13-2019 06:26 AM
Thanks @Hugonaut. I'm actually looking for a method to debug the policy and see why it works on checkin and not login
Posted on 03-13-2019 06:35 AM
These two screenshots show the difference between when the policy runs at log in vs check in.
The one with steps which actually works is upon check in
Posted on 12-23-2019 06:01 PM
I'm working on this same problem now with Catalina. Tried the scripts @Hugonaut provided but can't seem to get them to work. I am getting output that says users/root is not a home directory nor can it find a plist. Have you had any luck getting this to work on the guest account?
Posted on 03-03-2020 10:12 AM
Hey Guys, I just stumbled across this thread and if you're still having dock problems, I might be able to help.
Firstly, if you want to change the guest account (and new user login) dock, particularly if you're just adding items, then why don't you point dockutil at the default dock template. Then you'd only have to run it once, and not for each user on login.
For example:
#!/bin/bash
/usr/local/bin/dockutil --add "/Applications/App Store.app" --no-restart '/System/Library/User Template/English.lproj'
exit
This will change the template (in this case for english language users) which affects new accounts and the guest user.
It won't affect current users and if the guest user is logged in, you'll need to log out before the changes take effect.
If you need to hit existing users as well, try adding another dockutil line and use the --allhomes flag
Another method is to use Composer to pkg up a pre-made dock template and push it out. I've attached a screenshot as an example. If you go this route, you'll need to open your plist and pull out the entry for the Downloads folder before packaging it up.
I've verified that both of these work (at least in our environment) on 10.15.3