--- trunk/dwm-status.pl 2007/05/26 23:18:05 30 +++ trunk/dwm-status.pl 2007/05/26 23:47:35 31 @@ -11,9 +11,9 @@ use Data::Dump qw/dump/; my $dt = 3; -my $acpi_every = 3; +my $acpi_every = 10; -my $debug = 0; +my $debug = shift @ARGV; $|=1; @@ -33,7 +33,9 @@ sub unit { my $v = shift; - + + warn "unit( $v )\n" if ($debug); + my @units = qw/b k m g/; my $o = 0; @@ -42,7 +44,11 @@ $v /= 1024; } - return sprintf("%d%s/s", $v, $units[$o]); + if ( $v >= 1 ) { + return sprintf("%d%s/s", $v, $units[$o]); + } else { + return sprintf("%.1f%s/s", $v, $units[$o]); + } } my ( $lrx, $ltx ) = ( 0, 0 ); @@ -62,6 +68,8 @@ my $time = ( $bat->{info}->{'design capacity'} - $bat->{state}->{'remaining capacity'} ) / $bat->{state}->{'present rate'}; + warn "time = $time\n" if ($debug); + $bat->{hh} = int( $time ); $bat->{mm} = int( ( $time - $bat->{hh} ) * 60 ); $bat->{ss} = ( $time * 3600 ) % 60; @@ -99,11 +107,12 @@ my $t = ( $tx - $ltx ) / $dt; ( $lrx, $ltx ) = ( $rx, $tx ); - printf "%s | %s |%6s >> %-6s| %s %2d%% %02d:%02d:%02d%s| %s\n", + printf "%s | %s |%6s >> %-6s| %s %2d%% %02d:%02d:%02d %3.1fW%s| %s\n", $s, $load, unit( $r ), unit( $t ), - substr($bat->{state}->{'charging state'},0,1), $bat->{pcnt} * 100, $bat->{hh}, $bat->{mm}, $bat->{ss}, $bat->{new}, + substr($bat->{state}->{'charging state'},0,1), $bat->{pcnt} * 100, $bat->{hh}, $bat->{mm}, $bat->{ss}, + $bat->{state}->{'present rate'} / 1000, $bat->{new}, $temp; sleep $dt;