You are not logged in.

#1 2010-02-16 19:53:38

mohikaner
Member
Registered: 2010-01-28
Posts: 10

musca dzen2 and python

hey guys,
i have a problem with a python script and dzen2. as wm i have installed musca, which is nice. now i have written some python script to display volume and battery state.

python script (info.py):

import subprocess


f=open("/proc/acpi/battery/BAT0/state","r")
lines = f.readlines()
remaining = lines[4].split()[-2]
f.close()


f = open("/proc/acpi/ac_adapter/AC/state","r")
lines = f.readlines()
charging = lines[0].split()[-1]
f.close()


f=open("/proc/acpi/battery/BAT0/info" , "r")
lines = f.readlines()
capacity = lines[2].split()[-2]
f.close()


amixer = subprocess.Popen(['amixer','-c', '0', 'sget', 'Master'], stdout=subprocess.PIPE, shell=True)
volume = amixer.communicate()[0].splitlines()[4]
volume = volume.split()[3][1:3]


bat = float(remaining)/float(capacity)*100

output = "Vol: {0}%   |   Battery: {1:.0f}%   |   email not implemented".format(volume, bat)


print output

here the bash script i start in my .musca_start:

(while true; do python info.py; sleep 4; done) | dzen2  -p  -w 800 -e 'button3=' -ta c -x 170

the problem is, that if i starting the code above in a terminal, all is displayed correctly, but at startup executed by my .musca_start script dzen2 starts correct, but nothing is displayed.

Offline

#2 2010-02-16 20:00:48

mohikaner
Member
Registered: 2010-01-28
Posts: 10

Re: musca dzen2 and python

mhh ok have solved it. was the bash script. it didnt find the relative path info.py

Offline

#3 2010-02-17 09:05:49

mohikaner
Member
Registered: 2010-01-28
Posts: 10

Re: musca dzen2 and python

ok new problem. i wanted to update my dzen2 bars every minute with crond. so i wrote a script which kills all bars and starts them new.

master.sh:

killall dzen2
/home/user/dzen2/todo.sh &

and here is my todo.sh:

( echo "TODO"; cat /home/user/dzen2/TODO) | dzen2 -p -x 870 -l 5 -w 200 -h 18  -sa l -ta l

and crontab:

* * * * * /home/user/dzen2/master.sh

if i start with ./master.sh all works fine, but if its startet every minute with crond, it only kills the bars, but doesnt show new ones. anybody an idea?

Offline

#4 2010-02-17 09:17:16

jsgt
Member
Registered: 2009-03-16
Posts: 29

Re: musca dzen2 and python

I think you have to tell dzen which display to use. In crontab, try:

* * * * * DISPLAY=:0.0 /home/user/dzen2/master.sh

Offline

#5 2010-02-17 09:29:50

mohikaner
Member
Registered: 2010-01-28
Posts: 10

Re: musca dzen2 and python

thx works very well big_smile

Offline

Board footer

Powered by FluxBB