Toggling a clock on top of MythTV

From JoatWiki
Jump to: navigation, search

Toggling a clock on top of MythTV

(23 Nov 2009) - Some times you want a clock showing in MythTV. Some of MythTV's menus show a clock, most don't. Same goes for the in-video clocks, and those only show for a few seconds. I wanted a clock that shows up on top of MythTV and sticks around until I turn it off. Following are my notes for setting up a clock that you can toggle on and off.

The idea is that you want the clock to show up on top of MythTV, not as part of it. This means that you'd use a system clock vice the MythTV OSD stuff. The tool called osd_clock fits the bill nicely.

The toggle script

Copy and paste the following into a script called "timetoggle". Save it in the bin directory, change the owner and group to "root", and make it executable.

#!/usr/bin/perl

open(INFILE,"ps aux|grep osd_clock|grep -v grep|");
@lines=<INFILE>;
close INFILE;

$count=@lines;

if ($count) {
	($junk,$pid,$junk)=split(/\s+/,@lines[0],3);
	chomp $pid;
	if($pid) {
		system("kill $pid");
	}
} else {
	system("osd_clock -f '-*-lucidatypewriter-medium-*-*-*-32-*-*-*-*-*-*-*' &");
}

You can change the font size of the clock by changing "32" (in the above) to another number. Font, style, and weight can be changed in a similar manner.

You can test the clock by typing in "timetoggle" at the command line.

Editing the menu

Where you could edit the menus directly in .21, .22 requires that changes be made in userspace. In other words, if you want to change a menu, you should copy the appropriate file into the .mythtv folder in your home directory, correct the file ownership, and then edit it.

root@desk:~# cp /usr/share/mythtv/util_menu.xml /home/joat/.mythtv
root@desk:~# chown joat:joat /home/joat/.mythtv/util_menu.xml
joat@desk:~$ vi /home/joat/.mythtv/util_menu.xml

Somewhere in your menu file (mine was util_menu.xml), add the following. (I added it just above the closing tag for "mythmenu".)

<button>
  <type>MENU_GENERAL</type>
  <text>Toggle the clock</text>
  <action>EXEC /bin/timetoggle</action>
</button>

From there, fire up MythTV, go to your utils menu and give it a try. (I'll post a screen capture here shortly.)




Comments:

Leave a Comment

Personal tools