summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-03-20 15:57:25 -0400
committerJesse Luehrs <doy@tozt.net>2014-03-20 16:00:05 -0400
commit6d9aa8974214399425b94e359be4da5c8b465605 (patch)
tree3f4fbe53d7b700e45f5a98046d2b18b4efdd383c /bin
parent8a43e8a4ffac0ee9c5bfb4753b1dfaf43add43da (diff)
downloadconf-6d9aa8974214399425b94e359be4da5c8b465605.tar.gz
conf-6d9aa8974214399425b94e359be4da5c8b465605.zip
formatting
Diffstat (limited to 'bin')
-rwxr-xr-xbin/status27
1 files changed, 16 insertions, 11 deletions
diff --git a/bin/status b/bin/status
index 581657f..d3f2504 100755
--- a/bin/status
+++ b/bin/status
@@ -34,10 +34,10 @@ while (<$i3status>) {
my $rate = sprintf("%6s/%6s", map { human_bytes($_) } $up, $down);
$item->{full_text} =~ s{^($iface:)}{$1 $rate};
$item->{color} =
- $up + $down >= 512000 ? '#FF0000'
- : $up + $down >= 51200 ? '#FFFF00'
- : $up + $down >= 5120 ? '#00FF00'
- : '#FFFFFF';
+ $up + $down >= 512000 ? '#FF0000'
+ : $up + $down >= 51200 ? '#FFFF00'
+ : $up + $down >= 5120 ? '#00FF00'
+ : '#FFFFFF';
}
if ($item->{name} eq 'cpu_usage') {
my ($val) = $line{load}{full_text} * 100 / ncpu();
@@ -49,10 +49,13 @@ while (<$i3status>) {
}
if ($item->{name} eq 'battery') {
my ($state, $val) = $item->{full_text} =~ /(\w+) (\d+(?:\.\d+))%/;
- ($discharge_rate{$item->{instance}}) = $item->{full_text} =~ /\(.* (.*)W\)/;
- $discharge_rate{$item->{instance}} *= -1 if defined($discharge_rate{$item->{instance}}) && $state ne 'BAT';
- $discharge_rate{$item->{instance}} //= 0;
+ my ($rate) = $item->{full_text} =~ /\(.* (.*)W\)/;
+ $rate *= -1 if defined($rate) && $state ne 'BAT';
+ $rate //= 0;
+
+ $discharge_rate{$item->{instance}} = $rate;
$battery_index{$item->{instance}} = $index;
+
$item->{full_text} =~ s/\((.*) (.*)W\)/\($1\)/;
$item->{color} =
$val >= 80 ? '#00FF00'
@@ -65,15 +68,17 @@ while (<$i3status>) {
$index++;
}
- for my $battery (sort { $battery_index{$b} <=> $battery_index{$a} } keys %battery_index) {
+ my @batteries = sort { $battery_index{$b} <=> $battery_index{$a} }
+ keys %battery_index;
+ for my $battery (@batteries) {
splice @$line, $battery_index{$battery} + 1, 0, {
name => 'battery_discharge',
full_text => sprintf("%0.2fW", $discharge_rate{$battery}),
color => (
$discharge_rate{$battery} < 8 ? '#FFFFFF'
- : $discharge_rate{$battery} < 12 ? '#00FF00'
- : $discharge_rate{$battery} < 20 ? '#FFFF00'
- : '#FF0000'
+ : $discharge_rate{$battery} < 12 ? '#00FF00'
+ : $discharge_rate{$battery} < 20 ? '#FFFF00'
+ : '#FF0000'
),
};
}