<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Postpostmodern &#187; Bash</title>
	<atom:link href="http://postpostmodern.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://postpostmodern.com</link>
	<description>Speaking of web development.</description>
	<lastBuildDate>Tue, 08 Jun 2010 18:46:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Screenwatcher</title>
		<link>http://postpostmodern.com/instructional/screenwatcher/</link>
		<comments>http://postpostmodern.com/instructional/screenwatcher/#comments</comments>
		<pubDate>Mon, 20 Nov 2006 02:32:55 +0000</pubDate>
		<dc:creator>Jason Johnson</dc:creator>
				<category><![CDATA[Instructional]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Screen Capture]]></category>
		<category><![CDATA[Screenwatcher]]></category>

		<guid isPermaLink="false">http://blog.postpostmodern.com/2006/11/19/screenwatcher-a-visual-activity-log/</guid>
		<description><![CDATA[An automatically-generated visual activity log]]></description>
			<content:encoded><![CDATA[<p>Sometimes I end up asking these questions:</p>

<ul>
    <li>How many hours did I spend on that project yesterday?</li>
    <li>What day did I work on x project?</li>
    <li>Where did the time go today?</li>
</ul>

<p>I&#8217;m not the best at recording my time as I work on stuff. And I&#8217;ve never found the perfect time-logging application, anyway. So, the answers to these questions usually come from tedious review of file modification dates and emails. I can usually put together most of the pieces of the past week&#8217;s activities, but it&#8217;s a real pain in the ass, and the result is not very accurate.</p>

<p>The other day, I said to myself:</p>

<p>&#8220;Self, can&#8217;t your Mac automatically keep track of what I do in an easy-to-understand format?&#8221;</p>

<p><strong>&#8220;Of course it can!&#8221;</strong> I replied. &#8220;How about something that produces a visual activity log where you can see what you were doing every 15 minutes of every day?&#8221;</p>

<p>&#8220;Excellent!! We&#8217;ll call him <strong><em>Screenwatcher</em></strong>.&#8221;</p>

<h3>How? Simple: 3 steps!</h3>

<ol>
    <li>Create a folder in which to put your screenshots.</li>
    <li>Write a script that takes a screenshot and saves it in the aforementioned screenshots folder.</li>
    <li>Have the computer run the script every 15 minutes.</li>
</ol>

<p>On Mac OS X 10.4, this involves a shell script and a plist for launchd. It&#8217;s easier than it sounds.</p>

<h4>Step 1: Create the Folder</h4>

<p>I created a folder in my home directory called &#8216;Screenwatcher.&#8217; i.e. ~/Screenwatcher</p>

<p>This folder will automatically get subfolders for each day. The shell script handles that. Which brings us to&#8230;</p>

<h4>Step 2: Create the Script</h4>

<p>The shell script looks like this (replace &#8220;jason&#8221; with your username):</p>

<pre>
<code lang="bash">
#!/bin/bash
# Change to a Screenwatcher directory in your home directory
cd /Users/jason/Screenwatcher
# Make a directory based on the date
mkdir -p `date "+%Y-%m-%d"`
# Capture
screencapture -C `date "+%Y-%m-%d"`/`date "+%H.%M"`.png
</code>
</pre>

<p>I saved this script here: ~/Library/Scripts/Shell/screenwatcher.sh</p>

<p>UPDATE: Don&#8217;t forget to give it execute permissions:</p>

<p><kbd class="block">chmod 755 ~/Library/Scripts/Shell/screenwatcher.sh</kbd></p>

<h4>Step 3: Create the launchd plist</h4>

<p>Launchd is a part of OS X that runs tasks at specific times and/or intervals. Plist files tell Launchd what to run and when to run it.</p>

<p>The screenwatcher plist looks like this<sup><a href="#footnote-1-40" id="footnote-link-1-40" title="See the footnote.">1</a></sup>:</p>

<pre name="code" class="xml">
<code lang="xml">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;com.postpostmodern.screenwatcher&lt;/string&gt;
  &lt;key&gt;LowPriorityIO&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;Program&lt;/key&gt;
  &lt;string&gt;/Users/jason/Library/Scripts/Shell/screenwatcher.sh&lt;/string&gt;
  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
    &lt;string&gt;/Users/jason/Library/Scripts/Shell/screenwatcher.sh&lt;/string&gt;
  &lt;/array&gt;
  &lt;key&gt;ServiceDescription&lt;/key&gt;
  &lt;string&gt;Takes a picture of the screen every 15 minutes&lt;/string&gt;
  &lt;key&gt;StartInterval&lt;/key&gt;
  &lt;integer&gt;900&lt;/integer&gt;
&lt;/dict&gt;
&lt;/plist&gt;</code>
</pre>

<p>The StartInterval is in seconds. Change it to whatever you want. I track my time in 15 minute increments; so, 900 seconds does me just fine. If I had vast amounts of disk space, I might get crazy and try 300.</p>

<p>This plist needs to be saved in ~/Library/LaunchAgents (e.g. ~/Library/LaunchAgents/com.postpostmodern.screenwatcher.plist). If your LaunchAgents folder doesn&#8217;t exist, create it.</p>

<p>Placing the plist file in the LaunchAgents folder allows launchd to automatically find it when you log in. You can also manually load it via this command:</p>

<p><kbd class="block">launchctl load ~/Library/LaunchAgents/com.postpostmodern.screenwatcher.plist</kbd></p>

<h3>Get me off this crazy thing!</h3>

<p>How do you stop it? This will unload it from launchd:</p>

<p><kbd class="block">launchctl unload ~/Library/LaunchAgents/com.postpostmodern.screenwatcher.plist</kbd></p>

<p>And removing the plist from the LaunchAgents folder will keep it from being loaded next time you log in.</p>

<h3>Final Notes</h3>

<p>Now that all of this is up and running, you can focus on your work and know that your good ol&#8217; Mac is keeping an eye on you. How do you know? You&#8217;ll hear the little shutter sound. If the shutter sound gets too annoying you can alter the shell script and add the -x flag to the screencapture command. But I like the sound. It reminds me that it&#8217;s doing its job.</p>

<p>I should also mention that the reason I keep my shell scripts in my ~/Library/Scripts folder is so it will show up in my Scripts Menu. That way, I can manually take a Screenwatcher screen capture whenever I want.</p>

<p>Finally, don&#8217;t forget to clean out your Screenwatcher folder every once in a while. The PNGs don&#8217;t take up a ton of space, but they take up enough. I don&#8217;t like to keep more than a few days. You could modify the script to handle the file deletion, but I prefer to do it manually.</p>

<ins>

<h2>UPDATE:</h2>

<p>It has come to my attention that OS X 10.4.7 introduced a launchd/launchctl bug that causes this: &#8220;Workaround Bonjour: Unknown error: 0&#8221;. I haven&#8217;t seen this myself (some say it&#8217;s fixed on the Intel version of 10.4.8), but it has been confirmed to happen on a G4 PowerBook. Most <a href="http://www.google.com/search?q=%22Workaround+Bonjour%22">Google results</a> say that it doesn&#8217;t cause too much trouble. And I think it&#8217;s only when you run launchctl. I don&#8217;t think that it will happen when you restart.</p>

</ins>

<p><br /></p>

<ol class="footnotes"><li id="footnote-1-40">I actually didn&#8217;t write the plist file by hand. There&#8217;s an application called <a href="http://www.codepoetry.net/products/launchdeditor">Launchd Editor</a> that does it via a GUI. If you want to make more launchd plists, you might want to download it.  <a href="#footnote-link-1-40">&#8593; back up there</a></li></ol>
]]></content:encoded>
			<wfw:commentRss>http://postpostmodern.com/instructional/screenwatcher/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
