You are not logged in.

#1 2010-07-08 20:04:42

Ventil1
Member
Registered: 2010-03-17
Posts: 140

battery_time in conky.... How can I remove seconds? [Solved]

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

#2 2010-07-08 21:15:24

lagagnon
Member
From: an Island in the Pacific...
Registered: 2009-12-10
Posts: 1,087
Website

Re: battery_time in conky.... How can I remove seconds? [Solved]

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

#3 2010-07-08 21:28:34

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: battery_time in conky.... How can I remove seconds? [Solved]

OK I'll try. Thank you laganon

Offline

#4 2010-07-08 21:48:58

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: battery_time in conky.... How can I remove seconds? [Solved]

Nope

${battery_time BAT0 |  cut -c1 }

output is still

3h 55m 22s

What could be wrong?

Offline

#5 2010-07-09 11:43:28

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: battery_time in conky.... How can I remove seconds? [Solved]

I cant figure it out. Can someone please help me?

Offline

#6 2010-07-09 12:45:21

kgas
Member
From: Qatar
Registered: 2008-11-08
Posts: 718

Re: battery_time in conky.... How can I remove seconds? [Solved]

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

#7 2010-07-09 13:31:47

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: battery_time in conky.... How can I remove seconds? [Solved]

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

#8 2010-07-09 13:36:47

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: battery_time in conky.... How can I remove seconds? [Solved]

you need one of the exec function to execute shell commands

Offline

#9 2010-07-10 05:29:25

Ventil1
Member
Registered: 2010-03-17
Posts: 140

Re: battery_time in conky.... How can I remove seconds? [Solved]

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

Board footer

Powered by FluxBB