Skip to main content
Answer

Custom Dock Icon & dockutil

  • February 19, 2016
  • 6 replies
  • 73 views

gskibum
Forum|alt.badge.img+13

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?

Best answer by mm2270

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.

6 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • Answer
  • February 19, 2016

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
Forum|alt.badge.img+35
  • Hall of Fame
  • February 20, 2016

@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
Forum|alt.badge.img+13
  • Author
  • Valued Contributor
  • February 24, 2016

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


Forum|alt.badge.img+12
  • Valued Contributor
  • November 9, 2020

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
Forum|alt.badge.img+5
  • Contributor
  • November 10, 2020

@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
Forum|alt.badge.img+19
  • Valued Contributor
  • November 19, 2020

@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