16 |
my $disk_blk_size = 512; |
my $disk_blk_size = 512; |
17 |
|
|
18 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
19 |
my $awesome = 1; |
my $awesome = 3; |
20 |
|
|
21 |
$|=1; |
$|=1; |
22 |
|
|
28 |
while(<$fh>) { |
while(<$fh>) { |
29 |
chomp; |
chomp; |
30 |
my ( $key, $value ) = split(/:\s+/, $_, 2); |
my ( $key, $value ) = split(/:\s+/, $_, 2); |
31 |
$value =~ s/ m[VW]h*$//; |
$value =~ s/ m[AVW]h*$//; |
32 |
$h->{$key} = $value; |
$h->{$key} = $value; |
33 |
} |
} |
34 |
warn "$f ",dump( $h ) if ( $debug ); |
warn "$f ",dump( $h ) if ( $debug ); |
100 |
my $s = strftime("%Y-%m-%d %H:%M:%S", localtime()); |
my $s = strftime("%Y-%m-%d %H:%M:%S", localtime()); |
101 |
|
|
102 |
if ( $i % $acpi_every == 0 ) { |
if ( $i % $acpi_every == 0 ) { |
103 |
if ( $proc_acpi_battery ) { |
my $sysfs_path = glob "$sys_fs/*_full"; |
104 |
|
if ( $sysfs_path ) { |
105 |
|
|
106 |
|
my $full = read_file( $sysfs_path ); |
107 |
|
$sysfs_path =~ s/_full/_now/; |
108 |
|
my $now = read_file( $sysfs_path ); |
109 |
|
$bat = sprintf("%2d%% | ", $now * 100 / $full ); |
110 |
|
|
111 |
|
} elsif ( $proc_acpi_battery ) { |
112 |
|
|
113 |
my $state = proc2hash( "$proc_acpi_battery/state" ); |
my $state = proc2hash( "$proc_acpi_battery/state" ); |
114 |
|
|
132 |
$state->{'present rate'} / 1000 |
$state->{'present rate'} / 1000 |
133 |
); |
); |
134 |
} |
} |
|
} elsif ( -e $sys_fs ) { |
|
|
my $full = read_file( "$sys_fs/charge_full" ); |
|
|
my $now = read_file( "$sys_fs/charge_now" ); |
|
|
$bat = sprintf("%2d%% | ", $now * 100 / $full ); |
|
135 |
} |
} |
136 |
} else { |
} else { |
137 |
$bat =~ s/!(\|\s)$/ $1/; |
$bat =~ s/!(\|\s)$/ $1/; |
156 |
s/^\s+//; |
s/^\s+//; |
157 |
s/:\s+/:/; |
s/:\s+/:/; |
158 |
my @n = split(/\s+/, $_, 17); |
my @n = split(/\s+/, $_, 17); |
159 |
next unless ( $n[0] =~ s!(eth\d|ath\d):!! ); |
#next unless ( $n[0] =~ s!(eth\d|ath\d):!! ); |
160 |
|
next unless $n[1] =~ m{^\d+$}; |
161 |
|
|
162 |
warn dump( @n ) if ($debug); |
warn dump( @n ) if ($debug); |
163 |
$rx += $n[0]; |
$rx += $n[1]; |
164 |
$tx += $n[8]; |
$tx += $n[8]; |
165 |
} |
} |
166 |
warn "rx: $rx tx: $tx\n" if ($debug); |
warn "rx: $rx tx: $tx\n" if ($debug); |
187 |
my $d_write = ( $d_w - $ld_w ) / $dt; |
my $d_write = ( $d_w - $ld_w ) / $dt; |
188 |
( $ld_r, $ld_w ) = ( $d_r, $d_w ); |
( $ld_r, $ld_w ) = ( $d_r, $d_w ); |
189 |
|
|
190 |
my $out = sprintf("%s | %s |%5s D %-5s|%5s > %-5s| %s%s\n", |
my $out = sprintf("%s | %s |%5s D %-5s|%5s > %-5s| %s%s", |
191 |
$s, |
$s, |
192 |
$load, |
$load, |
193 |
unit( $d_read ), unit( $d_write ), |
unit( $d_read ), unit( $d_write ), |
195 |
$bat, $temp, |
$bat, $temp, |
196 |
); |
); |
197 |
|
|
198 |
print $out; |
print "$out\n"; |
199 |
if ( $awesome ) { |
if ( $awesome ) { |
200 |
open(my $fh, '|-', 'awesome-client') || die "can't pipe to awesome-client: $!"; |
open(my $fh, '|-', 'awesome-client') || die "can't pipe to awesome-client: $!"; |
201 |
print $fh "0 widget_tell mystatusbar dwm-status text $out\n"; |
print $fh |
202 |
|
$awesome == 3 ? qq{mytextbox.text="$out"\n} |
203 |
|
: "0 widget_tell mystatusbar dwm-status text $out\n" |
204 |
|
; |
205 |
close($fh); |
close($fh); |
206 |
} |
} |
207 |
|
|