Running MythTV Dual Headed

From MythTV Official Wiki
Revision as of 03:01, 2 December 2005 by Kkuphal (talk | contribs) (DualHeadedMythHowTo moved to Running MythTV Dual Headed)

Jump to: navigation, search

This little 'HowTo' lets you run two instances of Myth on the same machine.

There are many ways of using 2 screens - this just addresses one way - feel free to add more...


I use this because I have a TV and a projector connected to my Myth box. It could work for people who want to play games on an accelerated VGA display and watch TV on a PVR350.


Linux is a multi-user OS - so you simply create a second myth user and use it to run mythfrontend.

I end up with 1 instance of mythfrontend running through my PVR350 to my TV (accessed through Virtual Terminal 7) and another running through my NVidia card to my projector (on VT-8).

So first create a new user (I used mythbig)

Logging In

Here's the /etc/init.d/ script I use

#! /bin/sh
# Originally based on:
# Version:      @(#)skeleton  1.8  03-Mar-1998
# Modified for projector David Greaves 12/Jul/04

set -e


case "$1" in
        chvt 8
        nohup su - mythbig /home/mythbig/runx >>/var/log/projector.log 2>&1 &
        echo "Usage: /etc/init.d/projector {start|stop}"
        exit 1

exit 0

(chvt is a fantastic command - possibly worth putting in your .lirc file)

Starting X

You'll notice it calls a script : runx it's only a 2 line script:

 export QT_XFT=1
 xinit  -- :1 -layout Projector

But notice it uses

:1 to create a new X display (as in the DISPLAY variable - the normal one is hostname:0.0 - this one will be hostname:1.0) and
-layout - this corresponds to a LayoutSection in your XF86Config-4 confg (see later)

Now we need an .xinitrc file. This is like a .profile for X and it contains commands that are run when X starts:

 xsetroot -solid black
 xhost +
 nvidia-settings -l --assign="[[Sync To V Blank]]=1"
 mythfrontend -v &

When the last command finishes, X stops. I don't have this set to continually restart but you could easily do so.

Configuring X

OK, the infamous XF86Config-4...

This is a bit more complex but not a lot. You need to realise that this file contains lots of little sections. Not all of them are used all the time. Normally X looks for the first 'ServerLayout' and then looks to see what other sections are referred to. It keeps doing this down through Screens, Monitors, Devices, InputDevices etc etc. So here the first ServerLayout is used by default, the second (which refers to a different screen which in turn refers to the MonitorSection called Projector and the Nvidia Device) is what we specify by name back in runx:

Section "[[Server Layout]]"
       Identifier     "TV"
       Screen      0  "TV"
       [[Input Device]]    "Keyboard0" "[[Core Keyboard]]"
       [[Input Device]]    "PS/2 Mouse" "[[Core Pointer]]"
       Option "Xinerama" "off"
[[End Section]]

Section "[[Server Layout]]"
       Identifier     "Projector"
       Screen      0  "[[Proj Screen]]"
       Option          "Xinerama"      "off"
       Option          "[[Allow Mouse Open Fail]]"
       [[Input Device]]    "PS/2 Mouse" "[[Core Pointer]]"
       [[Input Device]]    "Keyboard0" "[[Core Keyboard]]"
[[End Section]]

Configuring Myth

Myth uses a .myth directory in the users home directory. In there is a file called mysql.txt which tells mythfrontend where to get all it's settings from. Now Myth stores this information on a per-hostname basis - so we need to tell a white lie. Here's what mine looks like:

[[D B Host Name]]=localhost
[[D B User Name]]=mythtv

# Set the following if you want to use something other than the
# machine's real hostname for identifying settings in the database.
# This is useful if your hostname changes often, as otherwise
# you'll need to reconfigure mythtv (or futz with the DB) every time.
[[Local Host Name]]=bao-projector

The 'LocalHostName' value is the one you care about, and as the comment says, it must be unique.

All Done

Now you can easily switch (ctrl-alt-F<x>) between TV and VGA screens.

On word of caution: you may have problems sharing the sound/dsp device if you switch whilst it's in use)

Hope this helps

--David Greaves

Lazy Man Commercial Solution

I run mythfrontend on a Groovix linux system. The main console is used by the family for day to day stuff (email etc.) The secondary console is used for mythtv. I'd say it works quite well and was a lot less work than setting it up myself.

-- Matt Welland