From ebdf67298438e5c29550f6e3020b0b313ad50777 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 7 Jun 2011 18:08:08 +0200 Subject: [PATCH] bin/battery.pl: Add tmux mode. --- bin/battery.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/battery.pl b/bin/battery.pl index 31501ac..6a9ce2c 100755 --- a/bin/battery.pl +++ b/bin/battery.pl @@ -13,6 +13,7 @@ if (! -e $path) { } my $screen_mode = (defined $ARGV[0] and $ARGV[0] eq '-s'); +my $tmux_mode = (defined $ARGV[0] and $ARGV[0] eq '-t'); my %battery; @@ -37,6 +38,18 @@ if ($screen_mode) { } print "\005{+$color}$charge%\005{-}\n"; +# Same in tmux mode. +} elsif ($tmux_mode) { + my $color; + if ($charge < 20) { + $color = 'red'; + } elsif ($charge < 40) { + $color = 'yellow'; + } else { + $color = 'green'; + } + + print "#[fg=$color,bold]$charge%#[default]\n"; # Just text output. } else { -- 2.45.2