title: Is it possible to programmatically change the volume icon on a mounted drive on Mac OS X?
body: <p>I want to programmatically change the volume icon for a stacked file system implemented using <a href="http://osxfuse.github.com" rel="noreferrer">OSXFUSE</a> (formerly MacFUSE). The icon needs to reflect the state of a mounted file system. </p>
  
  <p>The approach that I have been trying to get working is to map requests for /.VolumeIcon.icns to the appropriate icon in the application bundle. Then sending change notifications to the file system for the actual path (path) and the mount path (mountPath).</p>
  
  <pre><code>    [[NSWorkspace sharedWorkspace] noteFileSystemChanged: @"/Volumes"]; 
      [[NSWorkspace sharedWorkspace] noteFileSystemChanged: [mountPath stringByDeletingLastPathComponent]];
      [[NSWorkspace sharedWorkspace] noteFileSystemChanged: mountPath];
      [[NSWorkspace sharedWorkspace] noteFileSystemChanged: [path stringByDeletingLastPathComponent]];
      [[NSWorkspace sharedWorkspace] noteFileSystemChanged: path];
  
      FNNotifyByPath([[[mountPath stringByDeletingLastPathComponent] dataUsingEncoding:NSUTF8StringEncoding] bytes], kFNDirectoryModifiedMessage, kNilOptions);
      FNNotifyByPath([[[path stringByDeletingLastPathComponent] dataUsingEncoding:NSUTF8StringEncoding] bytes], kFNDirectoryModifiedMessage, kNilOptions);
      FNNotifyByPath([[@"/Volumes" dataUsingEncoding:NSUTF8StringEncoding] bytes], kFNDirectoryModifiedMessage, kNilOptions);
  </code></pre>
  
  <p>Stepping through the debugger I can see this code being hit but the code to map the /.VolumeIcon.icns gets called infrequently and never in response to these notifications.</p>