Created
November 3, 2014 08:32
-
-
Save jpouellet/56533dcc2b5a907a8440 to your computer and use it in GitHub Desktop.
OS X text status-item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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