Custom Dock Icon & dockutil

gskibum
Contributor III

I'm using dockutil and loving it. But I'm hoping to accomplish one thing that may not be possible: Is it possible (with dockutil or otherwise), to add a network share point with a custom icon?

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Yes, but the share has to be mounted first for it to pick up the icon.
With one mounted in the standard /Volumes/ path, just run

dockutil --add /Volumes/VolName

It will end up at the end of the Dock in folders section, complete with the icon. It will act to mount the share if not mounted when the Dock icon is clicked on, provided it can authenticate, or will prompt for authentication I believe.
To my knowledge, if you try to add it in without the share mounted, it will either fail if you use a direct path, or if you use something like smb://path/to/share then it gets added in with a generic globe icon.

Unless by "custom icon" you meant adding in a share and customizing the icon to something other than its real icon? if so, I don't think that's possible, but maybe explore Applescript to see if there's some way with that.

View solution in original post

6 REPLIES 6

mm2270
Legendary Contributor III

Yes, but the share has to be mounted first for it to pick up the icon.
With one mounted in the standard /Volumes/ path, just run

dockutil --add /Volumes/VolName

It will end up at the end of the Dock in folders section, complete with the icon. It will act to mount the share if not mounted when the Dock icon is clicked on, provided it can authenticate, or will prompt for authentication I believe.
To my knowledge, if you try to add it in without the share mounted, it will either fail if you use a direct path, or if you use something like smb://path/to/share then it gets added in with a generic globe icon.

Unless by "custom icon" you meant adding in a share and customizing the icon to something other than its real icon? if so, I don't think that's possible, but maybe explore Applescript to see if there's some way with that.

bentoms
Release Candidate Programs Tester

@gskibum how do you want the icon to behave?

By adding a share that's not mounted you'll get the generic icon. Once the share is mounted it will show the contents.

So not sure how the icon is expected/wanted to work.

If it's just an icon that a user clicks then opens a share, that can be done via an AppleScript app.

gskibum
Contributor III

Thank you both for your replies. Been busy the last couple of days. I'll write a more detailed response hopefully tomorrow.

khurram
Contributor III

We are using dockutil to go to a https URL. Couldn't figure out 'yet' how to change the icon to the relevant link.

Imagine having 10 URLs in the dock and the user has to hover over each one to figure out which one to click :)

remus
New Contributor III

@khurram We are doing something along these lines…

#!/bin/sh
## postinstall

# Generate a help and support url file.
user=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ { print $3 }' )
DOCK_UTIL="/tmp/dockutil"
HelpURL="/tmp/website.webloc"
python -c 'import Cocoa; Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_("/tmp/QMarkB.png"), "/tmp/website.webloc", 0)'
# Add it to the dock
sudo -u $user $DOCK_UTIL --add $HelpURL --section others


exit 0      ## Success
exit 1      ## Failure

dstranathan
Valued Contributor II

@remus I noticed you are running the dockutil binary in the user context, is this how you usually manage your user's Dock from Jamf scripts? Does this work in macOS 10.15 Catalina?

Example: sudo -u $user $DOCK_UTIL