<?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>edwi.nl/og &#187; macports</title>
	<atom:link href="http://edwi.nl/og/tag/macports/feed/" rel="self" type="application/rss+xml" />
	<link>http://edwi.nl/og</link>
	<description>Edwin Woudt's weblog</description>
	<lastBuildDate>Sat, 18 Apr 2009 00:15:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MCE Remote on a Mac &#8211; Step 3: configuring LIRC in OS X</title>
		<link>http://edwi.nl/og/2009/04/08/mce-remote-on-a-mac-step-3-configuring-lirc-in-os-x/</link>
		<comments>http://edwi.nl/og/2009/04/08/mce-remote-on-a-mac-step-3-configuring-lirc-in-os-x/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 16:08:49 +0000</pubDate>
		<dc:creator>edwin</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[htpc]]></category>
		<category><![CDATA[lirc]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[mce remote]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[vlc]]></category>

		<guid isPermaLink="false">http://edwi.nl/og/?p=156</guid>
		<description><![CDATA[This is part 3 in a series on using an MCE Remote Control with a Mac. See the:
- Main article
- Step 1: installing Finnix as a Parallels VM
- Step 2: installing LIRC in the Finnix VM
Installing LIRC using MacPorts
The LIRC client executables can be installed using MacPorts. We will use these executables to connect to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-93 alignleft" style="border: 1px solid #dddddd; margin-bottom: 12px; margin-right: 20px;" title="mac-mce-120x120" src="http://edwi.nl/og/uploads/2009/04/mac-mce-120x120.png" alt="MCE Remote on a Mac" width="120" height="120" />This is part 3 in a series on using an MCE Remote Control with a Mac. See the:<br />
- <a href="http://edwi.nl/og/2009/04/08/mce-remote-on-a-mac-or-i-want-more-buttons/">Main article</a><br />
- <a href="http://edwi.nl/og/2009/04/08/mce-remote-on-a-mac-step-1-installing-finnix-as-a-parallels-vm/">Step 1: installing Finnix as a Parallels VM</a><br />
- <a href="http://edwi.nl/og/2009/04/08/mce-remote-on-a-mac-step-2-installing-lirc-in-the-finnix-vm/">Step 2: installing LIRC in the Finnix VM</a></p>
<h3>Installing LIRC using MacPorts</h3>
<p>The <a href="http://www.lirc.org/">LIRC</a> client executables can be installed using <a href="http://www.macports.org/">MacPorts</a>. We will use these executables to connect to the LIRC daemon in the Finnix VM.</p>
<p>First you need to install:</p>
<ul>
<li>Apple <a href="http://developer.apple.com/TOOLS/xcode/">Xcode</a></li>
<li>MacPorts (<a href="http://www.macports.org/install.php">installation instructions</a>)</li>
</ul>
<p>Then fire up a terminal, and execute the following commands in a Mac terminal to initialize your ports tree and install LIRC:<br />
<code>$ sudo port -v selfupdate<br />
$ sudo port install lirc</code></p>
<p>While you are waiting for lirc to install, let&#8217;s already execute the next step: in order to connect to your virtual machine, you need to know the IP address used by it. Run the ifconfig command in your Finnix VM. The output looks someting like:<br />
<code>root@tty1:~# ifconfig eth0<br />
eth0&nbsp;&nbsp;&nbsp;&nbsp;Link encap:Ethernet  HWaddr 00:1c:42:f0:e5:19<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inet addr:10.37.129.3  Bcast:10.37.129.255  Mask:255.255.255.0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RX packets:813 errors:0 dropped:0 overruns:0 frame:0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TX packets:145 errors:0 dropped:0 overruns:0 carrier:0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;collisions:0 txqueuelen:1000<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RX bytes:73804 (72.0 KiB)  TX bytes:11687 (11.4 KiB)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Interrupt:10 Base address:0x8200</code></p>
<p>The ip address you are looking for is the one after &#8216;inet addr:&#8217; on the second line.</p>
<p>When lirc is installed, let&#8217;s connect to it by typing the following in your <em>Mac</em> terminal (and not the Finnix VM), obviously replacing the ip address with the one you found in the previous step:<br />
<code># sudo lircd --connect 10.37.129.3<br />
# sudo chmod 666 /opt/local/var/run/lircd</code></p>
<p>Now let&#8217;s test your setup by running &#8216;irw&#8217; and pushing some buttons. Your terminal should look like:<br />
<code># irw<br />
000000037ff07bf2 00 Home mceusb<br />
000000037ff07bf2 01 Home mceusb<br />
000000037ff07bf2 02 Home mceusb<br />
000000037ff07be9 00 Play mceusb<br />
000000037ff07be0 00 Down mceusb</code></p>
<p>Congratulations! You are now receiving your MCE Remote events on your Mac. Read on for information on how to control an application with it.<br />
<span id="more-156"></span></p>
<h3>Controlling VLC with LIRC</h3>
<p>This tutorial will now show you how to control the <a href="http://www.videolan.org/vlc/">VLC media player</a> using your MCE remote by mapping your remote buttons to keypresses.</p>
<p>First of all a script is needed that can send keystrokes. <a href="http://www.apple.com/applescript/">AppleScript</a> is the most logical candidate. A script like the following should do the trick (note: at the end of this posting you can find a link to download a full version of this script):<br />
<code>--&nbsp;Filename:&nbsp;keystroke-simple.applescript<br />
--&nbsp;Author:&nbsp;&nbsp;&nbsp;Edwin&nbsp;Woudt<br />
--&nbsp;Version:&nbsp;&nbsp;20090407-1<br />
--<br />
--&nbsp;Note:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;a&nbsp;simplified&nbsp;version&nbsp;of&nbsp;the&nbsp;full&nbsp;script.<br />
--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Download&nbsp;keystroke.applescript&nbsp;below&nbsp;for&nbsp;the&nbsp;full&nbsp;version.<br />
&nbsp;<br />
on run argv<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;set xkey to (item 1 of argv)<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ((count of argv) > 1) then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set xmod to (item 2 of argv)<br />
&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set xmod to ""<br />
&nbsp;&nbsp;&nbsp;&nbsp;end if<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;set xcode to 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;if xkey = "down" then set xcode to 125<br />
&nbsp;&nbsp;&nbsp;&nbsp;if xkey = "up" then set xcode to 126<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;if xmod = "" then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if xcode = 0 then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tell application "System Events" to keystroke xkey<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tell application "System Events" to key code xcode<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if<br />
&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if xcode = 0 then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if xmod = "x" then tell application "System Events" to keystroke xkey using command down<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if xmod = "x" then tell application "System Events" to key code xcode as integer using command down<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end if<br />
&nbsp;&nbsp;&nbsp;&nbsp;end if<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
end run</code></p>
<p>This script can be called with two command line parameters:</p>
<ol>
<li>A key, either a letter or a special key like &#8216;up&#8217;, &#8216;down&#8217;, &#8216;esc&#8217; or &#8216;enter&#8217;</li>
<li>An optional modifier, consisting of one or more of the following letters: &#8216;c&#8217; for Control, &#8216;o&#8217; for Option, &#8217;s&#8217; for Shift and/or &#8216;x&#8217; for Command (note: the simple version only supports the &#8216;x&#8217; modifier, the full version below supports all modifiers and all combinations).</li>
</ol>
<p>This script will be called from a &#8216;lircrc&#8217; file, of which the following is a small example:<br />
<code>#&nbsp;Filename:&nbsp;vlc-simple.lircrc<br />
#&nbsp;Author:&nbsp;&nbsp;&nbsp;Edwin&nbsp;Woudt<br />
#&nbsp;Version:&nbsp;&nbsp;20090407-1<br />
&nbsp;<br />
#&nbsp;&nbsp;Note:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;a&nbsp;simplified&nbsp;version&nbsp;of&nbsp;the&nbsp;full&nbsp;file.<br />
#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Download&nbsp;vlc.lirrc&nbsp;below&nbsp;for&nbsp;the&nbsp;full&nbsp;version.<br />
&nbsp;<br />
#&nbsp;Play&nbsp;button<br />
begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;prog&nbsp;&nbsp;&nbsp;=&nbsp;irexec<br />
&nbsp;&nbsp;&nbsp;&nbsp;button&nbsp;=&nbsp;Play<br />
&nbsp;&nbsp;&nbsp;&nbsp;config&nbsp;=&nbsp;/usr/bin/osascript&nbsp;~edwin/Documents/Scripts/keystroke.applescript&nbsp;p&nbsp;x<br />
end<br />
&nbsp;<br />
#&nbsp;Volume&nbsp;buttons<br />
begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;prog&nbsp;&nbsp;&nbsp;=&nbsp;irexec<br />
&nbsp;&nbsp;&nbsp;&nbsp;button&nbsp;=&nbsp;VolUp<br />
&nbsp;&nbsp;&nbsp;&nbsp;config&nbsp;=&nbsp;/usr/bin/osascript&nbsp;~edwin/Documents/Scripts/keystroke.applescript&nbsp;up&nbsp;x<br />
end<br />
begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;prog&nbsp;&nbsp;&nbsp;=&nbsp;irexec<br />
&nbsp;&nbsp;&nbsp;&nbsp;button&nbsp;=&nbsp;VolDown<br />
&nbsp;&nbsp;&nbsp;&nbsp;config&nbsp;=&nbsp;/usr/bin/osascript&nbsp;~edwin/Documents/Scripts/keystroke.applescript&nbsp;down&nbsp;x<br />
end</code></p>
<p>This file will basically instruct lirc to output a &#8216;Command-P&#8217; when I click on the Play button, &#8216;Command-Up Arrow&#8217; for the volume up button and &#8216;Command-Down Arrow&#8217; for the volume down button. These correspond to the default keys used by VLC, according to the VLC Preferences -> Hotkeys.</p>
<p>Create the file with a texteditor (or download my full version below) and run it in a terminal using:<br />
<code>irexec ~edwin/Documents/Scripts/vlc.lircrc</code></p>
<p>Note: all my scripts assume their location to be in the Documents/Scripts subdirectory of my home directory. Feel free to change it to a different location.</p>
<p>Now start up a video in VLC media player and try to use some buttons!</p>
<p>Download attachments:<br />
<a href="http://edwi.nl/og/uploads/2009/04/vlc.lircrc">vlc.licrc</a><br />
<a href="http://edwi.nl/og/uploads/2009/04/keystroke.applescript">keystroke.applescript</a></p>
<h3>Next steps</h3>
<p>You have now reached the end of this three part tutorial on getting your MCE remote control to work on your Mac.  Hopefully this has all worked out for you: let me know through a comment or by mailing me at <em>edwin AT woudt DOT nl</em>. </p>
<p>A few things you could do after this tutorial:</p>
<ul>
<li>change the configuration for the VLC media player to be more of your liking</li>
<li>add configuration files for other applications</li>
<li>somehow extend all this with detection of which application is running (using AppleScript?) and change the behaviour of the remote based on that</li>
<li>use a different linux distribution</li>
<li>use VirtualBox as a free alternative to Parallels</li>
</ul>
<p>If I get around to one of these things, I will post the results on this blog. Of course: should you have anything to add, let me know, whether it is a solution to one of the above suggestions, or a completely different thing. </p>
]]></content:encoded>
			<wfw:commentRss>http://edwi.nl/og/2009/04/08/mce-remote-on-a-mac-step-3-configuring-lirc-in-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

