On Fri, May 10, 2013 at 8:14 AM, Stephen J. Butler <stephen.but...@gmail.com> wrote: > I didn't look at your code, but... one thing to note is that it is > absolutely not secure to run your daemon as root and display a GUI. I hope > that isn't part of your plan.
No, the "daemon" is the picture viewer itself. It is hidden most of the time. When you run "xqiv image1.jpg image2.jpg" from command-line, then the "daemon" pops and displays image1.jpg. You can press "escape" to hide the application or "space" to see image2.jpg. There is no reason to run it as root. The idea is to let the "daeomon" - picture windowed application start from command-line tool xqiv if it hasn't started yet. > > The OS X way to do this sort of thing is to write your daemon as a Launch > Agent (since it needs to interact with a logged in user). Using a launchd > plist file, you can tell launchd to monitor a TCP port/unix socket/mach > port/watched directory/etc and run your agent when there is activity. This > is nice since your agent can exit when it doesn't have anything to do, and > the system will regain resources. > > Good place to start would be here: > > http://developer.apple.com/library/mac/#technotes/tn2083/_index.html > > And then here: > > http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html#//apple_ref/doc/uid/10000172i-SW1-SW1 > thanks for the hint, I have to check this first. However at first glance it seems I have to create 2 applications. Daemon and cmd-line app. My idea is to have just one app which behaves as a "daemon" in case the deamon doesn't run yet and/or as a cmd-line tool if the daemon runs. But maybe it is not the way. To explain my motivation, I grown on linux bases. I saw Mac and I like it, I bought it. However, command-line is something crucial for me. I like cmd-line + keyboard much more then Finder + mouse. Am I strange? :-) > On Wed, May 8, 2013 at 5:41 AM, Ondrej Holecek <ondrej.hole...@gmail.com> > wrote: >> >> Hi, >> >> I'm creating a picture viewer controlled from command-line (I call it >> xqiv which sould be an equivalent to http://www.klografx.net/qiv/ on >> linux). However, xqiv is slightly different. >> >> You have to run xqiv-daemon, which is the window-based application >> which handles global notifications sent by xqiv-command-line and >> displays the image(s). My idea is to have just one application xqiv >> which acts as both daemon and/or command-line tool together. If you >> run xqiv and the deamon is not running yet it forks and run the >> daemon. Parent would act as a commandline tool and child would be the >> daemon which stay on background. Parent would sent a notification to >> the forked child what image to display and exit. If the daemon is >> already running, then fork is not needed and it would just sent the >> notification. >> >> The question is, how to force NSApplicationMain() to run in child. >> >> The basic idea is to do something like this: >> >> if (already running) { >> return cmd_main(argc, argv); >> } else { >> if (fork() == 0) { >> return NSApplicationMain(argc, (const char **)argv); >> } else { >> return cmd_main(argc, argv); >> } >> } >> >> The real code is there: http://pastebin.com/7LD2dPK8 >> >> When I run NSApplicationMain() in child process, it simply does >> nothing. What's wrong? >> >> I have already functional application there: >> https://github.com/smrt28/xqiv >> >> It is functional but daemon and command-line tool are two applications. >> >> let me note I'm the beginner in objc/cocoa development and this is my >> very first cocoa application. >> >> thanks, >> >> Ondrej >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> >> https://lists.apple.com/mailman/options/cocoa-dev/stephen.butler%40gmail.com >> >> This email sent to stephen.but...@gmail.com > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com