Myth TV remote control working

I’ve had an ATI Remote Wonder for years. Bought it whilst at Uni’ for my computer because I couldn’t be bothered to walk the three feet to the computer! I’ve known this has had a linux driver since I compiled the original before it was wound in to the kernel. I had it kicking about the house so wanted to get it working. I’ve read a lot about lirc and using that to set up the Remote Wonder. One drawback to using lirc that I think is unique to the Remote Wonder is that you can’t use the mouse functionality.

The Remote Wonder has a direction wheel and a left and right mouse button on the control. I want this because I may want to use catch up TV, which means running a web browser as well as Myth TV, and typing something in the search box, clicking on a ‘full screen’ button for the video means I need a pointer, and the Remote Wonder gives me that. What I’m then missing would be a keyboard. Happily, there is a Firefox plug in that does just that. I’ve managed to get them all configured and working, so below is how I did it. The only slight downer is the known issue around the TV, DVD, OK and Channel up/down buttons that do not work on Linux because the key codes are greater than 255. There is a patch to fix this I’ve not applied yet to evdev, I’ll update this blog when I’ve done that.

The ATI Remote Wonder is a USB based RF (radio) remote control. Plug it in and the ati_remote kernel module will be automagically loaded. Here’s how to figure out what’s working and get it configured.

Run the following in a terminal to get the right driver for X loaded, and so we can test what devices we have:-

sudo apt-get install evdev evtest

evdev will likely already be there. evtest allows you to see what devices you have attached, so go attach the USB bit now (you don’t need the control to have batteries just yet). Now run this to see if the remote wonder is detected:-

