Skip to content

Instantly share code, notes, and snippets.

@jpouellet
Created November 3, 2014 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpouellet/56533dcc2b5a907a8440 to your computer and use it in GitHub Desktop.
Save jpouellet/56533dcc2b5a907a8440 to your computer and use it in GitHub Desktop.
OS X text status-item
#include <AppKit/AppKit.h>
#include <stdio.h>
#include <signal.h>
static void
handler(int sig __attribute((unused)))
{
close(STDIN_FILENO);
}
int
main()
{
char *line = NULL;
size_t size = 0;
[NSApplication sharedApplication];
NSStatusBar *bar = [NSStatusBar systemStatusBar];
NSStatusItem *item = [bar statusItemWithLength:NSVariableStatusItemLength];
signal(SIGINT, handler);
signal(SIGQUIT, handler);
signal(SIGABRT, handler);
while (getline(&line, &size, stdin) != -1)
[item setTitle:[NSString stringWithUTF8String:line]];
[bar removeStatusItem:item];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment