Difference between revisions of "Integrating Skype with a MythTV system"
|Line 1:||Line 1:|
Latest revision as of 02:12, 15 October 2009
The approach to integrating Skype with a MythTV system described here is an attempt to get these two pieces of software to play nicely with one another inside a home entertainment PC. Please note that the "integration" described here does not involve cluttering up MythTV with an additional "Skype management screen" or the like. On the contrary, the aim is to get Skype working smoothly through an ordinary telephone and remove it from the computer display altogether, to prevent it from interfering with the operation of MythTV.
This document assumes the use of an external piece of hardware (see below) that is used to connect an ordinary telephone to the USB port of a PC. The relevant hardware costs 40 to 50 dollars US new --- and I hasten to add that I have no connection with any of the firms that make or market this item, nor with Skype. I just find that a telephone, MythTV and Skype make a handy combo, and imagine that others might find it useful as well. So here goes with the explanation.
In their initial version, these instructions assume the use of the Ubuntu Linux distribution. They should also work for GNU/Linux (Debian) systems. If you run a different distribution and find that some parts of the instructions need to be modified, feel free to amend this document for the benefit of others.
What we're after
As a learning-averse modern consumer, my needs are very simple. To me, "making a call" means picking up a telephone, dialing a number, talking with the person on the other end of the line, and hanging up. Conversely, "receiving a call" means that the telephone rings, and I answer by picking it up and speaking into the receiver. Notice that the words keyboard, monitor and mouse do not figure in this description. As an aspiring Luddite, when I come home from work and flop down in front of the telly, I want --- however briefly --- to be able to forget what those terms mean.
On the other hand, I have more technology-tolerant friends who do make calls, using Skype from their computer monitors. When I find myself sitting at home getting reacquainted with subtle plot twists in The Brady Bunch or admiring the fine dramatic performances of David Hasselhoff, I would like Skype to broadcast my online status as Online . When the Myth box is busy recording programs, but the front end is not in use, the world should be told that I am Not Available. And stuff.
That is the target feature set in a nutshell: a telephone that can be used for ordinary inbound and outbound calls via Skype or the landline, and which gives a hint to other Skype users about whether I'm around and likely to pick up the phone if they should ring.
This scenario can be realized by matching Skype with a small device that we will call a "telbox", using a small amount of software glue.
You will need three pieces of software to connect the telbox to Skype:
- usbb2k_api A small driver daemon that converts simple human-friendly commands to the binary whatsit language used by the telbox, and likewise returns responses sent back by the box in human-friendly (or at least, programmer-friendly) form. Fetch the latest binary distribution of this item.
- kb2kskype A bridge application that, using the simplified command set groked by usbb2k_api on one side, and the Skype Public API on the other, causes incoming Skype calls to ring the phone, and keypresses on the telephone to be fed through to Skype. Fetch the latest binary distribution of this item, as well.
- skype You should install version 1.4 (or later) of Skype (version 1.3 will work, but 1.4 is superior software). Fetch the 32-bit beta version of Skype for your Linux distribution, or fetch the 64-bit version of Skype for Ubuntu.
Once you have grabbed the usbb2k_api and kb2kskype packages, and checked that the two main apps (Skype and Myth) will both run in your environment, you will need the following hardware in order to proceed:
- USB-B2K telbox The original manufacturer is Yealink, but the same product has been rebranded as OEM equipment by several other firms. Here are a few links to check for information:
- Open USB port This will be used to connect the telbox to your computer. The USB-B2K uses USB 1.1, so any USB port should work.
- Ordinary telephone You probably already have one of these lying around. The phone will be used for both PSTN (landline) and Skype calls, so your existing phone will continue to work.
Note: If you don't have a landline, you can set up the software for USB (Skype) mode only.
With software and hardware in hand, you're ready to put it all together. As indicated above, these instructions assume the use of the Ubuntu or GNU/Linux (Debian) distribution of the Linux OS. Some details (particularly the startup scripts) may need to be modified when working with another distribution.
The following diagram gives an idea of how things will work in the completed system. The usbb2k_api daemon provides an interface to the telbox. The kb2kskype bridge passes commands and status messages back and forth between the telbox and Skype. All the user needs to worry about is checking that the PC is turned on, and using the telephone in the customary way.
The first step is refreshingly simple. Connect the USB cable to the USB-B2K box, and plug the other end into a free USB port on your PC. Connect your telephone to the appropriate phone jack on the box (on mine, it is labeled "TEL"). If you use a landline, connect the line to the other phone jack on the box (on mine, this one is labeled "LINE"). The telbox draws its power from the USB cable, so that's all you need to do.When the telbox has no power (i.e. when your PC is turned off) the phone should work normally for landline calls.
Installing skype, usbb2k_api and kb2kskype
If you are are reading this, you are probably already familiar with the package installation process for your Linux distribution, but just in case, on Ubuntu, you can install these packages with commands similar to these:
prompt$ su Password: prompt# dpkg -q -i skype-188.8.131.52.deb prompt# dpkg -q -i usbb2k-api-mod_2.2-1_i386.kubuntu.deb prompt# dpkg -q -i kb2kskype_0.3.3-1_i386.kubuntu.deb prompt# exit prompt$
Once installed, the usbb2k_api will start automatically at boot time. It is a background process, so you can check that it is up with something like:
prompt$ ps ax | grep usbb
This daemon expects the telbox to remain connected when it is running. If the telbox is not connected when the daemon is started, it will eventually die. Its behaviour if the USB cable of the telbox is disconnected while it is running is undefined --- which is to say, it will probably crash if you suddenly yank the USB cable out of your PC before it is shut down.
Running Skype and kb2kskype in a virtual X server window
Now for the fun part. Skype is a GUI application that likes to make its presence known when it performs operations. There are a few sensible reasons for this. There is a very vocal population of users clamouring for video in Skype for Linux, so the pressure is for more on-screen activity, not less. Even without video, Skype has more features than can be easily controlled through a 12-key handset, so in most environments, putting the GUI in front of the user when it might be needed is convenient. There are security concerns as well. Skype can be accessed and controlled by other applications via a hidden communication channel (the Skype Public API), and in many environments it is a good thing for the user to be made aware of what these programs are doing. But when MythTV has control of the display, popups from the Skype client can be a distraction.
The simplest and most comprehensive way of keeping Skype off the screen is to route its GUI to a virtual X server (an "X-windows virtual network console", or Xvnc). This is a display separate from the physical screen(s) on your PC that is tucked away in the computer's memory, and can be accessed using a special Xvnc viewer client. When an X application is running on a virtual X server, it is for practical purposes invisible; its windows and whatnot will only be shown if the user connects to the virtual display with an Xvnc viewer.
Installing an Xvnc server and its friends
The first step is to install an Xvnc server and client. There are several in circulation. The one I use is the Debian/Ubuntu package vnc4server for the server, and xvncviewer for the viewer client. Unless you have a strong preference for another combination of Xvnc tools, use the package manager to install these two packages.
The Xvnc server, just like the server that runs the physical X display on the monitor, needs to have a window manager. Gnome is much too heavy for a server that will only run a couple of applications. There are many lightweight window managers around; the one I use is blackbox. If you don't feel like shopping around and tinkering with the setup, use your package manager to install this package as well.
Installing these tools runs something like this:
prompt$ su Password: prompt# dpkg -q -i vnc4server prompt# dpkg -q -i xvncviewer prompt# exit prompt$
[Complete to this point]
Configuring the server
The VNC server uses its own xstartup script, located at ~/.vnc/xstartup. Here is a copy of the one that I use, with commands and options explained in the comments. (Note that the VNC server display name is "bigbox". More on where that comes from in the next section.)
#!/bin/sh ## Allow connections from this computer (possibly not required) xhost +localhost ## A grey background is easier on the eyes than the default ## hash pattern used by X xsetroot -solid grey ## Force the VNC server configuration widget to the virtual display vncconfig -display bigbox:1 & ## Possibly gratuitous pause inserted to give Skype a comfortable ## startup environment /bin/sleep 1 ## Skype accepts the usual X11 options. We force it to use ## the virtual display /usr/bin/skype -display bigbox:1 & ## Several options are used with kb2kskype ## --cmap forces kb2kskype to use a private colormap, to avoid overburdening ## the server colormap ## --geometry just sizes and positions the kb2kskype GUI widget inside ## the virtual display ## --display just forces the widget to display in the virtual server ## --offhook-stamp causes the named file to be created when the ## telephone is off-hook, and deleted when the telephone is ## placed on-hook ## --status-script causes the last-named script to be run every ## ten seconds, and the Skype online status to be set to ## according to its exit status. An exit status of 0 uses ## the first option, 1 the second, and so on /usr/local/bin/kb2kskype --cmap --geometry 50x50+200x+0 --display bigbox:1 \ --offhook-stamp /tmp/CALL_IN_PROGRESS \ --status-script na,online,/usr/local/bin/MyB2Kcheckstatus.sh & ## Run the window manager! blackbox -display bigbox:1 &
If you have installed the blackbox window manager package, and both usbb2k_api and kb2kskype are in place, you should be able to use this script, too. Create a subdirectory .vnc in the account used by MythTV, and use cut and paste to copy the text above into a file xstartup in that subdirectory.
A few comments about the last two options fed to kb2kskype are in order. These options were added specifically to support MythTV. With the --offhook-stamp option, a MythTV shutdown script can check for the named file, and postpone a shutdown when it is found. This can be used to prevent the Myth box from suddenly shutting down in the middle of a Skype call. The --status-script option can be used to set Skype's online status using a script that is run periodically (every 10 seconds). In my installation, mythfrontend sets a pid file when it is running. The script invoked in the example checks for the pid file, and sets the user status to online when it is found, na otherwise.
(more coming soon ...)
 The current version of Skype for Linux does not offer a Desperate for Something Else to Do setting.