61 |
|
|
62 |
if ( $i % $acpi_every == 0 ) { |
if ( $i % $acpi_every == 0 ) { |
63 |
|
|
64 |
$bat->{state} = proc2hash( '/proc/acpi/battery/BAT0/state' ); |
my $state = proc2hash( '/proc/acpi/battery/BAT0/state' ); |
|
$bat->{info} = proc2hash( '/proc/acpi/battery/BAT0/info' ); |
|
65 |
|
|
66 |
$bat->{pcnt} = $bat->{state}->{'remaining capacity'} / $bat->{info}->{'design capacity'}; |
if ( $state->{'present rate'} != 0 ) { |
67 |
|
my $info = proc2hash( '/proc/acpi/battery/BAT0/info' ); |
68 |
|
|
69 |
my $time = ( $bat->{info}->{'design capacity'} - $bat->{state}->{'remaining capacity'} ) / $bat->{state}->{'present rate'}; |
my $pcnt = $state->{'remaining capacity'} / $info->{'design capacity'}; |
70 |
|
|
71 |
warn "time = $time\n" if ($debug); |
my $time = $state->{'remaining capacity'} / ( $state->{'present rate'} ); |
72 |
|
|
73 |
$bat->{hh} = int( $time ); |
warn "time = $time\n" if ($debug); |
|
$bat->{mm} = int( ( $time - $bat->{hh} ) * 60 ); |
|
|
$bat->{ss} = ( $time * 3600 ) % 60; |
|
74 |
|
|
75 |
$bat->{new} = '!'; |
my $hh = int( $time ); |
76 |
|
my $mm = int( ( $time - $hh ) * 60 ); |
77 |
|
my $ss = ( $time * 3600 ) % 60; |
78 |
|
|
79 |
|
$bat = sprintf("%s %2d%% %02d:%02d:%02d %3.1fW!| ", |
80 |
|
substr($state->{'charging state'},0,1), |
81 |
|
$pcnt * 100, $hh, $mm, $ss, |
82 |
|
$state->{'present rate'} / 1000 |
83 |
|
); |
84 |
|
|
85 |
|
} else { |
86 |
|
$bat = ''; |
87 |
|
} |
88 |
} else { |
} else { |
89 |
$bat->{new} = ' '; |
$bat =~ s/!(\|\s)$/ $1/; |
90 |
} |
} |
91 |
$i++; |
$i++; |
92 |
|
|
116 |
my $t = ( $tx - $ltx ) / $dt; |
my $t = ( $tx - $ltx ) / $dt; |
117 |
( $lrx, $ltx ) = ( $rx, $tx ); |
( $lrx, $ltx ) = ( $rx, $tx ); |
118 |
|
|
119 |
printf "%s | %s |%6s >> %-6s| %s %2d%% %02d:%02d:%02d %3.1fW%s| %s\n", |
printf "%s | %s |%6s >> %-6s| %s%s\n", $s, $load, unit( $r ), unit( $t ), $bat, $temp; |
|
$s, |
|
|
$load, |
|
|
unit( $r ), unit( $t ), |
|
|
substr($bat->{state}->{'charging state'},0,1), $bat->{pcnt} * 100, $bat->{hh}, $bat->{mm}, $bat->{ss}, |
|
|
$bat->{state}->{'present rate'} / 1000, $bat->{new}, |
|
|
$temp; |
|
120 |
|
|
121 |
sleep $dt; |
sleep $dt; |
122 |
} |
} |