OSX make command line app show icon in dock while running

953 views Asked by At

I have a simple command line app

#include <unistd.h>

int main(int argc, const char* argv[]) {
  sleep(100);
  return 0;
}

Is it possible to make that command line app show an icon in the dock while it's running or do I have to turn it into a full on app package?

1

There are 1 answers

2
Ken Thomases On BEST ANSWER

Given that the app creates a modal dialog, I assume it's using Cocoa. In that case, you can do [[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular] at the point where you display the dialog.

You should be aware that the Dock may show an odd icon. Prior to Yosemite, unbundled executables got a generic icon that looks a bit like a terminal window with the word "exec" in it. The title would be the name of the executable. In Yosemite, the Dock icon for an unbundled executable will be the icon of the folder/directory containing the executable. Its title will be that folder's name, too. (As far as I'm concerned, this is a terrible decision on Apple's part but what are you going to do?)