Ubuntu MythTV Client
Based on Ubuntu 18.04 / MythTV 0.29, differences for newer versions noted in the text.
Configuring Ubuntu 18.04
- Install Ubuntu Server.
- Ubuntu 22.04 does not appear to set the timezone correctly, run
sudo timedatectl set-timezone Europe/London
to correct it.
- At the Software Selection screen, none of the options are required (i.e. core system only).
- Install the required programs with apt:
sudo apt install mythtv-frontend ratpoison xinit x11-xserver-utils xloadimage xfce4-terminal alsa-utils
- For Ubuntu 20.04 and later, run this command instead:
sudo apt install --no-install-recommends mythtv-frontend ratpoison xinit x11-xserver-utils xloadimage xfce4-terminal alsa-utils xserver-xorg-core xserver-xorg-video-all xserver-xorg-input-libinput
- For an Ubuntu 22.04 “minimized” install, you will also need to install
netcat-openbsd
- If you have an Intel graphics card, you may also need to add
i965-va-driver
(see Configuring MythTV 0.29 below)
- Copy
/etc/mythtv/config.xml
from your MythTV Server to this machine (or edit the pre-generated file to fit). - Edit the
/etc/sudoers
file so the MythTV user can manage the machine:sudo visudo
- Add the following line to the bottom of the file:
mythtv ALL=(ALL) NOPASSWD: /sbin/shutdown *, /sbin/poweroff, /sbin/reboot, /usr/bin/apt *, /usr/bin/systemctl * mythtv-backend
- Save and exit with
Ctrl+X
,Y
.
- Override the main console login:
sudo systemctl edit getty@tty1
- Enter the following text into the file:
[Service] ExecStart= ExecStart=-/sbin/agetty --autologin mythtv --noclear %I $TERM
- Save and exit with
Ctrl+X
,Y
- Change the mythtv user's shell (so the auto-start code works, also makes setting up easier):
sudo usermod -s /bin/bash mythtv
- Switch to the mythtv user (so the files you create will be owned by the correct user):
sudo su mythtv cd ~
- Create
.bash_profile
to auto-start the GUI:nano -w .bash_profile
- Enter the following text into the file:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then printf " Starting MythTV..." until netcat -z *mythtv-server* 6544; do sleep 1; printf "."; done sleep 1; printf "."; sleep 1; printf "."; sleep 1; printf "."; sleep 1; printf "."; sleep 1; printf "."; sleep 1; printf "."; sleep 1; printf ".\n"; startx > /dev/null 2>&1 printf " Restarting..." sleep 1; printf "."; sleep 1; printf "."; sleep 1; printf ".\n"; logout fi
- Make sure to replace
*mythtv-server*
with the IP address of your MythTV server (and remove the stars). - Briefly, what this (very hacky) code does is:
- Check if it is being run on console 1 (this means you can login to the the
mythtv
user elsewhere and not have the GUI auto-start on you). - Print a 'progress bar' so you can see the machine hasn't hung.
- Wait for the MythTV Server to become available before starting the GUI (otherwise it looks like the GUI has hung when really it is waiting for the server).
- Starts the GUI/MythTV Client.
- When the GUI exits, confirms that the GUI is about to be restarted.
- Adds some hard-coded delays to stop the whole thing cycling too fast to do anything useful (especially if some weird error is occurring, humans need time to read!).
- Logs out of the console so the auto-login can kick in again and restart the whole procedure.
- Save and exit with
Ctrl+X
,Y
- Create
.xinitrc
to auto-start the window manager:nano -w .xinitrc
- Enter the following text into the file:
ratpoison & mythwelcome
- This tells
X
(the window 'system') to then startratpoison
(the window 'manager', specifically designed for machines without mice), and then startmythwelcome
(the program we actually want running, the one and only 'window'). - To set the screen size (e.g. in a VM where almost any size is valid but the auto-detected size is usually 1024×768 and unsuitable for standard video playback), add the following to the top of this file:
xrandr --fb 1920x1080 xrandr --size 1920x1080
- You can also use this to reduce the resolution, such as when you have a 4K capable graphics output and screen, but the 4K output is too much for the machine to handle. Limiting it to 1080p can remove some irritating hiccups in the output.
- Save and exit with
Ctrl+X
,Y
.
- Create
.ratpoisonrc
to configure the window manager:nano -w .ratpoisonrc
- Enter the following text into the file:
escape C-a exec xset -dpms s off exec xsetroot -solid black exec xloadimage -border black -onroot -quiet -center /usr/share/mythtv/html/images/icons/upnp_large_icon.jpg exec xsetroot -cursor_name none defwinname name bind x exec xfce4-terminal --fullscreen keystate_numlock = disable
- What this does (in order):
- Set ratpoison's 'escape key' to
Ctrl+A
(this is the key combination you press to tell ratpoison you want it to do something, rather than passing the key to the active window). - Turn off screen power management (i.e. don't blank or turn off the screen, power-saving can cause issues on some graphics card/screen combinations that make it impossible to get the display back without rebooting the machine, also you turn your TV off when you're not watching it anyway, right?).
- Change the background colour to solid black (you won't see it except at start-up and shut-down, but it looks nicer).
- Draw a MythTV icon in the middle of the screen, it looks nicer than plain black and tells you the machine is actually on and hasn't gone to sleep/crashed/etc.
- Disables the mouse cursor (we're not using it anyway, just keeps things looking neat).
- Specifies how windows should be named (probably not important, I don't even remember where I imported this one from).
- Binds the
X
key to start a full-screen terminal, for when you need to work on the machine (this combines with the escape key above, so to start the terminal you pressCtrl-A
,X
). - Disables numlock on the keyboard, if you're using a small keyboard where the numpad is integrated into the main letter keys, having numlock accidentally on can be a nightmare! (Note this doesn't permanently disable numlock, it just turns it off once at startup).
- Save and exit with
Ctrl+X
,Y
.
- Open the volume control utility
alsamixer
:alsamixer
- Increase the volume of (at least) the Master and PCM channels to maximum (100). Use the left and right keys to select the channel, and up and down to change the volume. If either channel is muted (displaying
MM
at the bottom), press them
key to unmute it (displayingOO
at the bottom). - Press
Escape
to save and exit.
- If everything has gone to plan, you should now be able to reboot as the
mythtv
user:sudo reboot
- Rebooting will prove the sudoers edit earlier worked as intended (i.e. the mythtv user can reboot without a sudo password) and will kick-start the auto-login process. You should end up at the main MythTV Frontend screen.
Configuring MythTV 0.29
Note that this section focuses on tweaking the settings that are relevant to the client and will skip over those that affect the server. Effectively this is aimed at setting up an additional client, where the overall system is already up and running.
- Go to 'Setup' (bottom of the list).
- Use the 'Setup Wizard':
- Select your audio device and use
Test Speakers
to confirm sound is being output correctly. There may be multiple variants of your soundcard using different drivers, a bit of trial and error is required here. - Select your video driver and use
Test High Definition
to verify it. Watch for stuttery video and listen for audio stuttering too. Again trial and error is required here. PressEscape
to abort the test if there are obvious issues. You will almost certainly want one of the 'High Quality' options here, unless you need to use the 'VAAPI' driver for which there is only one quality setting.- If you press
m
while the test is running, selectPlayback
thenPlayback Data
you can get some more detailed statistics about the playing video. Most important is usually the CPU usage, if this is hitting 90%+ you probably have the wrong driver. - In general terms:
- Intel graphics use the VAAPI driver
- Celeron J1800, J4105, J4125 need the
i965-va-driver
package (just the chips I've tested, I can't speak for others)
- nVidia graphics use the VDPAU driver
- AMD graphics use the OpenGL driver
- In 'General':
- To navigate these settings menus, use the arrow keys. 'Right' will descend into a sub-menu, 'Left' will return to the menu above. 'Enter' will change the currently highlighted setting. When you are done, press 'Left' until the 'Exit' menu appears, then select 'Save then Exit'.
- Under 'Shutdown/Reboot Settings':
- Change 'Customise exit menu options' to 'Show quit'. This simplifies the exit menu so it is not easy to shutdown/reboot the machine with a miss-click.
- Under 'Remote Control':
- If you intend to use the Android Remote Control app (or telnet!): put a tick in the box for 'Enable Network Remote Control Interface'.
- On MythTV 0.32: Un-tick 'Enable CEC Control Interface' unless you have a remote that works properly through the HDMI CEC interface, in my experience MythTV can wait for a long time loading the CEC interface, so if you don't use it turn it off to skip the wait time.
- Under AirPlay Settings':
- Untick 'Enable AirPlay' unless you have Apple devices.
- In 'Appearance':
- Under 'Theme / Screen Settings':
- Change 'Paint Engine' to 'Auto', if the MythTV interface becomes laggy after this is applied (the change isn't applied until you exit the 'Appearance' section), change it back to 'Qt', most of the time you want 'Auto'. On MythTV 0.32: This option no longer exists.
- Change 'Menu Theme' to 'Media Center Menu Theme'. This is a personal preference, as I use the Videos section probably more than the Recordings section.
- On MythTV 0.32: Change 'Startup Screen Delay' to '0', this means you'll see the MythTV loading screen immediately so it is obvious something is happening instead of appearing to ignore you or hang.
- Under 'Localisation', set it to your personal preferences, these are mine:
- Language: English (United Kingdom)
- Guide Language (1 & 2): English
- Date Format: Sat 23 May 2020
- Short Date Format: Sat 23.05 (I would prefer a slash, but the leading zero is more important to me)
- Time Format: 16:42 (the 2nd one - before 10am you can see this one adds a leading zero, the 1st one does not)
- When exiting the 'Appearance' section, the MythTV Frontend will restart to update the interface, so you will be back at the main menu. If you changed the 'Menu Theme' to 'Media Center Menu Theme' then the settings pages are now under 'Advanced' and then 'Setup'.
- Under 'Theme Chooser':
- Select your preferred theme, you will have to do this twice. The first time the theme will be downloaded, the second time it will be selected and the Frontend will be restarted (again). The new theme may not actually get applied immediately, but it should show up when we restart the Frontend for the final time when finishing the setup.
- My preferred theme is currently 'Functionality', however this can have lag issues in the program guide if you prefer to scroll left and right at high-speed (I think due to the amount of data being displayed all at once), so as an alternative I recommend 'Mythbuntu'. Personally I find the darker themes less obtrusive then a glowing blue screen (the default 'MythCenter') when no video is playing. I just wish it highlighted the current selection a little better (light grey vs. dark grey isn't a good contrast on some displays). On MythTV 0.32: Mythbuntu now uses a yellow highlight for selected text which is helpful.
- On MythTV 0.32: If the theme you want is not listed, press the 'M' (or 'Menu') key, select 'Refresh Downloadable Themes', then exit the Theme Chooser screen and open it again.
- Under 'Audio':
- Leave 'Use internal volume controls' ticked, but press Right to go into the sub-menu.
- Set the Master & PCM mixer volumes to 100. I mostly use external audio controls so it is best to have MythTV outputting at maximum volume (without clipping of course) to maximise the signal-to-noise ratio (i.e. minimise the noise).
- On MythTV 0.32: The default 'Mixer Control' is 'PCM', however I find it works better when set to 'Master', depending on the machine.
- Under 'TV Settings':
- Under 'Playback':
- Under 'General Playback':
- Clear the tick box on 'Clear bookmark on playback'. Occasionally I have issues with my backend video storage and MythTV will timeout while playing. By not removing the bookmark it makes it possible to resume closer to where you where when the timeout occurred, this can be especially helpful if the video happens to be a 7 hour livestream! The flip side is that eventually all of your videos will probably end up with bookmarks part way through and you will have to select 'Play from beginning' if you want to watch it again. On MythTV 0.32: This option no longer exists, but the default behaviour now does this automatically.
- Tick the box on 'Automatically mark a recording as watched'. The 'watched' flag can help the backend manage your recordings better by avoiding deleting stuff you haven't actually seen yet. If you prefer to do this manually or not use this feature at all, leave this unticked.
- Change 'Action on playback exit' to 'Save position and exit'. This automatically creates a bookmark when you exit a video, enabling you to pick up the video from the same point on another device. On MythTV 0.32: This option no longer exists, but the default behaviour now does this automatically.
- On MythTV 0.32: Tick 'Playback from start of program', this makes recordings start from where the program should be (according to the EPG), skipping over any leader you may have added to the recording schedule, so you don't have to do that manually every time.
- Under 'View Recordings':
- Clear the tick box on 'Start in group list'. This makes it a little quicker to start watching a recent recording, and also makes it harder to accidentally exit the recordings screen as you have to press left twice (instead of once) from the default cursor position.
- Under 'Recording Groups':
- Clear the tick box on 'Save current group filter when changed'. This makes it easy to fix things if you accidentally change the group filter by just exiting the screen and going back in (yes I have done this multiple times).
- Under 'Include the 'Watch List' group':
- Tick the box 'Start from the Watch List view'. This makes the recordings screen start from the most logical point (in my opinion): a list of the oldest recording of each series that you haven't seen yet.
- Change 'Days to exclude weekly episodes after delete' to zero. This makes it easier to 'binge watch' a series, as the next unwatched episode will keep popping up in the watch list until you have seen them all.
- Under 'Seeking':
- Untick 'Reverse direction in fast forward/rewind'. This allows you to speed up/slow down the FF/Rwd using the FF/Rwd keys, much like how VCRs used to work (at least the ones I remember).
- Under 'Playback OSD':
- Untick 'Enable interactive TV'. Some channels display a logo or splash screen through the interactive features when they are 'off-air', this then overlays the recording making the recording worthless, so I turn this feature off.
- Under 'Media Settings':
- Under 'Videos Settings':
- Under 'General Settings':
- Set the 'Directories that hold videos' to the location in which you keep videos (not recordings), this is probably a directory you mount from a network share or similar.
- Tick the box for 'Video Tree remembers last selected position'. This makes it easier to remember your position in a series.
- Under 'Video Metadata Settings':
- Untick 'Perform metadata update after v…'. The metadata update incorrectly identifies videos too often for my taste, and is a pain to fix afterwards. The metadata is also stored centrally, so leaving this on on one client will overwrite all of the other clients' video metadata, and finally it will 'unfix' your changes every time you re-scan. Basically only use this if you're very happy with the metadata updates MythTV does on your video library.
- Exit the Setup menu, and go in to 'Edit Keys' (if you are using the same theme as me it will be next to Setup under the Advanced menu). All of these are optional, especially if you intend to use a full keyboard to interact with MythTV.
- Under the Global context:
- Under the ESCAPE action, select one of the empty keybinding slots (at the bottom of the screen) and bind the Back or Escape key on your remote. If the remote sends an actual Escape keypress, you don't need to do this.
- Under the INFO action, bind the Info key on your remote.
- Under the MENU action, bind the Menu key on your remote.
- Under the Main Menu context:
- Under the EXIT action, bind the Back or Escape key on your remote. It will complain that it conflicts with the Global context, bind it anyway.
- Under the EXITPROMPT action, remove the binding for the Escape key. This allows you to exit the MythTV Frontend without having that exit menu pop-up that is mostly useless, since we will be using the MythTV Welcome screen anyway.
- Under the TV Playback context:
- Under the FFWDSTICKY action, bind the Fast Forward key on your remote. This is the VCR-style fast forward, where you press the button once and it speeds through the 'tape' until you stop it. Pressing the key again makes it go faster.
- Under the JUMPFFWD action, bind the Jump Forward key on your remote. The Down key will also do the same thing (even though it is not listed in the key bindings), jumping forward one minute per key press.
- Under the JUMPRWND action, bind the Jump Backward key on your remote. The Up key will also do the same thing.
- Under the PAUSE action, bind the Play/Pause key on your remote. If the Play and Pause keys on your remote send different keypresses (very uncommon), then bind the Pause key here, and bind the Play key to the PLAY action. If you only have one Play/Pause (combined) key, or both keys send the same keypress, only bind it here under the PAUSE action, or pausing simply will not work.
- Under the RWNDSTICKY action, bind the Rewind key on your remote, similar to the FFWDSTICKY key above.
- Press Escape and save the changes.
- Return to the main menu (if using the suggested theme it should read 'Watch Recordings', 'Watch Videos', etc.).
- Go in to 'Watch Videos'.
- Press the menu key to bring up the menu. This is also a good test of your keybindings above.
- Select 'Change View' and 'Switch to List View'. This view lays out the folders and files like they are on your HDD, I find this view the easiest to navigate.
- You can play a video to test the system, if you wish.
- Exit the Videos screen, then exit the MythTV Frontend. After a few moments, this should bring up the welcome screen.
- The welcome screen is probably still in the default blue ('MythCenter') theme, we will fix this in a moment.
- Press the 'i' key (the Info key on your remote won't work until we restart the welcome screen).
- Untick the box for 'Automatically start mythfrontend'. This will mean when the machine boots up it will sit and wait on the welcome screen until you need it.
- Select the 'Finish' button to save.
- Press the 'F11' key to bring up a different config menu (yes the welcome screen has two).
- Change the 'Command to run Xterm' to:
xfce4-terminal --fullscreen
- This will start the same terminal as the ratpoison command, if you press 'F12'.
- Select the 'Finish' button to save.
- Press the 'm' key to bring up the menu.
- Select 'Exit' to close the welcome screen, it will restart automatically, applying the updated theme and enabling your keybindings.
Maintenance
- To access programs that aren't MythTV, press
Ctrl+A
,X
any time while the GUI is running to bring up a terminal with themythtv
user already logged in.- Alternatively, press
F12
on the MythTV Welcome screen to bring up the same terminal. - Alternatively, press
Ctrl+Alt+F2
to switch to the second console terminal, where you can log in as a normal user. To go back to the GUI, pressCtrl+Alt+F1
(the GUI runs on the first console terminal).
- The
mythtv
user can run the following commands without a password:sudo reboot
to reboot the machine.sudo poweroff
to shut the machine down.sudo apt update
to update the software package lists.sudo apt upgrade
to install the updated software packages.
Miscellaneous
- Intel integrated graphics cards can exhibit screen tearing, especially on 4K displays. To alleviate this, create the file
/etc/X11/xorg.conf.d/20-intel.conf
with the following contents:Section "Device" Identifier "Intel Graphics" Driver "intel" Option "TearFree" "true" Option "AccelMethod" "sna" EndSection
- Some monitors don't talk to the graphics card while they're switched off/in standby, so if you leave your screen off to save power and the machine reboots the display will not render, giving you just a black screen even though mythwelcome is actually running in the background. As a workaround you can detect the presence of a monitor and prevent things from initialising until the monitor appears.
- Create the file
/home/mythtv/xinitrc.sh
with the following contents:#!/bin/bash xrandr -q | grep " connected" &>> /dev/null if [ "$?" == "0" ]; then # Screen found start mythtv xrandr --fb 1920x1080 xrandr --size 1920x1080 ratpoison & mythwelcome fi
- Make it executable with
chmod +x /home/mythtv/xinitrc.sh
- Replace the contents of
/home/mythtv/.xinitrc
with just the one line:/home/mythtv/xinitrc.sh
- You can remotely access the screen via X11VNC (this does not work with the initialisation script above).
sudo apt install x11vnc
sudo nano -w /home/mythtv/.xinitrc
- Add the following to the top of the file:
x11vnc -rfbport 5900 -forever -nevershared -sleepin 60 -passwd password &
- Restart the frontend.