Re: Adding an application to the login items
Re: Adding an application to the login items
- Subject: Re: Adding an application to the login items
- From: Misha Gonodanov <email@hidden>
- Date: Mon, 1 Jun 2009 20:09:26 -0700
You are not creating URL correctly - basically
CFURLRef.alloc().initWithString_() will create it by calling
CFURLCreateWithString() while it should be created by
CFURLCreateWithFileSystemPath(). I do not know the name of
corresponding python method.
Misha
On Dec 3, 2008, at 4:36 PM, Bill Janssen wrote:
I'm writing an installer that adds an application to the login items,
but my script (see below) keeps failing, with a bus error, like this:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread: 0
Thread 0 Crashed:
0 com.apple.CoreFoundation 0x96318aa7 CFStringGetLength + 39
1 com.apple.CoreFoundation 0x963254b2 CFStringCompare + 18
2 com.apple.LaunchServices 0x904e4b61
LSSharedFileListInsertItemURL + 73
3 _objc.so 0x00231855 ffi_call_SYSV + 53
4 _objc.so 0x00231d6c ffi_call + 147
5 _objc.so 0x0023f528
PyObjCFormalProtocol_ForProtocol + 1551
6 org.python.python 0x0011fd3d PyObject_Call + 50
7 org.python.python 0x0018db1a PyEval_EvalFrameEx +
17904
8 org.python.python 0x0018f45b PyEval_EvalCodeEx + 1638
9 org.python.python 0x0018f548 PyEval_EvalCode + 87
10 org.python.python 0x001a69ec PyErr_Display + 1896
11 org.python.python 0x001a7016 PyRun_FileExFlags + 135
12 org.python.python 0x001a8982
PyRun_SimpleFileExFlags + 421
13 org.python.python 0x001b3c03 Py_Main + 3095
14 org.python.pythonapp 0x00001fca 0x1000 + 4042
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0xa07444ec ebx: 0x96318a8a ecx: 0x00000000 edx: 0x00000007
edi: 0x01f10690 esi: 0x00000000 ebp: 0xbfffe8c8 esp: 0xbfffe8b0
ss: 0x0000001f efl: 0x00010283 eip: 0x96318aa7 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x00000000
Here's the script -- any advice would be appreciated!
TIA, Bill
---------------------------------------------------------------------------------
#!/usr/bin/python
# -*- mode: Python -*-
import os, sys
from Foundation import *
from AppKit import *
from LaunchServices import *
pool = NSAutoreleasePool.alloc().init()
try:
if len(sys.argv) < 2:
sys.stderr.write("Usage: %s APPLICATIONPATH\n" % sys.argv[0])
sys.exit(1)
if not os.path.isdir(sys.argv[1]):
sys.stderr.write("Specified application %s not an application.
\n" % sys.argv[1])
sys.exit(1)
url = CFURLRef.alloc().initWithString_(sys.argv[1])
props = NSDictionary.dictionaryWithObject_forKey_(True,
kLSSharedFileListItemHidden)
login_items = LSSharedFileListCreate(
kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)
NSLog("login_items are %s, url is %s, props are %s" %
(login_items, url, props))
v = LSSharedFileListInsertItemURL(login_items,
kLSSharedFileListItemLast,
None,
None,
url,
props,
None)
NSLog("v is %s" % v)
finally:
del pool
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden