I'm trying to use a launchagent on login to kill the Finder, and then re-launch TotalFinder, to automatically apply the colorsidebar mod for OS X 10.7 (the mod can be found here).

If I use the launchagent to call a shell script, it's fine, like so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.colorsidebar.root</string>
    <key>KeepAlive</key>
    <false/>
    <key>RunAtLoad</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/POSIX/path/to/some/shell/script.sh</string>
    </array>
</dict>
</plist>

And then in the shell script, all I use is

#!/bin/bash
#
#This file kills the finder on user session start
#and re-launches TotalFinder
#

killall Finder
Open /Applications/TotalFinder.app

Now, when I try to combine the two like so

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.colorsidebar.root</string>
    <key>KeepAlive</key>
    <false/>
    <key>RunAtLoad</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>killall Finder</string>
        <string>open /Applications/TotalFinder.app</string>
    </array>
</dict>
</plist>

It doesn't work, and console shows the following error:

8/21/11 5:16:16.957 PM com.colorsidebar.root: /bin/bash: killall Finder: No such file or directory

link|improve this question
feedback

1 Answer

bash expects to be given an filename (i.e. a script) as its argument. Since there's no file named "killall Finder", you get an error to that effect. If you want to pass commands to bash as arguments, you must use the -c option, and pass the commands as a single argument:

<key>ProgramArguments</key>
<array>
    <string>/bin/bash</string>
    <string>-c</string>
    <string>killall Finder; open /Applications/TotalFinder.app</string>
</array>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.