Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'running generatelinks.sh' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
running generatelinks.sh
Authored by: nick on Nov 04, '05 10:33:02AM
the file gotta look s/th like this:

<?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>Debug</key>
        <true/>
        <key>Label</key>
        <string>generatelinks</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>10</integer>
        <key>Program</key>
        <string>/Users/nick/Apps/generatelinks.sh</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Users/nick/Apps/generatelinks.sh</string>
        </array>
        <key>ServiceDescription</key>
        <string>generate links for commandline GUI-app launching</string>
        <key>UserName</key>
        <string>nick</string>
        <key>WatchPaths</key>
        <array>
                <string>/Applications/</string>
        </array>
</dict>
</plist>
of course you should adapt the path to the script AND the username. you can make this plist with launchd editor (its on vt, me thinkin) or with the plist-editor (its on your system). the you tell osx to add it to launchd-services:

:~ nick$ launchctl load Library/LaunchAgents/generatelinks.plist 
:~ nick$ launchctl list 
again adapt paths. if you now add s/th to /Applications/ you'll notice the find-process in top. but this way, if you remove apps, they aren't removed from your list. you gotta add s/th like "rm ~/Apps/*.app" to generatelinks.sh for this. then everytime you s/th to /Applications/ the complete list of links is rebuild. this could be a problem with apps writing in their app-bundle though, as the find-command takes its time... regards, n.

[ Reply to This | # ]
running generatelinks.sh
Authored by: GlowingApple on Nov 04, '05 04:28:29PM
Thanks! Works great. I changed the code of the original script a bit to be more conducive to a background task:

#!/bin/sh

cd ~/Apps
find -E /Applications/ -regex ".*.app$" -print |
while read APPS; do
  APPLINK=`echo -n "$APPS" | sed s:".*/":"": | sed s:" ":"_":g`
  if [ ! -e "$APPLINK" ]; then
         ln -s open.sh "$APPLINK"
         logger "Created Application symlink for "$APPLINK
  fi
done
This will verify if the symlink exists first, otherwise when it tries to overwrite it generates an error. It will also output the names of the links it creates to the system log, rather than to stdout, which running within launchd isn't really visible. This doesn't cover the problem with apps removed, but simply doing an rm ~/Apps/*.app periodically should fix this.

---
Jayson --When Microsoft asks you, "Where do you want to go today?" tell them "Apple."

[ Reply to This | # ]