You are not logged in.

#1 2013-06-17 23:45:31

Winston-Wolfe
Member
Registered: 2013-06-01
Posts: 49

Conky battery time remaining - without the seconds

The 'battery_time' variable outputs in HH:MM:SS format; I find the last bit redundant and it takes up valuable space in my status bar.

I found this solution that worked for others, though I'm having trouble making it work for me.

${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)}'}

/proc/acpi/battery/BAT1/ has been dropped in favor of /sys/class/power_supply/BAT1/, though I don't see the 'state' script needed by the above command to work.

capacity, charge_full, charge_now, cycle_count, status, etc are there, but no 'state' containing "remaining capacity:" or "present rate:" needed for the math to take place

Offline

#2 2013-12-19 20:34:22

SwitchPT
Member
Registered: 2013-12-19
Posts: 1

Re: Conky battery time remaining - without the seconds

Hi!

Maybe for the original poster this came late, But i found a solution for this problem by my own and I want to share it for future use big_smile 

Using the variable $battery_time from conky you can display the time remaining on your battery only in hours and minutes (losing the seconds).

1st> Add to the start of your conky config file the flag:

times_in_seconds true

This will "convert" the output of  $battery_time to seconds  (e.g. 1h 1m 1s --->3661 sec )

2nd> Use the follow expression to convert from seconds to hours and minutes:

${format_time $battery_time "\hh\mm"} 

big_smile
Useful stuff -->Conky docs

Last edited by SwitchPT (2013-12-19 20:38:30)

Offline

#3 2016-05-21 12:00:27

belette
Guest

Re: Conky battery time remaining - without the seconds

Thanks for the tips smile I was trying to do the same, working great

#4 2016-05-21 14:47:01

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,654

Re: Conky battery time remaining - without the seconds

Glad to hear it is working.   I am going to take this opportunity to close this old thread.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB