Revision 31
- Date:
- 2007/05/26 23:47:35
- Files:
Legend:
- Added
- Removed
- Modified
-
trunk/dwm-status.pl
11 11 use Data::Dump qw/dump/; 12 12 13 13 my $dt = 3; 14 my $acpi_every = 3; 14 my $acpi_every = 10; 15 15 16 my $debug = 0; 16 my $debug = shift @ARGV; 17 17 18 18 $|=1; 19 19 … … 33 33 34 34 sub unit { 35 35 my $v = shift; 36 36 37 warn "unit( $v )\n" if ($debug); 38 37 39 my @units = qw/b k m g/; 38 40 my $o = 0; 39 41 … … 42 44 $v /= 1024; 43 45 } 44 46 45 return sprintf("%d%s/s", $v, $units[$o]); 47 if ( $v >= 1 ) { 48 return sprintf("%d%s/s", $v, $units[$o]); 49 } else { 50 return sprintf("%.1f%s/s", $v, $units[$o]); 51 } 46 52 } 47 53 48 54 my ( $lrx, $ltx ) = ( 0, 0 ); … … 62 68 63 69 my $time = ( $bat->{info}->{'design capacity'} - $bat->{state}->{'remaining capacity'} ) / $bat->{state}->{'present rate'}; 64 70 71 warn "time = $time\n" if ($debug); 72 65 73 $bat->{hh} = int( $time ); 66 74 $bat->{mm} = int( ( $time - $bat->{hh} ) * 60 ); 67 75 $bat->{ss} = ( $time * 3600 ) % 60; … … 99 107 my $t = ( $tx - $ltx ) / $dt; 100 108 ( $lrx, $ltx ) = ( $rx, $tx ); 101 109 102 printf "%s | %s |%6s >> %-6s| %s %2d%% %02d:%02d:%02d%s| %s\n", 110 printf "%s | %s |%6s >> %-6s| %s %2d%% %02d:%02d:%02d %3.1fW%s| %s\n", 103 111 $s, 104 112 $load, 105 113 unit( $r ), unit( $t ), 106 substr($bat->{state}->{'charging state'},0,1), $bat->{pcnt} * 100, $bat->{hh}, $bat->{mm}, $bat->{ss}, $bat->{new}, 114 substr($bat->{state}->{'charging state'},0,1), $bat->{pcnt} * 100, $bat->{hh}, $bat->{mm}, $bat->{ss}, 115 $bat->{state}->{'present rate'} / 1000, $bat->{new}, 107 116 $temp; 108 117 109 118 sleep $dt;