Is it possible, to change the title of my application at runtime, which is displayed in the dock?
Asked
Active
Viewed 1,793 times
4
-
Thanks Dave - I read that as "TILE of my application ... displayed in the block" when I answered. :-) I've gone ahead and deleted my answer as it's completely irrelevant. Sorry to Nobik and Diederick for the noise – Joshua Nozzi Feb 22 '10 at 18:35
-
You mean the label shown when you however over the dock icon right? Were you able to figure this one out? I'm having the same need. I can do so by renaming the .app and then toggling "Keep in Dock" on the icon, but the "Keep in Dock" toggle I can't figure out how to do purely programmatically. – Noitidart Feb 05 '15 at 15:35
2 Answers
4
You might try to change the badge label of the dock tile:
[[NSApp dockTile] setBadgeLabel:@"My custom text"]

El Developer
- 3,345
- 1
- 21
- 40

diederikh
- 25,221
- 5
- 36
- 49
-
This doesn't work, this puts a label on top of the dock icon. This doesn't change the text shown on hover of the dock icon. – Noitidart Feb 05 '15 at 15:33
1
No, it's not possible. The Dock uses the display name of the file system item for the process. For a bundled app, that's the app bundle.
That display name can be localized, but, for any given system language, that's a static property of the app bundle.

Ken Thomases
- 88,520
- 7
- 116
- 154
-
I noticed renaming the app bundle file (the top most one, the one that contains "Contents") does change the title if you toggle "Keep in Dock" or quit then relaunch the app or even if you do `killall Dock`. Is this expected behavior? However after running `killall Dock` I noticed the windows still get focused when you click the dock icon, but if you right click the dock icon the "Quit" menu item is gone, so its like semi disocciated but not fully, its weird. – Noitidart Feb 05 '15 at 15:32
-
Here's an image showing the label on hover, is there offical ways to chagne this one? http://i.imgur.com/CjytiTk.pnghttp://i.imgur.com/CjytiTk.png – Noitidart Feb 05 '15 at 23:34
-
1I understood what you were asking about and that's what my answer applies to: no, there's no way to change that title programmatically. – Ken Thomases Feb 05 '15 at 23:43
-
Hey Ken is there any non-programmatic way? Like a key/value pair in the `info.plist`? It's ok it won't take on the dock until the app is shutdown i understand that. But I just need a way to give it a text, as my .app are named a string of numbers, an id. And then I create alias file on desktop with name of "Firefox - profile name here". Thanks Ken you are so patient with people! – Noitidart Mar 01 '15 at 03:08
-
1The Dock uses the display name of the file system item (app bundle, in this case). The only way to affect the title it shows is to change the name of the app bundle. At least, that's the only way I've ever been able to find. – Ken Thomases Mar 01 '15 at 03:32
-
Thanks so much for sharing your answer so fast. Darn ok this will make things tricky, now every time my user renames the profile I'll have to rename the .app and remake the alias's that i can find. And also check if it is persited in dock.plist and update its entry if running. Ah headache already ahaha – Noitidart Mar 01 '15 at 03:39
-
Oh man if its running and not persisted, doing a killall dock detaches associated windows. and its not in dock.plist yikes no idea on how to handle that situation – Noitidart Mar 01 '15 at 03:46
-
Oh super nice i dont have to go through the dock.plist if its not running. And now for running Im thinking ill have to update the NSWindow app names somehow or something – Noitidart Mar 01 '15 at 03:51
-
Oh maybe change the `bundleURL` and `executableURL` of `NSRunningApplication`, just posting here in case you know its not worth a shot or maybe it is :P https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSRunningApplication_Class/index.html#//apple_ref/doc/uid/TP40008799-CH1-SW19 cuz i do this via jsctypes which takes a bit of time to write out :P – Noitidart Mar 01 '15 at 04:01