GNU/Linux

Martin's
GNU/Linux Projects

To Home Page

Media PC - one device and one remote for all media

Last modifications: 16 September 2017

Introduction

On this page I describe how I built my media PC. With this PC you can watch television, watch movies from DVD and hard disk, listen to music and view photo's. My media PC can be controlled with an infrared remote control.

All the information on this page is about a setup using:

Do you also like to build your own remote controlled media PC? Read on and hopefully you will find some useful information here.

Why using a media PC?

Remote controll stress

Now that photo's, music and video (including television) are all available in digital format, you actually need only one device to have access to all this media: a computer!

Still, people try to sell us smart TV's, DVD and Blu-ray players, hard disk recorders and streaming media players. All these devices come with their own remote control and their own user interface. I do not like that. Furthermore, the use of these devices is restricted by the features built in by the manufacturer. I do not like that either!

So when I decided to replace my old bulky cathode ray tube television, it was clear to me I would not buy an expensive smart TV. Instead I bought a second hand computer and a HD LCD computer monitor to build my own ultra smart media PC!

What it looks like

Below you can see some screen shots of my media PC to give you an idea what it looks like. Click on an image to view a larger version.

My media PC desktop with media shortcuts (Xfce desktop environment):

My media PC desktop (Xfce desktop environment)

Watching television with Me TV:

Watching television with Me TV

Listening to music using Banshee media player:

Listening to music using Banshee media player

Watching a DVD with VLC media player:

Watching a DVD with VLC media player

Enjoying my pictures with Ristretto photo viewer:

Enjoying my pictures with Ristretto photo viewer

Switching between open application windows:

Switching between open windows

My hardware setup

Below you find a picture of my hardware setup. It consists of:

  • Dual core PC
  • High-definition LCD/LED computer monitor (28 inch)
  • Stereo amplifier
  • Great sounding speakers (JBL LX44)
  • DVB-T USB stick with antenna (DVB stands for Digital Video Broadcasting)

My infrared receiver and remote control are not shown in the picture below. They are described in the next section.

My hardware setup

Some remarks:

  • I use a Ultra-Small Form Factor PC with a horizontal desktop case, that fits easily in my TV rack.
  • With the DVB-T USB stick and a small antenna, I receive 4 Dutch channels from the air for free. That is enough TV for me. If you need more channels or better quality, use a DVB device for cable (DVB-C) or satellite (DVB-S).
  • I really like my two JBL speakers so I chose for a stereo setup. But you can also make a surround sound setup, if you like.
  • My media PC is connected to my home network so I can access all the media files on my NAS (and other computers). Surfing the Internet is also possible (of course!).

Controlling my media PC

To control my media PC I use a home made infrared receiver and a universal infrared remote control. The software I use is LIRC (Linux Infrared Remote Control). Read more about this software in the section How does LIRC work?

Remote control

You need quite a lot of commands to control a computer. So I chose a universal remote control with enough buttons to configure all the commands I like to use (41 all together!).

General commands:

Universal remote control
  • enter
  • escape
  • go up, down, left, right
  • page up, down
  • go one level up in file browser
  • enter numbers 0-9 (to choose TV channel)
  • delete

Desktop commands:

  • show main/start menu
  • show application menu
  • show context menu
  • show window menu
  • show desktop (hide all windows)
  • switch between application windows
  • go to next, previous window (or window panel)
  • close window
  • show window in full screen mode

Media commands:

  • play/pause
  • stop
  • forward or next
  • rewind or previous
  • record
  • show TV program guide or DVD menu
  • raise, lower volume
  • mute sound

Infrared receiver

Receiver built in serial connector

I have built the infrared receiver myself. It is cheap and fun to do (if you like soldering). To be able to use this receiver, you need a computer with a serial port. The receiver is very small and fits into a serial connector (see image). It works great with the LIRC software and my remote.

Read how to build your own serial receiver.

You can plug in the receiver directly into the serial port on the back of your computer. This will work well if the wall behind the computer is light enough to reflect the infrared signals from your remote.

Choosing your remote & receiver

If you are planning to use LIRC, make sure your remote and receiver are supported.

See "Supported Hardware" on the LIRC homepage.

Mouse & keyboard

In stead of using a remote, you could also use a wireless mouse (and maybe a keyboard) to control your media PC. This will save the effort of configuring LIRC and making it work.

I hooked up a wired mouse and keyboard. I use them in case controlling with a remote becomes to cumbersome. For example, if I want to do a quick search on the web.

The software

Below you find a list of software I use on my Media PC.

Some of the system software I use
Xfce Lightweight desktop environment that looks nice and runs on older computers.
LIRC Software to control your PC with an infrared remote control (read more in the next section: How does LIRC work?).
xte Program to fake keyboard strokes and mouse movements. I use it in combination with LIRC tool irexec (see LIRC configuration). Part of the Debian package xautomation.
banshee-
extension-lirc
LIRC plug-in for Banshee.
DesktopNova Program that turns your desktop background into a slide show (for Gnome and Xfce based systems).
Unclutter Utility that hides the mouse pointer after a period of inactivity.
Compton Compositor featuring tear-free video (see Tear-free video).
 
