usr bin env python coding utf-8 import sys import os from time import

 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
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
from time import sleep
_awesome_client_path = "%s/bin/awesome-client" % os.environ.get('HOME')
_status_file = "/tmp/sbar-mcabber.msg"
_widgetName = 'mcabber'
def getmsg():
if os.path.exists(_status_file):
f = open(_status_file);
msg = f.read()
f.close()
if int(msg) > 0:
return '[ mcabber: %s ]' % str(msg)
else:
return ''
else:
return ''
if __name__ == "__main__":
if len(sys.argv) > 1:
_widgetName = sys.argv[1]
while 1:
try:
pipe = os.popen(_awesome_client_path, 'w')
msg = getmsg()
if msg == '':
pipe.write('0 widget_tell %s\n' % _widgetName)
else:
pipe.write('0 widget_tell %s %s \n' % (_widgetName, msg))
pipe.close()
except:
pass
sleep(1)