Specify the Finder icon with Avahi

Finder shared area icons Yesterday, I blogged about my various issues setting up Apple Filesharing on the Debian virtual server I’ve got running in Parallels. As of OS X 10.5, Leopard, the Finder has a shared area which shows the machines it’s discovered via Bonjour so you can easily connect to them. Today I got bored of having the default icon for my server, bizarrely Apple have set the default icon as a Cinema Display (what?), I wanted something more visually informative. After some Googling around and a bit of configuration on the Debian side, the server is now using an XServe icon.

This all takes advantage of an enhancement Apple added in Leopard, which allows a savvy server to specify its type and model. Leopard then uses one of its icons for various Mac hardware to represent that server.

Finder shared area icons The MacRumours forums provided the solution to how to configure Avahi to specify the hardware type in it’s broadcast announcement. Before starting to mess around, I had the following text in my Avahi service definition at /etc/avahi/services/afpd.service (N.B. that path is for a Debian machine, other distros may put their service definitions elsewhere):

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
</service-group>

After my alterations, the file read (I’ve emboldened the new portion):

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=RackMac</txt-record>
</service>
</service-group>

The model information I’ve used, sets the icon to an XServe icon (see the screenshot above). You can determine the model text you need to broadcast for other icons by digging through the Plist at /System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist.


Comments

