You are not logged in.

#1 2008-09-13 09:56:48

krims0n
Member
Registered: 2008-08-25
Posts: 17

Quick & dirty banshee status script for conky

I made a quick & dirty little python script to return the current Artist and Track name from Banshee using DBUS. You can also retrieve this information by calling banshee on the commandline but this is quite hefty resourcewise.

The processcheck is necessary to prevent banshee from automatically starting up if it is not currently running when doing the dbus call.

Feel free to comment on my noob python skills wink

#!/usr/bin/env python

import sys,os,dbus
rc = os.system( "ps -ef | grep -v grep | grep -c ' banshee' > /dev/null" )

if rc == 0:
    bus = dbus.SessionBus()
    banshee = bus.get_object("org.bansheeproject.Banshee", "/org/bansheeproject/Banshee/PlayerEngine")
    
    currentTrack = banshee.GetCurrentTrack()
    state = banshee.GetCurrentState()
    if state == 'playing':
        if sys.argv[1] == "-a":
            print(currentTrack['artist'])
        elif sys.argv[1] == "-n":
            print(currentTrack['name'])
    else:
        if sys.argv[1] == "-a":
            print "Stopped"
else:
    if sys.argv[1] == "-a":
        print "Banshee not running"

Example conky config:

  ${color0}${execi 15 /path/to/conky_banshee.py -a}
  ${color0}${execi 15 /path/to/conky_banshee.py -n}

Last edited by krims0n (2008-09-13 10:04:07)

Offline

Board footer

Powered by FluxBB