Projects Blog

Change Your Skype Mood Text In Linux With Python

I thought it would be neat to change my Skype mood text based on what I was watching on my WDTV. I have a WDTV Live Plus modded with WDLXTV (version based on 1.05.04) that displays what I am watching on a web dashboard. To accomplish this, it is as simple as scraping the data from the dashboard and passing it to Skype using Skype’s API. On Linux, Skype uses D-Bus to interact with its API. The scripts I used are below.

# script to change Skype mood status, usage: new_mood

import dbus
import sys

def mood(text=""):
    bus = dbus.SessionBus()
        proxy = bus.get_object('com.Skype.API', '/com/Skype')
        proxy.Invoke('PROTOCOL 2')
        if text=="":
            command = 'GET PROFILE MOOD_TEXT'
            command = 'SET PROFILE MOOD_TEXT %s' % text
        return proxy.Invoke(command)
            print "Could not contact Skype client"

if __name__ == "__main__":
    if len(sys.argv) >= 2:
        print mood()

import urllib2
import re
from skype_mood import mood

wdlxtvurl = "http://WDLXTVURL/"
defaultmood = "Nothing Playing"

    content = urllib2.urlopen(wdlxtvurl).read()
    print "Could not reach server"

m ='id="deviceStatus".*?>(.*?)<', content)
status =

if status in ("PLAYING", "PAUSED_PLAYBACK"):
    m ='id="currentMedia".*?>(.*?)<', content)
    playing =
    print mood(playing)

The first script,, is a generic script. The second script imports the first one, grabs the relevant information from WDLXTV’s dashboard and if media is playing or paused, it will display the name or file name of the media as your mood status text in Skype. I had difficulty passing basic authentication credentials (urllib’s password manager or adding an authentication header) to my WDLXTV so I decided to remove the authentication altogether. If you want to run this with cron, you will need to configure some extra things detailed here.


Categorised as: Programming

Leave a Reply

Your email address will not be published. Required fields are marked *