From fd564fbc254425456aff4f6e0a282b2d91c0a230 Mon Sep 17 00:00:00 2001 From: "Michael P. Geraci" Date: Sat, 7 Nov 2015 11:32:38 -0500 Subject: [PATCH] update readme for run-on-boot instructions --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ff2978a..f63dca1 100644 --- a/README.md +++ b/README.md @@ -166,10 +166,44 @@ to install the packages required to compile Auto-HUD's frontend files. Just run `gulp` in the project root to watch for Sass and CoffeeScript changes. ## Running the app on boot -To start the application when the computer boots, add a script to automate the -loading of your virtualenv, and starting the flask task. An example script can -be found [here](https://gist.github.com/mgeraci/8764990edb50e4023959). Be sure -to make it executable! Then you can add a hook to OS X's login event by typing -the following on your command line: +To start the application when the computer boots, you can write a simple script +to load the correct python, start flask, and log the output. Here's what I am +using (you'd need to change the paths from `mediabox` to your user): - sudo defaults write com.apple.loginwindow LoginHook /path/to/your/script.sh +``` +#!/bin/sh + +/Users/mediabox/.virtualenvs/auto-hud/bin/python /Users/mediabox/web/auto-hud/auto-hud.py > /Users/mediabox/Library/Logs/auto-hud.log 2>&1 +``` + +Then, create a plist file in `~/Library/LaunchAgents/` that runs the script: + +``` + + + + + Disabled + + KeepAlive + + Label + auto-hud starter + Program + /Users/mediabox/start-auto-hud.sh + RunAtLoad + + StandardErrorPath + /tmp/auto-hud-starter.err + StandardOutPath + /tmp/auto-hud-starter.out + + +``` + +Finally, load the plist file into OS X's launch control, and you'll be good to +go! + +``` +launchctl load ~/Library/LaunchAgents/[your-plist-file].plist +```