26 responses to “Specify the Finder icon with Avahi”

  1. Eldrik Avatar
    Eldrik

    Hi,

    Exactly what i was looking for!! Now my NAS shows up as a Xserve device instead of an iMac :-)

    Greetz
    Eldrik

  2. Hi Eldrik – Glad to be of service!

  3. […] Me « Specify the Finder icon with Avahi MyOpenID seemed very slow this… […]

  4. Excellent tip! Thanks a lot!

    For the lazy ones, these are other possible models:

    Xserve (same a RackMac)
    PowerBook
    PowerMac
    Macmini
    iMac
    MacBook
    MacBookPro
    MacBookAir
    MacPro
    AppleTV1,1
    AirPort

    There is a lot of submodels defined. But for those you’ll have to look in the plist.

  5. Is there a possibility of editing this .plist file and adding diff models? I’m looking at the .plist file right now and testing it…

    1. Mark Ikemoto Avatar
      Mark Ikemoto

      Hi Nils,

      Did you ever get your tests with modifying the Info.plist file to work? I want to add a custom icon to Finder for a remote device mounted onto my Snow Leopard Mac. My device’s Avahi/AFP service config contains “model=DeviceX”. And I’ve copied my DeviceX.icns file into /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources. But I haven’t figured out what changes I need to make to the Info.plist. If you have any suggestions for me, let me know. Thanks.

      By the way, if anyone else has suggestions for me, I’d appreciate hearing them.

      Mark

  6. simonwheatley Avatar
    simonwheatley

    Hi Nils… let us know how you get on with editing the .plist file, please!

  7. Just FYI for anyone who may be curious: to show a Quicksilver instead of a Graphite PowerMac, use PowerMac3,5

  8. […] I streamlined my Linux avahi config using some pointers here, suggested to me by George the commenter on my above linked […]

  9. […] found this article http://www.simonwheatley.co.uk/2008/04/06/avahi-finder-icons/ and found it very nice to do. But it didn’t seem to work on OpenSolaris… but […]

  10. Does anyone know how to accomplish this with mDNSresponder instead of Avahi ?

    FreeNAS is forced to use mDNSresponder due to storage constraints for the emmbedded version so Avahi is out of the question..

    Thanks in advance,

    Adi

  11. unreality Avatar
    unreality

    Adi, you can do the same with mDNSresponder by adding the following to the config file:

    your-machines-hostname
    _device-info._tcp.
    1
    model=Xserve

    1. Hi !

      Where is the config file located ? On which position should I add ? When I change the file in /etc/rc.d/ or in /var/etc/ the changes are gone after rebooting the machine.

      Thanks

  12. You can also let your device come up as a nifty iPhone icon by using the iPhone2,1 identifier. Very nice :P

  13. […] aus diesem Mac OS X Hint, Icon-Pack aus diesem Thread des Cube-Owner-Forums, Avahi-Icon-Zauber von Simon Wheatly) einfach unter einem anderen Namen gespeichert, etwa com.apple.powermac-g4-graphite.original.icns […]

  14. […] This blog post explains the process and this comment describes the various device types you can specify. […]

  15. […] want to use your own icon for it or the one’s made by me provided within this article. Thanks toSimon Wheatley for figuring this out. Additionally you can use these models in this file: RackMac (same as […]

  16. Yvan BARTHÉLEMY Avatar
    Yvan BARTHÉLEMY

    Here are the Models I found (there are other machine icons for Mac mini servers but there are no associated model codes):
    – Windows
    – Macintosh
    – PowerBook (Titanium) PowerBook6,1 (G4 12″) PowerBook5,2 (G4 15″) PowerBook5,1 (G4 17″) PowerBook 6,3 (iBook G4)
    – PowerMac (G4) PowerMac3,5 (G4 QS) PowerMac3,6 (G4 MDD) PowerMac7,2 (G5)
    – Xserve
    – Macmini1,1 Macmini4,1 (Unibody)
    – PowerMac4,4 (eMac)
    – PowerMac4,2 (iMac G4 15″) PowerMac4,5 (iMac G4 17″) PowerMac6,3 (iMac G4 20″) PowerMac8,1 (iMac G5 17″)
    – PowerMac12,1 (iMac G5 iSight 17″) iMac4,1 (iMac G5 iSight 24″)
    – iMac7,1 (Alu 20″) iMac9,1 (Alu 24″) iMac10,1 (Alu 27″)
    – MacBook1,1 (White) MacBook1,1,Black MacBook5,1 (Unibody) MacBook6,1 (Unibody Plastic)
    – MacBookPro1,1 (15″) MacBookPro1,2 (17″) MacBookPro5,1 (15″ Unibody) MacBookPro5,2 (17″ Unibody) MacBookPro5,5 (13″ Unibody)
    – MacBookAir1,1 MacBookAir3,1 (11″ Unibody) MacBookAir3,2 (13″ Unibody)
    – MacPro
    – AppleTV
    – iPhone1,1 iPhone1,2 (3G) iPhone2,1 (3GS) iPhone3,1 (4)
    – iPod1,1 (Touch) iPod2,1 (Touch 2 & 3) iPod4,1 (Touch 4)
    – iPad1,1
    – AirPort
    – TimeCapsule

    1. Hi

      Thanks for the input :-) Up and running with Avahi and FreeBSD 9.0.

      Take a look at my site – I have completed the list of supported “models” by running through the plist file on a MacOSX Lion.

      http://veloce.dk/2012/01/24/change-the-icon-of-a-freebsd-served-afp-server/

    2. TimeCapsule wont work in 10.7 so I guess neither in 10.8
      It’s TimeCapsule6 (and I’ve saw that working on my AFP server)

  17. Hi,

    thanks for all the infos found here. I only like to add that it is not necessary to place the host icon information in the afpd.service file. It also works if you put it in an own file.


    %h

    _device-info._tcp
    0
    model=RackMac

  18. […] other than an iMac by modifying the afpt.service file for Avahi. (Avahi Service Definition file) Specify the Finder icon with Avahi | Simon Wheatley Normally this file exists in /etc/avahi/services/afpd.service However, that is for linux […]

  19. William Avatar
    William

    Which config file would one edit to make OS X broadcast as a different machine? i.e. a Mac Mini to be seen a “Rack Mac” by other Macs on the network? I can’t find info on that anywhere! Many thanks in advance for anyone who knows!

  20. Hi! I know that this is an ancient post, but, on the other hand, it’s also true that the Avahi configuration hasn’t changed!

    I have a simple question… why <port>0</port>? I mean, why port zero… instead of any other port?

    I’m just curious, that’s all. As I type this, it’s 2022, and Apple has abandoned Apple File Protocol (AFP) in favour of Samba. Nevertheless, Avahi is still being used as a discovery service, so the article itself continues to be valid for Samba as well (with the necessary changes, that is).

Leave a Reply to Tienne Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.