Linux Crumbs
Simbiotic - A Cyberpunk Thriller Novel

Tear Free Firefox Menu in MythTV

Summary

This tutorial describes how to address streaming video tearing in XFCE and how to add a Firefox menu to MythTV.

Update 2014-11-14: These steps were originally documented using Mythbuntu 12.04 which uses MythTV 0.25 with the XFCE 4.8 desktop. These steps have been updated to cover Mythbuntu 14.04 which uses MythTV 0.27 with the XFCE 4.11 desktop.

Contents

Background

Occasionally I miss recording a TV show that I would like to watch. Fortunately many TV stations now stream TV shows from their web sites. Unfortunately, streaming these shows using the MythTV built-in web browser does not always work.

Personally I have found the Firefox web browser to be a better way to stream TV shows. Note that there are some challenges with using Firefox on GNU/Linux to view TV shows, and I have documented the following two solutions.

Since Firefox works well, I wanted a way to make Firefox easily available from a MythTV menu. This would enable using Firefox without needing to exit the MythTV frontend to invoke Firefox from the desktop. Since there was a problem with streaming video tearing with Firefox on my Intel HD 3000 Graphics computer system running Mythbuntu 12.04 with MythTV 0.25 and XFCE 4.8 (and more recently Mythbuntu 14.04 with MythTV 0.27 and XFCE 4.11), I investigated and found a solution. This tutorial covers how to address the streaming video tearing problem, and also how to add Firefox to the MythTV menu.

Fix Video Tearing on XFCE

On a previous installation of Mythbuntu 11.04, I used the Compiz compositor to address video tearing on the XFCE desktop with reasonable success. However, Compiz did not work to my satisfaction for Mythbuntu 12.04.

This lead me to research and discover another solution which uses the Compton compositor as described in Howto: Using Compton for tear-free compositing on XFCE or LXDE.

Compton works very well to fix the video tearing problem. However I discovered that with my auto-login Mythbuntu PVR, the computer would crash if I set compton to autostart using the XFCE settings manager. I worked around the compton startup problem using a firefox startup script as I describe later.

Now onto the steps to install the Compton compositor. Note that you will need to exit the MythTV Frontend and open a terminal window in order to perform these steps.

  1. Add the Personal Package Achive respository for the Compton maintainer.

    sudo apt-add-repository ppa:richardgv/compton

  2. Update and install compton.

    sudo apt-get update && sudo apt-get install compton

    TIP:   Installing Compton from .deb Package

    If you do not wish to add the PPA repository, you can use the following steps instead.

    1. Locate and download the appropriate .deb file directly from https://launchpad.net/~richardgv/+archive/compton.
    2. Install the .deb package directly.

      sudo dpkg -i ~/Downloads/compton*.deb

      Note that if the above command fails due to missing dependencies, then you will need to manually install any missing dependencies such as libconfig8. For example:

      On Mythbuntu 14.04:

      sudo apt-get install libconfig9

      On Mythbuntu 12.04:

      sudo apt-get install libconfig8

  3. [Mythbuntu 12.04 only] Open an editor and create a compton configuration file.

    leafpad ~/.compton.conf

    Copy the following sample compton config file and paste it into your editor.

    ----- Begin ~/.compton.conf -----
    backend = "glx";
    paint-on-overlay = true;
    glx-no-stencil = true;
    glx-no-rebind-pixmap = true;
    vsync = "opengl-swc";
    
    # These are important. The first one enables the opengl backend. The last one is the vsync method. Depending on the driver you might need to use a different method.
    # The other options are smaller performance tweaks that work well in most cases.
    # You can find the rest of the options here: https://github.com/chjj/compton/wiki/perf-guide, and here: https://github.com/chjj/compton/wiki/vsync-guide
    
    
    # Shadow
    shadow = true;			# Enabled client-side shadows on windows.
    no-dock-shadow = true;		# Avoid drawing shadows on dock/panel windows.
    no-dnd-shadow = true;		# Don't draw shadows on DND windows.
    clear-shadow = true;		# Zero the part of the shadow's mask behind the window (experimental).
    shadow-radius = 7;		# The blur radius for shadows. (default 12)
    shadow-offset-x = -7;		# The left offset for shadows. (default -15)
    shadow-offset-y = -7;		# The top offset for shadows. (default -15)
    shadow-exclude = [
     "! name~=''",
     "n:e:Notification",
     "n:e:Plank",
     "n:e:Docky",
     "g:e:Synapse",
     "g:e:Kupfer",
     "g:e:Conky",
     "n:w:*Firefox*",
     "n:w:*Chrome*",
     "n:w:*Chromium*",
     "class_g ?= 'Notify-osd'",
     "class_g ?= 'Cairo-dock'",
     "class_g ?= 'Xfce4-notifyd'",
     "class_g ?= 'Xfce4-power-manager'"
    ];
    
    # The shadow exclude options are helpful if you have shadows enabled. Due to the way compton draws its shadows, certain applications will have visual glitches
    # (most applications are fine, only apps that do weird things with xshapes or argb are affected).
    # This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher.
    
    # Fading
    fading = true; # Fade windows during opacity changes.
    fade-delta = 4; # The time between steps in a fade in milliseconds. (default 10).
    fade-in-step = 0.03; # Opacity change between steps while fading in. (default 0.028).
    fade-out-step = 0.03; # Opacity change between steps while fading out. (default 0.03).
    #no-fading-openclose = true; # Fade windows in/out when opening/closing
    
    detect-client-opacity = true; # This prevents opacity being ignored for some apps. For example without this enabled my xfce4-notifyd is 100% opacity no matter what.
    
    # Window type settings
    wintypes:
    {
      tooltip = { fade = true; shadow = false; };
    };
        
    ----- End ~/.compton.conf -----

    Save the file and exit the editor.

