You are not logged in.
Is there a way to remove seconds from "battery_time" variable in conky
The output is HH:MM:SS. I just need HH:MM
Last edited by Ventil1 (2010-07-10 06:37:57)
Offline
Not from within conky itself, but you could strip off the extraneous seconds field with "cut", something like this in your ~/.conkyrc file (but you work on it):
${battery_time | cut -d=":" -f 1,2}
See "man cut" for more detail.
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
OK I'll try. Thank you laganon
Offline
Nope
${battery_time BAT0 | cut -c1 }
output is still
3h 55m 22s
What could be wrong?
Offline
I cant figure it out. Can someone please help me?
Offline
man cut will give you details. in case you need to display only the first two fields with space character as delimiter use
cut -d\ -f1-2 (delimiter space is escaped for more clear)
Offline
I checked man cut. But it doesn't work even for a simple usage like cut -c1. I think cut can only work when you use $exec variable in conky
Offline
you need one of the exec function to execute shell commands
Offline
Got my answer on crunchbang forum.
This is what I wanted:
${execi 60 cat /proc/acpi/battery/BAT*/state | awk '{if ($0 ~ "present rate:"){rate = $3} if($0 ~ "remaining capacity:"){cap = $3}} END {printf "%d hours %d minutes\n" ,(cap / rate), (((cap % rate) / rate) * 60)}'}
Offline