Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-18 Thread Christian Garbs
On Sat, Sep 15, 2007 at 01:49:17PM -0700, Amit wrote:

 I've tried modifying the .xinitrc to contain the battery percentage
 level from apm but I cannot seem to get it. What is the proper way
 to do this?

I use this script:
http://oni.tomodachi.de/~mitch/tmp/battery.pl

Call it with -s to get a one line output suitable for dwm.
It works with ACPI instead of APM though.

Regards,
Christian
-- 
Christian.Garbs.http://www.cgarbs.de

Bitte um Erleuchtung. Am besten 220V~, nicht gelb, nicht Pikachu.
-- Thomas Neumann in de.alt.anime




Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-16 Thread Albert Cardona



MAX_BATTERY_CAPACITY=84240
while true
do
   echo `date '+%Y%m%d %H:%M'` `uptime | sed 's/.*: 
\(.\...\),.*/\1/'` $(( (`cat /proc/acpi/battery/BAT0/state | grep 
remaining capacity | sed 's/.*: \{5,\}\(.*\) mWh/\1/'` * 100) / 
$MAX_BATTERY_CAPACITY))%

   sleep 20
done | /home/albert/Programming/suckless/bin/dwm



Beware of email's silly line breaks.

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona




Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-16 Thread Amit
Thank you for all the responses.

Actually right now, I am using apm. I am not sure if acpi is supported
on my notebook. This is an old PowerBook G4 500MHz. I will try
modifying the scripts to use apm instead of acpi.

Amit



Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-16 Thread Riccardo Murri
On 9/16/07, Amit [EMAIL PROTECTED] wrote:
 Actually right now, I am using apm. I am not sure if acpi is supported
 on my notebook. This is an old PowerBook G4 500MHz. I will try
 modifying the scripts to use apm instead of acpi.


If it's a PowerBook G4, then it's using PMU, not ACPI nor APM.

Under GNU/Linux, you can use the command `pbbcmd` to query the battery status::

  $ pbbcmd query powersource
  0   # -- outputs 0 if running on battery, and 1 if running on AC power.
::

  $ pbbcmd query timeremaining
  8760  # -- remaining running time in seconds.

Or you can directly parse the /proc/pmu/battery_0 file::

  $ cat /proc/pmu/battery_0
  flags  : 0011
  charge : 3251
  max_charge : 3251
  current: -1334
  voltage: 12613
  time rem.  : 8773

For instance you could define a `battstat` command::

  #! /bin/sh
  if [ -r /proc/pmu/battery_0 ]; then
sed -e 's/ *: */ /' /proc/pmu/battery_0 | ( \
   while read key value; do
 case $key in
charge) charge=$value;;
max_charge) max_charge=$value;;
current) if [ $value -eq 0 ]; then on_ac_power=yes; fi;;
 esac
  done
  if [ -z $on_ac_power ]; then
echo batt:$(expr $charge \* 100 / $max_charge )%
  else
echo (AC)
  fi
)
  fi

And then invoke dwm like::

  (while sleep 10; do battstat; done) | dwm

 Riccardo



Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-16 Thread James Turner

On Sep 16, 2007, at 4:34 PM, Amit wrote:


Thank you for all the responses.

Actually right now, I am using apm. I am not sure if acpi is supported
on my notebook. This is an old PowerBook G4 500MHz. I will try
modifying the scripts to use apm instead of acpi.

Amit


I just use something like this echo `/usr/sbin/apm -l`%.  If all  
you want is

the remaining percentage it does the trick nicely.

--
James Turner
BSD Group Consulting
http://www.bsdgroup.org




Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-15 Thread pancake
You will probably be using acpi instead of apm.

Install 'powersave' or just type 'acpitool'.

$ powersave -b
Battery: 100 %
AC is online.

$ acpitool 
  Battery #1 : charged, 100.0%, -462:00:00
  AC adapter : on-line
  Thermal zone 1 : ok, 63 C

$ acpitool -b
  Battery #1 : charged, 100.0%, -462:00:00

--pancake

On Sat, 15 Sep 2007 13:49:17 -0700
Amit [EMAIL PROTECTED] wrote:

 Hey guys,
 
 I've tried modifying the .xinitrc to contain the battery percentage
 level from apm but I cannot seem to get it. What is the proper way to
 do this? I am sure many of you have this on your status bar. Any hints
 or suggestions on how to approach this issue?
 
 Thanks,
 Amit
 



Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-15 Thread Alexander Polakov
* Amit [EMAIL PROTECTED] [070916 00:51]:
 Hey guys,
 
 I've tried modifying the .xinitrc to contain the battery percentage
 level from apm but I cannot seem to get it. What is the proper way to
 do this? I am sure many of you have this on your status bar. Any hints
 or suggestions on how to approach this issue?
 
 Thanks,
 Amit

AFAIK apm is not supported in new models of notebooks. I made a small tool
for myself [1]. It shows battery charge (via acpi), cpu frequency, network 
interface traffic,
time and load. It's linux specific.
Looks like this:
bat0: 100% cpu0: 800 | ppp0: [5205Kb|2215Kb] | 01:02 | 0.03

[1] http://rootshell.be/~polachok/statusd-46.tar.gz
-- 
Alexander Polakov | http://polachok.livejournal.com
Russian DWM users | http://community.livejournal.com/ru_dwm/



Re: [dwm] Proper way of monitoring battery level in DWM

2007-09-15 Thread Xavier
On Sat, Sep 15, 2007 at 11:04:15PM +0200, pancake wrote:
 You will probably be using acpi instead of apm.
 
 Install 'powersave' or just type 'acpitool'.
 
 $ powersave -b
 Battery: 100 %
 AC is online.
 
 $ acpitool 
   Battery #1 : charged, 100.0%, -462:00:00
   AC adapter : on-line
   Thermal zone 1 : ok, 63 C
 
 $ acpitool -b
   Battery #1 : charged, 100.0%, -462:00:00
 

There is another little tool just called acpi :
http://grahame.angrygoats.net/acpi.shtml

$ acpi
  Battery 1: charged, 100%