The Compton compositor is now installed. If you are curious to try it out, compton can be started as a background process with the following command:

On Mythbuntu 14.04:

compton --backend glx --vsync opengl -b

On Mythbuntu 12.04:

compton -b

Add Firefox to MythTV Menu

Due to problems I had autostarting compton as mentioned above, I opted to create a script to invoke firefox that would also start compton if needed. I did not wish to develop my own custom MythTV Theme, so I decided instead to override one of the menus for an already existing theme. Peronally I use the default theme, but I will describe how to find the main menu theme file so that you can use these steps for other MythTV themes.

The following steps are performed in a terminal window.

  1. Open an editor and create a script file to invoke compton and Firefox.

    sudo leafpad /usr/bin/mythtv-firefox-linux.sh

    Copy the following sample mythtv-firefox-linux.sh file and paste it into your editor.

    ----- Begin mythtv-firefox-linux.sh -----
    #!/bin/sh
    #
    # Startup Firefox (Linux) for MythTV
    #
    
    # If compton compositor available and not running then start compton
    if test "x`which compton`" != "x" ; then
            if test "x`ps -e | grep compton`" = "x"; then
                    compton --backend glx --vsync opengl -b
            fi
    fi
    
    # Ensure that no other firefox processes are running
    killall firefox
    
    # Startup Firefox
    firefox
        
    ----- End mythtv-firefox-linux.sh -----

    NOTE:   Mythbuntu 12.04 users need to change the compton line.

    From:

        compton --backend glx --vsync opengl -b

    To:

        compton -b


    Save the file and exit the editor.

  2. [OPTIONAL] For users that wish to also use Firefox running under WINE emulation software.

    Open an editor and create a script file to invoke compton and Firefox.

    sudo leafpad /usr/bin/mythtv-firefox-wine.sh

    Copy the following sample mythtv-firefox-wine.sh file and paste it into your editor.

    ----- Begin mythtv-firefox-wine.sh -----
    #!/bin/sh
    #
    # Startup Firefox (WINE) for MythTV
    #
    
    # If compton compositor available and not running then start compton
    if test "x`which compton`" != "x" ; then
            if test "x`ps -e | grep compton`" = "x"; then
                    compton --backend glx --vsync opengl -b
            fi
    fi
    
    # Ensure that no other firefox processes are running
    killall firefox
    
    # Ensure that no other wine processes are running
    killall wine
    
    # Startup Firefox using wine
    wine "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
        
    ----- End mythtv-firefox-wine.sh -----

    NOTE:   Mythbuntu 12.04 users need to change the compton line.

    From:

        compton --backend glx --vsync opengl -b

    To:

        compton -b


    Save the file and exit the editor.

  3. Make the script file(s) executable.

    sudo chmod 755 /usr/bin/mythtv-firefox-*.sh

  4. Find a place to add to the MythTV menu.

    Since my chosen MythTV theme (defaultmenu) has the MythTV web browser available under the main menu entry Information Center, I decided to add Firefox the same place.

    To find the mainmenu.xml file, I used the following command:

    find /usr/share/mythtv/ -name mainmenu.xml -print

    On my system I received the following output:

    /usr/share/mythtv/themes/defaultmenu/mainmenu.xml
    /usr/share/mythtv/themes/classic/mainmenu.xml
    /usr/share/mythtv/themes/Slave/mainmenu.xml
    /usr/share/mythtv/themes/mediacentermenu/mainmenu.xml
    /usr/share/mythtv/themes/DVR/mainmenu.xml

    To find the menu file being used for the Information Center entry in .../defaultmenu/mainmenu.xml I searched and found the following stanza:

        <button>
            <type>MENU_INFO_CENTER</type>
            <text>Information Center</text>
            <description>Information and Communications</description>
            <action>MENU info_menu.xml</action>
        </button>
        
    From this I could determine that the Information Center sub-menu is actually contained in the info_menu.xml file.
  5. Make an override copy of Information Center .xml file.

    cp -p /usr/share/mythtv/themes/defaultmenu/info_menu.xml ~/.mythtv

  6. Edit ~/.mythtv/info_menu.xml and add Firefox menu entry near bottom.

    leafpad ~/.mythtv/info_menu.xml

    Insert the Firefox button text (shown below) just above the </mythmenu> line so it looks like this:
        <button>
            <type>FIREFOX_LINUX</type>
            <text>Firefox (needs mouse)</text>
            <description>Firefox web browser (Linux)</description>
            <action>EXEC mythtv-firefox-linux.sh</action>
        </button>
    
    </mythmenu>
        
  7. [OPTIONAL] For users that wish to also use Firefox running under WINE emulation software.

    Edit ~/.mythtv/info_menu.xml and add Firefox menu entry near bottom.

    leafpad ~/.mythtv/info_menu.xml

    Insert the Firefox button text (shown below) just above the </mythmenu> line so it looks like this:
        <button>
            <type>FIREFOX_WINE</type>
            <text>Firefox - wine (needs mouse)</text>
            <description>Firefox web browser (WINE Windows emulation)</description>
            <action>EXEC mythtv-firefox-wine.sh</action>
        </button>
    
    </mythmenu>
        

You should now be able to invoke Firefox from a MythTV menu and use your mouse to surf the web and stream videos tear-free. :-)

MythTV menu with Firefox entry

TIP:   [Mythbuntu 12.04 only] Preventing Mythwelcome Timeout and Automatic Shutdown

If like me you have Mythwelcome configured to automatically power up your PVR for recordings and to automatically shutdown when not in use, then we need to perform one more step before starting Firefox.

To prevent automatic shutdown we need to establish a connection to the MythTV backend database. We can do this by first navigating to Media Library and then Watch Recordings to display a list of our recordings. If the list does not display, then try again until the list is properly displayed. After that we can go back and start Firefox and not need to worry about automatic shutdown.

References

The Medusa Deception novel - free first in series
News   Documentation     Copyright (c) 2013-2024 Curtis Gedak

Get GParted at SourceForge.net. Fast, secure and Free
	Open Source software downloads Valid HTML 4.01! Correct CSS!