Firefox allows you to run multiple profiles in parallel, which puts multiple icons in the dock. This gets confusing, so my users of my Firefox addon, free open source, requested two features: One to change the icon per their selection per profile. And also they requested that when they do "Keep in Dock" those items, clicking them to start the browser in that profile fails. (It just launches the default profile.) So I've devised a method that will allow them to launch the respective profile on click of "Kept in Dock" icons, on computer restart and window restore, and "Open at Login".
An issue came up because I can now edit the information of persisted dock icons and refresh the dock by editing /Users/noit/Library/Preferences/com.apple.dock.plist
. However the non-persisted dock icons are not editable through this method, and I need to set these properties so it opens properly, when a user does "Keep in Dock", restart browser, or restart computer with "open windows from last time".
Here is my current problem:
I'm launching Firefox with a .app
I made at /Users/noit/Desktop/dev.app
. The shell script in my .app
runs this shell:
#!/bin/sh\nexec /Applications/Firefox.app/Contents/MacOS/firefox -P "Default Profile" -no-remote
How to control the bundle-identifier
(NOT the CFBundleString
but the bundle-string
that gets written to com.apple.dock.plist
) and file-data :: _CFURLString
of my NSApplication via objective-c or core-foundation?
The reason I need this is because certain action sequences change the bundle-string
and file-data
which causes a redundant icon to pop up in the dock. I have recorded a 3 minute screencast clearly demonstrating this current issue. This screencast clearly shows how extra icons pop up, and the below logically explains why its creating a new icon: Youtube :: Demo :: Reason I need to set bundle-identifier/_CFURLString of non-persisted app
The CFBundleIdentifier
in the info.plist
of my dev.app
is:
<key>CFBundleIdentifier</key>
<string>myCustomBundleIdenter</string>
(note: for convenience i replaced with myCustomBundleIdenter
just for this topic post, my real one is in right format)
The following is how the dock icon (/Users/noit/Library/Preferences/com.apple.dock.plist
) is reacting - and the source of my troubles.
Now when I double click my
dev.app
it opens Firefox with this info for it's dock icon with the followingbundle-identifier
andfile-data :: _CFURLString
:<dict> ... <dict> <key>bundle-identifier</key> <string>myCustomBundleIdenter</string> ... <dict> ... <key>_CFURLString</key> <string>file:///Users/noit/Desktop/dev.app/</string> ... </dict> ... </dict> ... </dict>
Now if I do
killall Dock
from terminal, it separates my icon because the dock icon is now with a changedfile-data :: _CFURLString
:<dict> ... <dict> <key>bundle-identifier</key> <string>myCustomBundleIdenter</string> ... <dict> ... <key>_CFURLString</key> <string>file:///Applications/Firefox.app/</string> ... </dict> ... </dict> ... </dict>
If I restart Firefox, say after a addon install or something then this splits my icon in dock again due to change in
bundle-identifier
back to original:<dict> ... <dict> <key>bundle-identifier</key> <string>org.mozilla.firefox</string> ... <dict> ... <key>_CFURLString</key> <string>file:///Applications/Firefox.app/</string> ... </dict> ... </dict> ... </dict>
So as we see, my aim is to keep bundle-identifier
constant at myCustomBundleIdenter
and file-data :: _CFURLString
constant at file:///Users/noit/Desktop/dev.app/
, any ideas on how to keep this stuff constant programtically via objective-c or core-foundation? So that redundant icons do not pop up, and clicking the non-persisted OR persisted icon will launch properly, even on computer restart with "Open windows from last time".
Worst case scenario, I need to just be able to set the bundle-identifier
that gets stored to the com.apple.dock.plist
, then I can use file watcher on the com.apple.dock.plist
on file changes to see if it was my bundle-string
that got "Kept in Dock" and then I can set the file-data :: _CFURLString
via edit the com.apple.dock.plist
dictionary.