usr bin env python coding utf8 import os sys subprocess time def dcop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
# -*- coding: utf8 -*-
import os,sys,subprocess,time
def dcop(cmd):
return subprocess.Popen("/usr/bin/env dcop "+cmd,shell=True,stdout=subprocess.PIPE).stdout.read()[:-1]
def gajim(cmd):
return subprocess.Popen("/usr/bin/env gajim-remote "+cmd,shell=True,stdout=subprocess.PIPE).stdout.read()[:-1]
oldartist = oldtitle = oldplaying = None
status = gajim('get_status')
while True:
status = gajim('get_status')
playing = dcop('amarok player isPlaying')
if playing == 'true':
artist = dcop('amarok player artist')
title = dcop('amarok player title')
if (artist,title,playing) != (oldartist,oldtitle,oldplaying):
oldartist, oldtitle, oldplaying = artist, title, playing
cmd = 'gajim-remote change_status '+status+' "♫: '+artist+' - '+title+'"'
gajim('change_status '+status+' "♫: '+artist+' - '+title+'"')
else:
if gajim('get_status_message'):
gajim('change_status '+status)
oldplaying = 'false'
time.sleep(1)