The applications I use most
Me TV Easy to use application to watch and record television. If you want a more sophisticated TV application, try MythTV. No support for LIRC but you can control Me TV with xte and LIRC tool irexec (see LIRC configuration).
VLC Media player that plays almost every video format, including recordings made with Me TV. Plays DVD's as well (with DVD menu's that can be controlled with your mouse, keyboard or remote). LIRC is supported by VLC.
Banshee Application that allows you to manage and play your music, rip CD's, listen to Internet radio and more. LIRC is supported via the Banshee LIRC plug-in.
Ristretto Fast photo viewer. If you want an application that also manages your photo's, you could try Shotwell. No LIRC support but you can control Ristretto with xte and LIRC tool irexec (see LIRC configuration).

How does LIRC work?

LIRC

Before actually setting up LIRC, first let's see how it works. In the picture on the right you can see the data flow between the hardware and software components of my LIRC setup.

When you push a button on your remote control, it sends out an infrared data signal. The infrared receiver receives this data signal and via the serial port and the lirc_serial device driver the data is sent to the lircd daemon.

The lircd daemon translates the "infrared data" into the name of the remote control button that was pushed. The translation (decoding) is defined in the configuration file lircd.conf. Each type of remote has its own lircd.conf file.

See my lircd.conf file to get an idea how a configuration file looks like.

Applications with LIRC support receive the name of the pushed button from the lircd daemon and a specific action is executed. For each button on your remote control you can configure an application and the action it has to execute. This is done in the .lircrc configuration file.

Take a look at my .lircrc file and see how applications and actions are assigned to remote control buttons.

LIRC configuration

As stated in the previous section, LIRC uses the configuration files lircd.conf and .lircrc.

Configuration file "lircd.conf"

The LIRC daemon lircd uses the lircd.conf configuration file to translate "infrared data" sent by your remote, into the names of the remote control buttons. On the LIRC website you can find configuration files for about 2500 different types of remote controls.

If your remote control is not in the list, you can create your own configuration file. You need the tool irrecord (part of LIRC) to do this. Typical usage:

   $ irrecord -d /dev/lirc0 lird.conf

The tool irrecord will ask you to push buttons on your remote and will also ask you to enter the names of the buttons. This whole procedure will take some time! The output is written to the file lird.conf in the current directory. Read more about irrecord on the LIRC website.

Configuration file ".lircrc"

Applications with LIRC support use the .lircrc configuration file to see what action has to be taken when a certain remote button is pushed. Below you find some examples. A more detailed explanation about the .lircrc file format can be found on the LIRC website.

.lircrc example (1)

Play the next song in Banshee music player with the forward button on your remote:

   begin
     button = forward
     prog = banshee
     config = next
   end

A special application is the LIRC tool irexec. It is used to execute other applications.

.lircrc example (2)

Start VLC media player using the AV button:

   begin
     button = av
     prog = irexec
     config = vlc
   end

I mainly use irexec in combination with xte to generate fake keyboard strokes. For example, if you want to close a window using your keyboard, you press Alt+F4. To close a window with a button on your remote, you can use irexec and xte to fake the Alt+F4 keyboard strokes.

.lircrc example (3)

Close a window with the power button, using xte:

   begin
     button = power
     prog = irexec
     config = xte 'keydown Alt_L' 'key F4' 'keyup Alt_L'
   end

You can also use the LIRC tool irxevent to generate fake keyboard presses. But I find this tool more complicated than xte and it does not offer extra features that I need.

Setting up LIRC

One of the problems I ran into was the fact that the standard LIRC startup script in Debian does not work for my setup. So I made my own startup script. I call the script from /etc/rc.local. You can easily test this script by running it from a terminal as root.

Startup script LIRC daemon

Download: startlirc.sh

   #!/bin/bash

   # Startup script for LIRC daemon with home-brew serial port IR receiver

   # Create directory /var/run/lirc/ (needed by lircd)
   mkdir /var/run/lirc/

   # Free serial port
   setserial /dev/ttyS0 uart none

   # Load lirc_serial module (device driver)
   # This will create device /dev/lirc0
   modprobe lirc_serial

   # Start LIRC Daemon
   /usr/sbin/lircd -d /dev/lirc0

Finally a summary how to install, configure and start LIRC.

How to set up LIRC

  • Use your package manager to install the packages setserial and lirc.
  • If you want to use irxevent, also install the package lirc-x. If you prefer xte, install the package xautomation.
  • Find the right lircd.conf file for your remote control in the LIRC remote database. If you can not find a configuration file for your remote, use irrecord to create one.
  • Place your lircd.conf file in the directory /etc/lirc/.
  • Create a .lircrc file and place it in your home directory.
  • Disable the standard Debian startup script. To do this open a terminal, log in as root and type:
    $ chmod 644 /etc/init.d/lirc
    
  • Instead of the standard startup script, use the script above. Call this script from /etc/rc.local.
  • Use the autostart feature of your desktop to start irexec (in this way irexec runs as a regular user in the background, as it should). Do the same for irxevent if you want to use this tool.
  • Do not forget to connect your serial infrared receiver to the serial port of your computer!

Tear-free video

If you experience video tearing, you may try the compositor Compton to solve this. The setup below worked for me.

How to set up Compton for tear-free video

  • Use your package manager to install the package compton.
  • Make sure that no other compositor is running (in Xfce use Window Manager Tweaks to disable compositing).
  • Start Compton as follows:
    $ compton --backend glx --paint-on-overlay \
              --glx-no-stencil --vsync opengl-swc -b
    
    Call this command using the autostart feature of your desktop.