|
|
Keep apps alive without losing environment variables
No, that doesn't work, because the content of
There is an alternative mechanism, however, which is a lot neater. Go back to the original launchd Property List file to keep Quicksilver alive – the one with the single argument, described elsewhere. Then consider the following script: #! /bin/sh - # # For each of the environment variables defined in ~/.MacOSX/environment.plist, # inject it into the environment of launchd. # # Norman Gray <http://nxg.me.uk> cat <<EOD | /usr/bin/xsltproc --novalid - $HOME/.MacOSX/environment.plist | sh <?xml version='1.0' encoding='UTF-8'?> <stylesheet xmlns='http://www.w3.org/1999/XSL/Transform' version='1.0'> <output method='text' encoding='UTF-8' version='1.0'/> <template match='/'> <apply-templates select='plist/dict/key'/> </template> <template match='key'>launchctl setenv <value-of select='.'/> <value-of select='following::string[1]'/>;</template> </stylesheet> EOD exit 0 Put that in But the problem is: how do we get this script run promptly after logging in. That's easy – we use launchd. Create another launchd property list, which looks like: <?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>RunAtLoad</key> <true/> <key>Label</key> <string>nxg.LaunchdEnvironment</string> <key>ProgramArguments</key> <array> <string>/Users/norman/Library/LaunchAgents/environment-to-launchd.sh</string> </array> </dict> </plist> (adjusting the path accordingly) That's it – log out and back in again (or do appropriate launchctl
load/unload stuff), and launchd will keep Quicksilver alive, and
additionally inject the variable settings within
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.07 seconds |
|