run gui LaunchAgent from launchd
Not having any luck running a LaunchAgent containing a gui from launchd. Is this simply not possible?
bobkells@steelcape.com <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 3:13 PM -0800):
Not having any luck running a LaunchAgent containing a gui from launchd. Is this simply not possible?
I'm running both GUI and non-GUI agents (~/Library/LaunchAgents) using launchd. Try telling us what your .plist contains and describe the problems your having. -- James Bucanek
Thanks for getting back to me. Here is some info about the plist and the app. It feels like I am missing something obvious...bob I have been running a cocoa-app with a simple gui two different ways. 1. Run from a script file at the cmd-line. This runs fine. I check various fields by tailing the system.log. The alert panels appear as I expect. 2. Run by the same script file, which is run by launchd. The app is recognized and starts up. I can see the same fields in the tailed system log. The app run ok until it hangs in the call to [oAlert runModal]; I also try to run the app directly from launchd. I get the same effect as in #2 above. Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls. I have tried various permutations, such as the full path in the Program-key value. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <true/> <key>Label</key> <string>net.aquaconnect.acnotify</string> <key>OnDemand</key> <true/> <key>Program</key> <string>ACNotify</string> <key>ProgramArguments</key> <array> <string>/Users/bob/AppSupport/ACNotify.app/Contents/ MacOS/ACNotify</string> <string>-d</string> <string>4</string> <string>-p</string> <string>/Users/bob/LaunchScriptTest</string> </array> <key>QueueDirectories</key> <array> <string>/Users/bob/LaunchScriptTest</string> </array> <key>ServiceDescription</key> <string>Aquaconnect Alert Notification Manager</string> <key>WorkingDirectory</key> <string>/Users/bob/AppSupport/ACNotify.app/Contents/MacOS</ string> </dict> </plist> Here are code snippets of the app being called. This lists all of the gui-related calls in the app. I have a custom object instantiated in IB, and connected to File's Owner for some delegate methods. Again, I have tried various permutation... Creating NSAlert via the init/alloc; removed the NSPanel calls. Have added LSUIElement-key with a value of 1 to the Info.plist of the xcode project. I did have retain/releases with the NSAlert, but removed them as the doc says it is autoreleased. // ------------------------------------------------------------------------ ---- int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); } // ------------------------------------------------------------------------ ---- - (void) applicationDidFinishLaunching: (NSNotification *) aNotification // set focus to NSApp (forces its windows on top of all other windows) [NSApp activateIgnoringOtherApps: YES]; // ---------------------------------------------------------------- // create NSAlert object oAlert = [NSAlert alertWithMessageText: msgTitle defaultButton: b1Title alternateButton: nil otherButton: nil informativeTextWithFormat: msgInfo]; [oAlert setAlertStyle: NSWarningAlertStyle]; oPanel = [oAlert window]; [oPanel orderFront: self]; *****HERE IS WHERE THE CODE HANGS***** iButton = [oAlert runModal]; [NSApp terminate: self]; // ------------------------------------------------------------------------ ---- - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) mApp return (NSTerminateNow); // ------------------------------------------------------------------------ ---- - (void) applicationWillTerminate: (NSNotification *) aNotification application cleanup On Dec 14, 2007, at 3:30 PM, James Bucanek wrote:
bobkells@steelcape.com <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 3:13 PM -0800):
Not having any luck running a LaunchAgent containing a gui from launchd. Is this simply not possible?
I'm running both GUI and non-GUI agents (~/Library/LaunchAgents) using launchd.
Try telling us what your .plist contains and describe the problems your having.
-- James Bucanek
Bob Kells <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 5:44 PM -0800):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <true/> <key>Label</key> <string>net.aquaconnect.acnotify</string> <key>OnDemand</key> <true/> <key>Program</key> <string>ACNotify</string> <key>ProgramArguments</key> <array> <string>/Users/bob/AppSupport/ACNotify.app/Contents/MacOS/ACNotify</string> <string>-d</string> <string>4</string> <string>-p</string> <string>/Users/bob/LaunchScriptTest</string> </array> <key>QueueDirectories</key> <array> <string>/Users/bob/LaunchScriptTest</string> </array> <key>ServiceDescription</key> <string>Aquaconnect Alert Notification Manager</string> <key>WorkingDirectory</key> <string>/Users/bob/AppSupport/ACNotify.app/Contents/MacOS</string> </dict> </plist>
While there doesn't seem to be anything "wrong" with this plist, I've found that simpler is better when trying to debug these things. Since your first argument is already the complete path to the application binary, I'd eliminate both the Program and WorkingDirectory keys, since they're redundant. Bob Kells <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 6:18 PM -0800):
launchctl load -w net.aquaconnect.acnotify.plist launchctl unload -w net.aquaconnect.acnotify.plist launchctl list
Also, I have root priv when doing this.
You should be issuing user-agent requests as the user, not root. You want the application to be loaded/executed for ~ not root. Bob Kells <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 6:26 PM -0800):
That gives me an "illegal option" message. Am I running an old version? How can I tell?
The -S option was added is Leopard. -- James Bucanek
James Bucanek <mailto:subscriber@gloaming.com> wrote (Saturday, December 15, 2007 10:37 PM -0700):
Bob Kells <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 6:26 PM -0800):
That gives me an "illegal option" message. Am I running an old version? How can I tell?
The -S option was added is Leopard.
Footnote: For GUI applications, LaunchAgents are essentially broken in Tiger. This will only work in Leopard. If you're trying to do this in Tiger, you'll need to use Login Items. -- James Bucanek
Thanks for getting back to me. Here is some info about the plist. I had to cut the app gui-calls as the message was too big. It feels like I am missing something obvious...bob I have been running a cocoa-app with a simple gui two different ways. 1. Run from a script file at the cmd-line. This runs fine. I check various fields by tailing the system.log. The alert panels appear as I expect. 2. Run by the same script file, which is run by launchd. The app is recognized and starts up. I can see the same fields in the tailed system log. The app run ok until it hangs in the call to [oAlert runModal]; I also try to run the app directly from launchd. I get the same effect as in #2 above. Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls. I have tried various permutations, such as the full path in the Program-key value. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <true/> <key>Label</key> <string>net.aquaconnect.acnotify</string> <key>OnDemand</key> <true/> <key>Program</key> <string>ACNotify</string> <key>ProgramArguments</key> <array> <string>/Users/bob/AppSupport/ACNotify.app/Contents/ MacOS/ACNotify</string> <string>-d</string> <string>4</string> <string>-p</string> <string>/Users/bob/LaunchScriptTest</string> </array> <key>QueueDirectories</key> <array> <string>/Users/bob/LaunchScriptTest</string> </array> <key>ServiceDescription</key> <string>Aquaconnect Alert Notification Manager</string> <key>WorkingDirectory</key> <string>/Users/bob/AppSupport/ACNotify.app/Contents/MacOS</ string> </dict> </plist> On Dec 14, 2007, at 3:30 PM, James Bucanek wrote:
bobkells@steelcape.com <mailto:bobkells@steelcape.com> wrote (Friday, December 14, 2007 3:13 PM -0800):
Not having any luck running a LaunchAgent containing a gui from launchd. Is this simply not possible?
I'm running both GUI and non-GUI agents (~/Library/LaunchAgents) using launchd.
Try telling us what your .plist contains and describe the problems your having.
-- James Bucanek
launchctl load -w net.aquaconnect.acnotify.plist launchctl unload -w net.aquaconnect.acnotify.plist launchctl list Also, I have root priv when doing this. On Dec 14, 2007, at 5:11 PM, Hamish Allan wrote:
On Dec 15, 2007 12:51 AM, Bob Kells <bobkells@steelcape.com> wrote:
Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls.
What arguments are you passing to launchctl?
Hamish
Try: $ launchctl load -S Aqua -w net.aquaconnect.acnotify.plist HTH, H On Dec 15, 2007 1:18 AM, Bob Kells <bobkells@steelcape.com> wrote:
launchctl load -w net.aquaconnect.acnotify.plist launchctl unload -w net.aquaconnect.acnotify.plist launchctl list
Also, I have root priv when doing this.
On Dec 14, 2007, at 5:11 PM, Hamish Allan wrote:
On Dec 15, 2007 12:51 AM, Bob Kells <bobkells@steelcape.com> wrote:
Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls.
What arguments are you passing to launchctl?
Hamish
That gives me an "illegal option" message. Am I running an old version? How can I tell? On Dec 14, 2007, at 5:18 PM, Hamish Allan wrote:
Try:
$ launchctl load -S Aqua -w net.aquaconnect.acnotify.plist
HTH, H
On Dec 15, 2007 1:18 AM, Bob Kells <bobkells@steelcape.com> wrote:
launchctl load -w net.aquaconnect.acnotify.plist launchctl unload -w net.aquaconnect.acnotify.plist launchctl list
Also, I have root priv when doing this.
On Dec 14, 2007, at 5:11 PM, Hamish Allan wrote:
On Dec 15, 2007 12:51 AM, Bob Kells <bobkells@steelcape.com> wrote:
Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls.
What arguments are you passing to launchctl?
Hamish
Did you use a capital -S? Hamish On Dec 15, 2007 1:26 AM, Bob Kells <bobkells@steelcape.com> wrote:
That gives me an "illegal option" message. Am I running an old version? How can I tell?
On Dec 14, 2007, at 5:18 PM, Hamish Allan wrote:
Try:
$ launchctl load -S Aqua -w net.aquaconnect.acnotify.plist
HTH, H
On Dec 15, 2007 1:18 AM, Bob Kells <bobkells@steelcape.com> wrote:
launchctl load -w net.aquaconnect.acnotify.plist launchctl unload -w net.aquaconnect.acnotify.plist launchctl list
Also, I have root priv when doing this.
On Dec 14, 2007, at 5:11 PM, Hamish Allan wrote:
On Dec 15, 2007 12:51 AM, Bob Kells <bobkells@steelcape.com> wrote:
Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls.
What arguments are you passing to launchctl?
Hamish
Both upper and lowercase. On Dec 14, 2007, at 5:27 PM, Hamish Allan wrote:
Did you use a capital -S?
Hamish
On Dec 15, 2007 1:26 AM, Bob Kells <bobkells@steelcape.com> wrote:
That gives me an "illegal option" message. Am I running an old version? How can I tell?
On Dec 14, 2007, at 5:18 PM, Hamish Allan wrote:
Try:
$ launchctl load -S Aqua -w net.aquaconnect.acnotify.plist
HTH, H
On Dec 15, 2007 1:18 AM, Bob Kells <bobkells@steelcape.com> wrote:
launchctl load -w net.aquaconnect.acnotify.plist launchctl unload -w net.aquaconnect.acnotify.plist launchctl list
Also, I have root priv when doing this.
On Dec 14, 2007, at 5:11 PM, Hamish Allan wrote:
On Dec 15, 2007 12:51 AM, Bob Kells <bobkells@steelcape.com> wrote:
Here is the launchd plist. It is located in ~/Library/LaunchAgents. I cd here to issue all the launchctl calls.
What arguments are you passing to launchctl?
Hamish
participants (5)
-
Bob Kells
-
bobkells@steelcape.com
-
Hamish Allan
-
James Bucanek
-
Nathan Duran