<?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>Joe&#039;s Blog</title>
	<atom:link href="http://joegolike.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://joegolike.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 26 Jun 2009 11:25:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wake sleeping Mac with Applescript and Automator</title>
		<link>http://joegolike.com/wake-sleeping-mac-with-applescript-and-automator/</link>
		<comments>http://joegolike.com/wake-sleeping-mac-with-applescript-and-automator/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 09:34:30 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://joegolike.com/?p=3</guid>
		<description><![CDATA[
I have a Mac mini in my living room hooked up to my TV. I wanted to be able to control the mini from my iMac in my office. Using Screen Sharing built into Leopard, it&#8217;s a simple click of the mouse to do this. With a little Automator love, I created a simple workflow [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-14" title="wake-and-share" src="http://joegolike.com/wp-content/uploads/2009/06/wake-and-share.jpg" alt="wake-and-share" width="458" height="261" /></p>
<p>I have a Mac mini in my living room hooked up to my TV. I wanted to be able to control the mini from my iMac in my office. Using Screen Sharing built into Leopard, it&#8217;s a simple click of the mouse to do this. With a little Automator love, I created a simple workflow that turns the Screen Sharing step into a click of an icon in the dock.</p>
<p>However, even with the power efficiency of the 2009 Mac mini, I don&#8217;t want to leave it on 24/7. After searching through several solutions that used Python and Shell Scripting (neither of which I know or could make work), I found a <a href="http://forums.dealmac.com/read.php?4,2751523">nifty Applescript from Mark Muir</a> that I adapted to solve my problem:</p>
<pre>
(*
Script adapted from Wake on WAN - by Mark Muir (2008-04-01)
http://forums.dealmac.com/read.php?4,2751523
*)

property MAC_address : "00:25:4b:9f:63:c8"
property WAN_IP_address : "255.255.255.255"

on run
	set command to "/usr/bin/php -r " &#038; quoted form of ("$mac = " &#038; quoted form of MAC_address &#038; "; $ip = " &#038; quoted form of WAN_IP_address &#038; "; " &#038; "
$mac_bytes = explode(\":\", $mac);
$mac_addr = \"\";
for ($i=0; $i<6; $i++)
$mac_addr .= chr(hexdec($mac_bytes[$i]));
$packet = \"\";
for ($i=0; $i<6; $i++)	/*6x 0xFF*/
$packet .= chr(255);
for ($i=0; $i<16; $i++)	/*16x MAC address*/
$packet .= $mac_addr;

$port = 9;
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, TRUE);
socket_sendto($sock, $packet, strlen($packet), 0, $ip, $port);
socket_close($sock);
")
	do shell script command
end run
</pre>
<p>Rolling that into my Automator workflow gives me one-click access from my dock to wake my Mac mini over the network and start screen sharing on Leopard. Here is the final Automator workflow:</p>
<p><a href="/files/wake-and-share-mac-mini.zip">wake-and-share-mac-mini.zip</a> (68KB)</p>
]]></content:encoded>
			<wfw:commentRss>http://joegolike.com/wake-sleeping-mac-with-applescript-and-automator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
