Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

127 lines (107 sloc) 6.66 kb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="Content-Type" content="text/html; charset=utf-8" />
<title>File: LaunchdPlistExample</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/custom.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
relpath = '';
if (relpath != '') relpath += '/';
</script>
<base id="base_target" target="_top" />
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/autocomplete.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
<script type="text/javascript" charset="utf-8" src="js/live.js"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
if (window.top.frames.main) document.body.className = 'frames';
</script>
<div id="header">
<div id="menu">
<a href="object_index.html" target="_self" title="Index">Index</a> &raquo;
<span class="title">File: LaunchdPlistExample</span>
<div class="noframes">
<span class="title"></span>
<a id="frames_link" class="link_disabled">Frames</a> |
<a target="_top" id="noframes_link" class="link_disabled">No Frames</a>
<span class="title"></span>
</div>
</div>
<div id="search2">
<div class="search2_center">
<form class="search2" onsubmit="return false;" action="">
<input name="q" type="search" placeholder="Search" id="search_box2" size="30" value="" />
</form>
</div>
<script type="text/javascript" charset="utf-8">
$('#search_box2').focus(function(){
var search_index = relpath + 'search_index.json';
jQuery.getJSON(search_index, go_data);
function go_data(adata) {
$('#search_box2').autocomplete(adata, {
width: 300,
matchContains: true,
formatItem: function(item) {
return item.text;
}
}).result(function(event, item) {
if (window.location.search) {
window.location.href = relpath + $(item.href_tag).attr("href");
} else {
location.href = relpath + $(item.href_tag).attr("href");
}
});
}
});
</script>
</div>
<div class="clear"></div>
</div>
<iframe id="search_frame"></iframe>
<div id="content"><div id='filecontents'><h1>Launchd Plist Example</h1>
<p>
In this example, we edit an Apple Launchd plist, to modify a couple of the
keys and write them back to the same file. For setting the plist file
attributes see <tt><a href="Plist4r/Plist.html" target="_self" title="Plist4r::Plist (class)">Plist4r::Plist</a></tt>. For more information specifically about
Launchd Plists, see <tt><a href="Plist4r/PlistType/Launchd.html" target="_self" title="Plist4r::PlistType::Launchd (class)">Plist4r::PlistType::Launchd</a></tt>.
</p>
<pre class="code">
<span class='comment val'># standard method</span>
<span class='launchd_plist identifier id'>launchd_plist</span> <span class='assign token'>=</span> <span class='Plist4r constant id'>Plist4r</span><span class='dot token'>.</span><span class='open identifier id'>open</span> <span class='string val'>&quot;/Library/LaunchDaemons/com.mydomain.MyApp.plist&quot;</span>
<span class='launchd_plist identifier id'>launchd_plist</span><span class='lbrack token'>[</span><span class='symbol val'>:label</span><span class='rbrack token'>]</span> <span class='comment val'># =&gt; &quot;com.mydomain.Myapp&quot;</span>
<span class='launchd_plist identifier id'>launchd_plist</span><span class='lbrack token'>[</span><span class='symbol val'>:start_on_mount</span><span class='rbrack token'>]</span> <span class='assign token'>=</span> <span class='true true kw'>true</span>
<span class='launchd_plist identifier id'>launchd_plist</span><span class='dot token'>.</span><span class='save identifier id'>save</span>
<span class='comment val'># block method</span>
<span class='launchd_plist identifier id'>launchd_plist</span> <span class='assign token'>=</span> <span class='Plist4r constant id'>Plist4r</span><span class='dot token'>.</span><span class='open identifier id'>open</span> <span class='string val'>&quot;/Library/LaunchDaemons/com.mydomain.MyApp.plist&quot;</span> <span class='do do kw'>do</span>
<span class='comment val'># plist file attributes</span>
<span class='filename identifier id'>filename</span> <span class='comment val'># =&gt; &quot;/Library/LaunchDaemons/com.mydomain.MyApp.plist&quot;</span>
<span class='file_format identifier id'>file_format</span> <span class='comment val'># =&gt; :xml</span>
<span class='plist_type identifier id'>plist_type</span> <span class='comment val'># =&gt; :launchd</span>
<span class='comment val'># read plist keys</span>
<span class='label identifier id'>label</span> <span class='comment val'># =&gt; &quot;com.mydomain.Myapp&quot;</span>
<span class='program_arguments identifier id'>program_arguments</span> <span class='comment val'># =&gt; [&quot;/Applications/MyApp.app/Contents/MacOS/MyApp&quot;]</span>
<span class='queue_directories identifier id'>queue_directories</span> <span class='comment val'># =&gt; [&quot;/dir/to/watch/1&quot;,&quot;/dir/to/watch/2&quot;,&quot;etc...&quot;]</span>
<span class='run_at_load identifier id'>run_at_load</span> <span class='comment val'># =&gt; false</span>
<span class='start_on_mount identifier id'>start_on_mount</span> <span class='comment val'># =&gt; false</span>
<span class='comment val'># write plist keys</span>
<span class='run_at_load identifier id'>run_at_load</span> <span class='true true kw'>true</span>
<span class='store identifier id'>store</span> <span class='string val'>&quot;StartOnMount&quot;</span> <span class='true true kw'>true</span>
<span class='comment val'># call launchd_plist.save</span>
<span class='save identifier id'>save</span>
<span class='end end kw'>end</span>
</pre>
</div></div>
<div id="footer">
Generated on Wed Aug 18 16:27:34 2010 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
0.5.8 and the
<a href="http://github.com/dreamcat4/yard-slipstream">yard-slipstream</a> plugin
(ruby-1.8.7).
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.