You are not logged in.
Pages: 1
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
mhh ok have solved it. was the bash script. it didnt find the relative path info.py
Offline
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
I think you have to tell dzen which display to use. In crontab, try:
* * * * * DISPLAY=:0.0 /home/user/dzen2/master.sh
Offline
thx works very well
Offline
Pages: 1