1
2
3
4
5
6
7
8
9
10
11 import os
12 import string
13 import gobject
14 from GenericPlayer import GenericAPI
15 import commands
16
18 __name__ = 'Kaffeine API'
19 __version__ = '0.0'
20 __author__ = 'Whise (Helder Fraga)'
21 __desc__ = 'Kaffeine API to a Music Player'
22
23 playerAPI = None
24
25 __timeout = None
26 __interval = 2
27
28 callbackFn = None
29 __curplaying = None
30
31
35
36
37
38
40 proc = os.popen("""ps axo "%p,%a" | grep "kaffeine" | grep -v grep|cut -d',' -f1""").read()
41 procs = proc.split('\n')
42 if len(procs) > 1:
43 return True
44 else:
45 return False
48
49
51 return commands.getoutput('dcop kaffeine KaffeineIface title')
52
54 return commands.getoutput('dcop kaffeine KaffeineIface album')
55
57 return commands.getoutput('dcop kaffeine KaffeineIface artist')
58
59
61 t = commands.getoutput('dcop kaffeine KaffeineIface getFileName')
62 t = t.split('/')
63 basePath = ''
64 for l in t:
65 if l.find('.') == -1:
66 basePath = basePath + l +'/'
67
68 names = ['Album', 'Cover', 'Folde']
69 for x in os.listdir(basePath):
70 if os.path.splitext(x)[1] in [".jpg", ".png"] and (x.capitalize()[:5] in names):
71 coverFile = basePath + x
72 return coverFile
73
74 return ''
75
76
77
79 return commands.getoutput('dcop kaffeine KaffeineIface isPlaying')
80
81
83 if self.is_playing():
84 os.system('dcop kaffeine KaffeineIface pause &')
85 else:
86 os.system('dcop kaffeine KaffeineIface play &')
88 os.system('dcop kaffeine KaffeineIface next &')
89
91 os.system('dcop kaffeine KaffeineIface previous &')
92
99
100
110