adam@theatre:~$ sudo evtest
[sudo] password for user: 
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      Power Button
/dev/input/event1:      Power Button
/dev/input/event10:     HDA Intel Rear Mic
/dev/input/event11:     HDA Intel Front Headphone
/dev/input/event12:     HDA Intel Line-Out
/dev/input/event13:     HDA NVidia HDMI/DP,pcm=9
/dev/input/event14:     HDA NVidia HDMI/DP,pcm=8
/dev/input/event15:     HDA NVidia HDMI/DP,pcm=7
/dev/input/event16:     HDA NVidia HDMI/DP,pcm=3
/dev/input/event2:      X10 Wireless Technology Inc USB Receiver
/dev/input/event3:      X10 Wireless Technology Inc USB Receiver mouse
/dev/input/event4:      Microsoft  Microsoft Basic Optical Mouse v2.0 
/dev/input/event5:      em28xx IR (em28xx #0)
/dev/input/event6:      Lite-On Technology USB Productivity Option Keyboard( has the hub in # 1 )
/dev/input/event7:      Lite-On Technology USB Productivity Option Keyboard( has the hub in # 1 )
/dev/input/event8:      HDA Intel Line
/dev/input/event9:      HDA Intel Front Mic
Select the device event number [0-16]:

(Hit Ctrl+c to close the app at this point).

As you can see from the above the Remote Wonder is device /dev/input/event2 . We could configure X to use this but the problem is these event numbers tend to change on reboot, so you have to do something a little unique. Here’s my xorg.conf:-

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
#    InputDevice "Remote0" "SendCoreEvents"
    Option         "Xinerama" "0"

Section "Files"

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"

Section "InputClass"
    Identifier     "Remote0"
MatchProduct "X10 Wireless Techology Inc USB Receiver"
MatchDevicePath "/dev/input/event*"
    Driver         "evdev"
    Option         "event_key_remap" "402=112 403=117 377=156 389=157 352=36"

Section "InputClass"
   Identifier  "RemoteMouse0"
MatchProduct "X10 Wireless Techology Inc USB Receiver mouse"
MatchDevicePath "/dev/input/event*"
   Driver      "mouse"
   Option       "Protocol" "PS/2"
   Option       "SendCoreEvents"

... other stuff about monitors after this...

I’ve used InputClass instead of InputDevice. This means you don’t link to them in the ServerLayout, hence the commented out InputDevice highlighted above in that section. Using InputClass allows you to match by the device product name reported by evtest, and match anything in /dev/input starting with event, which means no matter what event number it gets loaded as this declaration will work.

I have the mouse declared too as a PS/2 mouse. I haven’t customised the mouse Options to simulate a three button mouse, and thus allow autoscrolling in Firefox, but I’ve not tested that yet. I’ll post back when I’ve tried it. For now though the above works great.

The Option event_key_remap line for the keyboard part of the remote is for the future, as yet untested by me, evdev alteration that allows remapping of key codes above 255 to lower key codes so that the X server can handle it.

Once the above is done you need to edit your ~/.Xmodmap so that the relevant keys are mapped to their Myth TV equivalents:-

keycode 164 = S
keycode 123 = F11
keycode 122 = F10
keycode 121 = F9
keycode 147 = M
keycode 104 = I
keycode 160 = F8
keycode 140 = W
keycode 176 = Left
keycode 208 = P
keycode 167 = Right
keycode 175 = R
keycode 136 = Escape
keycode 127 = P

I saved these files, rebooted the machine (sudo reboot) and lo the remote worked fine. Had a few typos originally which caused X not to load. I basically ran the following and you get some useful output to diagnose issues:-

tail -n 50 /var/log/Xorg.0.log

It should give you a line saying there’s an error on line 43 (or similar). From this it should be pretty clear what’s wrong. The error reporting is pretty good.

I then installed a plugin for Firefox called FxKeyboard. I then increased the default font size to 26 and used my normal mouse and keyboard (I’m lazy like that) to add all the catch up TV services, Lovefilm and Netflix sites as tabs to Firefox and pinned them as App Tabs. Then configured Firefox to open up previous tabs on startup. All these are simple options to find and configure in Edit > Preferences in Firefox.

Further information:-

Xorg mouse driver options (for 3 button emulation, etc.) –

evdev modified driver home – – WARNING: Use the following instead of git pull (you may need 2.7.0 for newest Ubuntu or X versions): git checkout -b code-remap-2.6.0 origin/code-remap-2.6.0


Home tech update…

Decided to take some time to revamp our HTPC (Home Theatre PC). Had Ubuntu 10.04 with XBMC on it. XBMC is a great idea but, like so many other things in free software these days, often doesn’t work out of the box. Updated Ubuntu and actually put a 64 bit build on the box (weirdly used a 32 bit image before – I think because I used the XBMC live CD to install) Decided not to bother with XBMC at all this time. We tend to use our TV and PC to either watch live TV or catch up TV, with the occassional Netflix/Lovefilm streamed movie. As it turns out XBMCs browser support sucks too. Decided to opt for just Myth TV on an Ubuntu box.

Myth TV is a great user interface, probably one of the best EPGs I’ve seen on any TV. I bought a PCTVSystems NanoStick DVB-T2 290e USB Freeview HD device which works out of the box with the latest Linux Kernel. This comes with a great mini antenna of its own, but also a normal aerial adapter. I was quite impressed with the reception of the antenna. Myth TV worked great with the backend (that records and received TV programmes) and the frontend (with the user interface and playback) on the same machine.

I hit a few annoying issues when running the frontend on a different machine. This is quite surprising when you think about it – a lot of the time these days you have multiple PCs and TVs in the house and if you don’t like being forced to sit through Coronation street it’s handy to relegate the missus to a different room! You would think Myth TV would support having remote Frontends out of the box. Unfortunately even though it configures 99% of the MySQL database backend it neglects the ability for the mythtv database account to connect remotely. Also, surprisingly, the mythtv db account fails locally when used from a transcoding perl script. This means logging in to MySQL as root and adding a ‘mythtv’@’*’ account and granting it all permissions on the mythconverg database. Plenty of websites with this on, just search for ‘MythTV database permission denied’.

Once those teething issues were sorted it worked well. Quite possibly the sexiest feature of Myth TV, and one that’s quite undersold in my opinion, is the ability for an Android phone to use the Mythmote application to act as a Myth TV specific remote control for a front end! Most people have their phones connected to their wifi at home, so this remote control app is a brilliant idea. It uses the local network rather than infrared to control a Myth Frontend. It also supports saving multiple front end locations, so the same app can control the living room (HTPC) frontend, my laptop frontend, or my mac mini front end. Great idea!

Also decided to set up the Myth Frontend for Mac. This was a massive, massive let down. Turns out the playback on Myth Frontend 0.25 on the mac has had hardware accelerated graphics disabled, meaning its nigh on impossible to watch any HD channels or HD recordings. This was done because the method Myth TV uses on the mac (DVADecoder) causes a kernel panic on interlaced playback. I logged a bug/feature request for them to use Qtkit instead for HD playback. This was immediately closed as invalid which bemused me. Their argument was that Qtkit wouldn’t give them a ‘Myth style playback’ i.e. pause/resume on live TV. My position is that HD playback without pause is better than no HD playback at all! They disagree. I managed to find a 32 bit build with DVA decoding enabled (at the moment even if you select it in the frontend, it will fallback to opengl!). This 32 bit build works great. A bit of an overreaction disabling all playback via DVA if sometimes it doesn’t work – you can always select a different playback option (and indeed DVA isn’t turned on by default anyway!) so their decision to do this is a bit bizarre.

I suspect a lot of the problem in linux born opensource projects is that the Mac is a second class citizen. A classic example of this is the way the bug closer responded to my bug. He said I should either install linux instead of Mac OS X or upgrade my hardware! Given I said I had a Macbook Pro and I use OS X because I don’t want to use Ubuntu (I use laptop for video editing), I found his reply utterly ridiculous. I’d expect better from a Windoze developer to be honest. It seems there is little appetite to work on Mac ports of mainstream software. If it ‘works on my machine’ they don’t particularly care about anyone else.

Managed to resurrect my Mac mini. This had a hard disk issue. Now got it set up with a new disc and Snow Leopard. I’ll use this to power the spare HD flat panel upstairs. I’m going to mount this on the wall between my two windows. I have a great view of the Peak District from the top floor here in my home office. I’ve often wondered if one very long window would be better, so am going to use the TV when not in use to displa the best HD photos of the peak district, and ones of myself and my fiancee climbing locally, so I always have a good weather picture to motivate me during the day.

Also looking at creating a live data feed set up for this screen. I’d like a mix of local (system, tv, network) and remote (stocks, news, email) alerts to show on it. Looking at using a web browser as the client. This would mean I can follow up on any news items from whichever computer I’m working on rather than be forced to use the mac. I want to keep the server side stuff to a minimum so am looking at node.js. Need to see if I can use that to access local system info, and mythtv (so mysql), as well as remote news feeds. Didn’t want to use a mix of programming languages as this would have meant at some point a complex mish mash of server side communication. Hopefully node.js has modules to do a lot of these facilities on the backend. I don’t need anything complicated really, just the ability to execute local commands (I can always write a script to do something) or fetch a remote URL.

Home office design principles

I would love to have lots of monitors and computers rocking in the home office, but I just can’t stand the fan noise. Also annoyingly although my hearing for speech isn’t great, I have the uncanny ability to walk in to a room and hear exactly which electronic devices are turned on. There is a very low volume hum to all devices, and that high pitched noise drives me crazy. This means I want a very quiet office. This has a few design implications though…

Firstly I can’t have a beast of a machine running a whole bunch of monitors. The heat the graphics cards would kick off would necessitate some crazy cooling systems. This also means my Home NAS box I’m wanting to create needs to be pretty quiet. Found a cheap 25 GBP coolermaster case on Overclockers UK, but then what to do about the hard discs? I would get 4-6 SSDs, but trying to get up to the minimum 2 TB (and thus 4TB on RAID 6/10, minimum 4 discs) would be ridiculously expensive. I think I’ll minimise the heat from the machine itself and hope the coolermaster case can keep the drives cool whilst staying quiet. It should manage it because it’s not like I’m using the same machine to rock a bunch of graphics cards, and those cases are designed for gaming applications so the cooling should be good.

I also hate boxes lying around. I’ve been coerced in to keeping my various bits of techie kit (cables, keyboards, 10 year old memory – be honest, you all have these boxes!) in my office. They just get in the damned way. Would love to put them in the loft but its currently not got a ladder or flooring up there. Need to convince the missus that this would be a ‘good idea’. I’m going to try to include some low profile shelving in the office somewhere to store small item boxes, one for RAM, bigger one for cables, etc etc.

Also running out of room in the Library (yes, I have a Library – mainly because I just love Cluedo…)  and am getting fed up running downstairs for reference books. I’m gonna be leaving room between my windows, HDTV and radiator to fit a full A4 / Letter size book shelf. May also put a corner bookshelf above the rear corner of my desk too. Should be able to use this to store some of the smaller often used gear on.

Something else I’m keen on doing is having my own mini museum in the office. I have a few oldies that I’m sure you’ll have heard of. Oldest one is a Tandy TRS-80 Color Computer (“With 1KB RAM!!!”), then an Atari 65XE where I learnt most of my coding. Also have a Compaq iPaq running Linux on it. May use that as a console for the FreeNAS (FreeBSD 8.2) storage machine via USB Ethernet. Just because I can. 8o) Wrote my dissertation on that little pad with a plug in keyboard. Turned a few heads in the library at Uni given it was only early 2002 and the concept was very new. Don’t own a tablet now. Waiting for a PadFone… which will instantly have a terminal emulator put on it naturally.

So to sum up:-

  • Quiet office. Like insanely quiet. We’re talking 16dB max, which is just above a whisper
  • Information at my fingertips for working – 2/3 monitors (yet to figure out how best to do this)
  • Media accessible in the room from dedicated hardware (Mac mini has dolby 5.2 optical out too happily enough – may end up taking advantage of that)
  • Tidy with nothing on the floors, paper destroyed and banished, CDs transferred to the NAS and destroyed (they take up sooo much space)

Should be pretty awesome.

Home Office 2.0 revamp…

Been rejigging the home office so it’s nicer to stay in and I don’t end up running all over the house for cables, computers, and to access music.

Now got the blinds cut to size and mounted. Required a bit of maths to figure out. Only a couple of mm out here and there which isn’t bad, especially as I didn’t use a spirit level. Below is a picture, although it doesn’t really do it justice! The Blinds are actually bright Orange from Dunelm Mill. Had to cut the width because the next size down was too narrow, so I’ve matched the width of the fabric on these larger blinds to that of the window sill. Also reversed the direction of the blind so the brighter Orange is on the inside, and it sits flush against the wall rather than an inch off the wall. Because the room is used as a bedroom also I wanted to be able to almost black out the room for the benefit of our guests.


As you can see I now have a blank space on the house outer brick wall which is conveniently slightly larger than the 26 inch flat panel HDTV you see on the left. 8o) Next trick is to mount a 180 degree left/right, 20 degree up/down, extendable arm to the wall and attach the flat panel.

Found the bracket at . Bought it from here because their site is absolutely fantastic at telling you exactly what options you have for your specific TV. Also tells you if you need a vesa adapter bracket. Great site, good fast delivery, highly recommended.

Having trouble finding the correct screw to use for the wall bracket. The bracket assumes a 1 3/4 inch screw will suffice. Problem is modern British homes’ external walls have 1/2 inch plaster board with a 1/2 inch cavity before a breeze block and brick outer. This means I need four 3 or 3 1/4 inch screws because the first inch isn’t going to provide any support. You don’t want any longer screws because you don’t want to weaken the breeze block. They are however a pig to get hold of. They need to be 6mm / size 12, so bit of a pain really. Tried Wickes, B&Q and Screwfix. Wickes had the screws but no plugs for them, and B&Q had a space for the screws, but none there, and again no raw plugs that would work.

I think I’m going to have to risk getting the screws from wickes and 2 inch raw plugs, and push the plugs through the plasterboard down to the brick layer, so this should work well.

After this I have to fix the Mac Mini and use it as the controller for the HDTV. Idea is I’ll have the Mac act as a Myth TV client for my HTPC down stairs, as well as accessing iTunes movies, music videos and albums. I can use it then for work to entertain me or have the news in the background whilst working. Can’t stand a silent room.

Another cool idea I had was getting an external web cam and placing it on the outside wall directly behind the HDTV. That way I can have the HDTV as a virtual window, giving me a full panorama of the National Park! Might be a bit over the top given the hassle of getting a cable from the outside, and mounting the thing on the top of three floors! I could always take a photo as a stop gap measure to see what it looks like.

I’ve ordered a nanoStick T2 which is a Freeview HD (DVB-T2 for non brits!) USB receiver. Got it for only 55 GBP on I’m going to set up Myth TV with it to record freeview shows. I can then copy them to t’other halfs Macbook Air so she can watch soap operas when at the outdoor centre (and so I no longer have to endure them!), or stream it to the HTPC in the living room, or just watch it on the HDTV in the spare room. Should be an awesome set up, especially as Myth TV on the Mac supports the Apple Remote.

Upgraded the old Mac Mini Solo (Feb 2006) to have more RAM, also replacing the (unsurprisingly) knackered Seagate HDD which are notorious for dying. Should get decent performance then. Also means I can use iTunes natively on that machine to play music in the home office rather than stream to my work pc, which is a bit of a pain at the moment.

There are some great projects out there for inspiration. I think most people have seen Stefan Didak’s home office set up. From his site he links to many other people with high end office set ups. There are some pretty awesome offices. Check out this list of the Top 96 kick ass home office set ups. My favourite weirdly is the Hacker set up. Reminds me of the faraday cage from the film Enemy of the State. I’m normally a more modernist clean design person when it comes to the house.

There are some set ups out there with 10+ monitors. Some people have criticised them, but as a developer I can totally understand these set ups. I’ve always had a mix of 4 to 6 virtual desktops on my Linnux and now Mac OS X machines. (Although Lion has screwed up the 2×2 by enforcing a horizontal ribbon for reasons passing understanding). A typical set up for me is to have media playing in the background, so that’s on the top left virtual desktop 1. Development environment typically on Virtual desktop 3, maximised for greatest code editing area. Next to this on desktop 4 is web browser. I open up any documents for reference then on virtual desktop 2.

I hate paper. I’ve worked in pre-sales for Enterprise Content Management (ECM) companies and have a visceral hatred for paper, printers, box files, and anything with ‘Iron Mountain’ written on it. Not because I hate the company, but because it’s a solution to a problem which should no longer exist. Just ditch the paper! </rant>

Anyway, that’s 4 desktops without even trying. Ideally I’d like to offload the media from the machine I’m working on – it tends to just sit in the background anyway. Also I always end up reading one thing whilst writing another. A portrait orientated monitor on the left for docs would help. Centre monitor would have to be for writing and the main work area, mainly to minimise turning or neck strain. Maybe a right hand monitor for reading something else too or refering to something.

This would give me, for example, a tutorial or dev guide on the left portrait monitor, development environment in the centre, and firefox test instance showing me what crap I’ve just developed/broken on the right. Only other thing I’m missing which would be handy are alerts and notifications. Sold (or tried! LOL) enough Business Activity Monitoring (BAM) solutions in my time to know that the concept is a very powerful one.

Stock brokers often rock 4-6 monitors for watching activity and trading. I’d like to see my own stock portfolio with a 15 min delayed view of prices, maybe visual alerts for ‘sell them and retire’, that sort of thing! Also handy would be an updating news feed incorporating twitter (which for some reason doesn’t update itself – which astounds me why it requires a click), facebook, news RSS (because the BBC ‘news’ website main page doesn’t update, but the RSS feed has many hidden gems).

Housekeeping items like todo lists from the missus (maybe sourced from Evernote), calendar upcoming events, home network usage (probably at 0.3% – it’s a Cat 6 gigibit Ethernet with hardly anything traveling over it). Thinking of creating a simple (for me) local web page that uses DoJo / jQuery and JavaScript API to load the information and display it. Should be easy on today’s Interwebs (coff, splutter).

If anyone has any cool ideas or photos for inspiration do let me know. More to follow.

One workstation, multiple displays, multiple computers…

I’ve been plotting an upgrade to my home office to make the day to day working environment much better. This will result in a range of computers used at the same station, with potentially multiple monitor setups, some remote sessions (currently via vnc), live data screens. Could do a variety of things really. Want a system for managing the displays but existing mechanisms have limitations. Some solutions, like Synergy2, allow multiple computers to share the same input devices via a ‘server’ computer. This works great if all the machines are plugged in to their own monitor(s), but what if you want to use, say, three screens with a particular computer that only has one DVI output on it?

E.g. if you have a Macbook Pro with crappy Lion on it that sucks as using virtual desktops and you want it to have 4 proper desktops but lo, you only have one output? Various ways around this of course. You have XFree86 window servers as targets, you can have a beastie computer manage the desktops and VNC in (although this gives only a single desktop). I wondered if a better solution existed though. Afterall a modern home office network with Cat 6 kit is more than capable of carrying high def raw data. E.g. HDMI over Ethernet. So why not allow any computers to share their physical monitor and share this capability via Bonjour. You could then have a virtual remote monitor graphics driver streaming a raw HDMI signal, for example, to this output.

This approach would have limitations – it would take over the entire monitor feed potentially, and only gets you the display portion, not the control portion. (Although you could do this via some sort of HDMI-CEC keyboard and mouse driver). I think whatever solution you have it needs to be neat and simple and require minimal coding on the systems. I would imagine most OS’ have libraries capable of outputting a variety of common formats. HDMI would normally be done by a graphics card though or motherboard graphics controller, so might not be appropriate for this usage.

Its the age old problem of KVM – Keyboard, Video and Mouse. Synergy2 gets you the K and M part, but doesn’t handle sharing a physical display on one machine as a virtual display on another. Maybe pursuing some sort of modification to Synergy2 would work well? It already supports Windows, Mac and Linux and is Free Software. You’d need some sort of ‘physical device server’ and ‘virtual device client’ mapping to handle this, but should be relatively straight forward. The hardest bit will be getting the OS to treat a piece of software as a display. I suppose there is always the Frame Buffer monitor type that would allow this to be done arbitrarily. Once this is done, support for multiple mapping presets would effectively let you do what I personally need – so ‘All three monitors to macbook pro’ or ‘all three monitors to work PC’. Others may wish to vary combinations depending upon task. E.g. if in ‘work’ mode then the work PC has two and the macbook as one (for iTunes say), and a ‘home’ configuration to reverse which machine has 2/1 monitors.

I’m going to post to the Synergy2 questions site to see if this is feasible. In the meantime I’ll try and write a virtual monitor driver for my mac. I’ll start by creating a 1024×768 virtual display that shows the output on the macs physical display…