/[scripts]/trunk/dwm-status.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/dwm-status.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Sat May 26 23:18:05 2007 UTC revision 31 by dpavlin, Sat May 26 23:47:35 2007 UTC
# Line 11  use Time::HiRes; Line 11  use Time::HiRes;
11  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
12    
13  my $dt = 3;  my $dt = 3;
14  my $acpi_every = 3;  my $acpi_every = 10;
15    
16  my $debug = 0;  my $debug = shift @ARGV;
17    
18  $|=1;  $|=1;
19    
# Line 33  sub proc2hash { Line 33  sub proc2hash {
33    
34  sub unit {  sub unit {
35          my $v = shift;          my $v = shift;
36            
37            warn "unit( $v )\n" if ($debug);
38    
39          my @units = qw/b k m g/;          my @units = qw/b k m g/;
40          my $o = 0;          my $o = 0;
41    
# Line 42  sub unit { Line 44  sub unit {
44                  $v /= 1024;                  $v /= 1024;
45          }          }
46    
47          return sprintf("%d%s/s", $v, $units[$o]);          if ( $v >= 1 ) {
48                    return sprintf("%d%s/s", $v, $units[$o]);
49            } else {
50                    return sprintf("%.1f%s/s", $v, $units[$o]);
51            }
52  }  }
53    
54  my ( $lrx, $ltx ) = ( 0, 0 );  my ( $lrx, $ltx ) = ( 0, 0 );
# Line 62  while ( 1 ) { Line 68  while ( 1 ) {
68    
69                  my $time = ( $bat->{info}->{'design capacity'} - $bat->{state}->{'remaining capacity'} ) / $bat->{state}->{'present rate'};                  my $time = ( $bat->{info}->{'design capacity'} - $bat->{state}->{'remaining capacity'} ) / $bat->{state}->{'present rate'};
70    
71                    warn "time = $time\n" if ($debug);
72    
73                  $bat->{hh} = int( $time );                  $bat->{hh} = int( $time );
74                  $bat->{mm} = int( ( $time - $bat->{hh} ) * 60 );                  $bat->{mm} = int( ( $time - $bat->{hh} ) * 60 );
75                  $bat->{ss} = ( $time * 3600 ) % 60;                  $bat->{ss} = ( $time * 3600 ) % 60;
# Line 99  while ( 1 ) { Line 107  while ( 1 ) {
107          my $t = ( $tx - $ltx ) / $dt;          my $t = ( $tx - $ltx ) / $dt;
108          ( $lrx, $ltx ) = ( $rx, $tx );          ( $lrx, $ltx ) = ( $rx, $tx );
109    
110          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",
111                  $s,                  $s,
112                  $load,                  $load,
113                  unit( $r ), unit( $t ),                  unit( $r ), unit( $t ),
114                  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},
115                            $bat->{state}->{'present rate'} / 1000, $bat->{new},
116                  $temp;                  $temp;
117    
118          sleep $dt;          sleep $dt;

Legend:
Removed from v.30  
changed lines
  Added in v.31

  ViewVC Help
Powered by ViewVC 1.1.26