I have an app that may get launched with current user's or with root permissions.
In fact, there's the possibility that the app runs twice at the same time - once under the current user and once as root.
I like to inform the user when the app is running under root. Currently, I show this in its window title, but I'd prefer to change the app's name so that it reads "Appname (Root)" where appropriate. That way, the name would appear both in the menu bar and in the Dock with this "root" info, and it would allow the user to tell which of the two app instances in the Dock is the root version.
Does someone know if the app name can be changed by code, i.e. by the app itself, or by its launcher?
If not, my only option appears to be adding a badge to the Dock icon that says "root", but that's my last resort, as it won't work for the menu bar nor for other tools that display the app names (i.e. other app launchers such as DragThing).
On your Mac, use Dock & Menu Bar System Preferences to change the appearance of the Dock, and to select items to show in the menu bar and in Control Center. To change these preferences, choose Apple menu > System Preferences, then click Dock & Menu Bar .
The Dock on the Mac desktop is a convenient place to access apps and features that you're likely to use every day—for example, Launchpad and the Trash. The Dock can show up to three recently used apps that aren't already in it and a folder for items you download from the internet.
After pulling up Finder > Applications, find the app you'd like to change the icon for. Right click and select Get Info or use the keyboard shortcut command + I. Now just drag the new image you want to use on top of the existing icon (you can also copy the new image then paste it onto the existing icon).
…there are at least five application names floating around, at least in concept: (1) the file name the Finder sees, which in the case of an application package is the package (bundle) name; (2) the name of the executable inside the package, (3) the long name used in many places for display purposes only; (4) the short name used as the application menu title and in a few other places where a long name won’t fit for display purposes; and (5) the process name of a running application. They aren’t always the same, especially in Microsoft and Adobe products.
—Bill Cheeseman
From what I can tell, the name in the dock is the name of the application bundle (sans ".app") on the filesystem.
The value under the CFBundleName
key in info.plist is what shows up in the menubar.
As far as I know, changing either these at runtime isn't going to work… but what you can do is have two versions of your app, a root and non-root version, inside your user-facing .app bundle. When the user-facing app is launched, it checks if it's running as root or not, and launches the appropriate copy of the real app, which has theCFBundleName
and file-name you want.
I wish I knew of a more elegant solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With