--- trunk/dwm-status.pl 2008/10/25 21:42:24 95 +++ trunk/dwm-status.pl 2010/06/30 15:21:02 136 @@ -16,7 +16,7 @@ my $disk_blk_size = 512; my $debug = shift @ARGV; -my $awesome = 1; +my $awesome = 0; $|=1; @@ -28,7 +28,7 @@ while(<$fh>) { chomp; my ( $key, $value ) = split(/:\s+/, $_, 2); - $value =~ s/ m[VW]h*$//; + $value =~ s/ m[AVW]h*$//; $h->{$key} = $value; } warn "$f ",dump( $h ) if ( $debug ); @@ -100,12 +100,12 @@ my $s = strftime("%Y-%m-%d %H:%M:%S", localtime()); if ( $i % $acpi_every == 0 ) { - if ( -e $sys_fs ) { + my $sysfs_path = glob "$sys_fs/*_full"; + if ( $sysfs_path ) { - my $path = glob "$sys_fs/*_full"; - my $full = read_file( $path ); - $path =~ s/_full/_now/; - my $now = read_file( $path ); + my $full = read_file( $sysfs_path ); + $sysfs_path =~ s/_full/_now/; + my $now = read_file( $sysfs_path ); $bat = sprintf("%2d%% | ", $now * 100 / $full ); } elsif ( $proc_acpi_battery ) { @@ -154,13 +154,14 @@ foreach ( split(/\n/, $net) ) { s/^\s+//; - s/:\s+/:/; + s/:\s*/ /; my @n = split(/\s+/, $_, 17); - next unless ( $n[0] =~ s!(eth\d|ath\d):!! ); + #next unless ( $n[0] =~ s!(eth\d|ath\d):!! ); + next unless $n[1] =~ m{^\d+$}; warn dump( @n ) if ($debug); - $rx += $n[0]; - $tx += $n[8]; + $rx += $n[1]; + $tx += $n[9]; } warn "rx: $rx tx: $tx\n" if ($debug); @@ -186,18 +187,21 @@ my $d_write = ( $d_w - $ld_w ) / $dt; ( $ld_r, $ld_w ) = ( $d_r, $d_w ); - my $out = sprintf("%s | %s |%5s D %-5s|%5s > %-5s| %s%s\n", - $s, + my $out = sprintf("%s |%5s D %-5s|%5s > %-5s| %s%s | %s", $load, unit( $d_read ), unit( $d_write ), unit( $net_rx ), unit( $net_tx ), $bat, $temp, + $s, ); - print $out; + print "$out\n"; if ( $awesome ) { open(my $fh, '|-', 'awesome-client') || die "can't pipe to awesome-client: $!"; - print $fh "0 widget_tell mystatusbar dwm-status text $out\n"; + print $fh + $awesome == 3 ? qq{mytextbox.text="$out"\n} + : "0 widget_tell mystatusbar dwm-status text $out\n" + ; close($fh); }