From f9ea04be3498360c64fc1596cb104aa536eb7818 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sat, 12 Dec 2009 21:06:58 -0800 Subject: [PATCH] bin/apport, bin/battery, bin/cpu_freq, bin/custom, bin/disk, bin/ec2_cost, bin/fan_speed, bin/hostname, bin/ip_address, bin/load_average, bin/logo, bin/mail, bin/mem_available, bin/mem_used, bin/menu, bin/network, bin/processes, bin/reboot_required, bin/release, bin/temp_c, bin/temp_f, bin/updates_available, bin/uptime, bin/users, bin/whoami, bin/wifi_quality, byobu-status, statusrc: define and use a color function for all status indicators, gives infinite flexibility --- bin/apport | 3 ++- bin/battery | 15 ++++++----- bin/cpu_freq | 3 ++- bin/custom | 5 ++-- bin/disk | 3 ++- bin/ec2_cost | 3 ++- bin/fan_speed | 3 ++- bin/hostname | 3 ++- bin/ip_address | 3 ++- bin/load_average | 3 ++- bin/logo | 31 +++++++++++----------- bin/mail | 3 ++- bin/mem_available | 3 ++- bin/mem_used | 3 ++- bin/menu | 3 ++- bin/network | 3 ++- bin/processes | 3 ++- bin/reboot_required | 5 ++-- bin/release | 3 ++- bin/temp_c | 3 ++- bin/temp_f | 3 ++- bin/updates_available | 5 ++-- bin/uptime | 5 ++-- bin/users | 3 ++- bin/whoami | 4 ++- bin/wifi_quality | 3 ++- byobu-status | 23 +++++++++++++++- debian/changelog | 8 ++++++ statusrc | 62 ------------------------------------------- 29 files changed, 107 insertions(+), 113 deletions(-) diff --git a/bin/apport b/bin/apport index 3b370423..a9e7def4 100755 --- a/bin/apport +++ b/bin/apport @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then if ls /var/crash/*.crash >/dev/null 2>&1; then @@ -35,4 +36,4 @@ if [ "$1" = "--detail" ]; then fi # Print {!} if a /var/crash/*.crash file exists -ls /var/crash/*.crash >/dev/null 2>&1 && printf "$yk{!}$UNDO " +ls /var/crash/*.crash >/dev/null 2>&1 && printf "$(color y k){!}$(color undo) " diff --git a/bin/battery b/bin/battery index e8d2638f..acc54a28 100755 --- a/bin/battery +++ b/bin/battery @@ -19,6 +19,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } search () { local str expr @@ -49,14 +50,14 @@ for bat in $(ls /proc/acpi/battery); do percent=$( echo "$rem" "$full" | awk '{printf "%.0f", 100*$1/$2}') if [ "$percent" -lt 33 ]; then - color="$Rk" - bcolor="$bRk" + color="$(color R k)" + bcolor="$(color b R k)" elif [ "$percent" -lt 67 ]; then - color="$Yk" - bcolor="$bYk" + color="$(color Y k)" + bcolor="$(color b Y k)" else - color="$Gk" - bcolor="$bGk" + color="$(color G k)" + bcolor="$(color b G k)" fi percent="$percent%" @@ -76,6 +77,6 @@ for bat in $(ls /proc/acpi/battery); do sign="$state" ;; esac - printf "$bcolor%s$UNDO$color|%s|$UNDO " "$percent" "$sign" + printf "$bcolor%s$(color undo)$color|%s|$(color undo) " "$percent" "$sign" break done diff --git a/bin/cpu_freq b/bin/cpu_freq index 0f49c441..53e8c93f 100755 --- a/bin/cpu_freq +++ b/bin/cpu_freq @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then cat /proc/cpuinfo @@ -29,4 +30,4 @@ if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" ]; then else freq=$(egrep -i -m 1 "^cpu MHz|^clock|^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ printf "%.1f", $2 / 1000 }') fi -printf "$bcW%s$UNDO$cW%s$UNDO " "$freq" "GHz" +printf "$(color b c W)%s$(color undo)$(color c W)%s$(color undo) " "$freq" "GHz" diff --git a/bin/custom b/bin/custom index a7cd9edd..b58184c0 100755 --- a/bin/custom +++ b/bin/custom @@ -20,6 +20,7 @@ PKG="byobu" [ -d "$HOME/.$PKG/bin" ] || exit 0 +color 2>/dev/null || color() { true; } [ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu" NOW=$(date +%s) @@ -39,9 +40,9 @@ for i in $(ls "$HOME/.$PKG/bin/"[0-9]*_* 2>/dev/null); do output=$(cat "$CACHE.$script") if echo "$output" | grep -qs "$ESC{"; then # User has formatted the colors - echo "$output" + printf "$output" else # Default to inverted coloring - echo "$INVERT$output$UNDO " + printf "$(color invert)$output$(color undo) " fi done diff --git a/bin/disk b/bin/disk index 19643b23..06f5638c 100755 --- a/bin/disk +++ b/bin/disk @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then df -h -P @@ -33,4 +34,4 @@ esac disk=$(df -h -P "$MP" 2>/dev/null || df -h "$MP") disk=$(echo "$disk" | tail -n 1 | awk '{print $2 " " $5}' | sed "s/\([^0-9\. ]\)/ \1/g" | awk '{printf "%d%sB,%d%", $1, $2, $3}') -printf "$MW%s$UNDO " "$disk" +printf "$(color M W)%s$(color undo) " "$disk" diff --git a/bin/ec2_cost b/bin/ec2_cost index 814db8fd..c87399dc 100755 --- a/bin/ec2_cost +++ b/bin/ec2_cost @@ -19,6 +19,7 @@ DETAIL=0 PKG="byobu" +color 2>/dev/null || color() { true; } for arg in $@; do case "$arg" in @@ -82,4 +83,4 @@ if [ "$DETAIL" = "1" ]; then exit 0 fi -printf "$KG~\$$UNDO$bKG%s$UNDO " $total_cost +printf "$(color K G)~\$$(color undo)$(color b K G)%s$(color undo) " $total_cost diff --git a/bin/fan_speed b/bin/fan_speed index 47a4fe7a..ef706ffd 100755 --- a/bin/fan_speed +++ b/bin/fan_speed @@ -19,6 +19,7 @@ # PKG="byobu" +color 2>/dev/null || color() { true; } DIR="/sys/class/hwmon" if [ "$1" = "--detail" ]; then @@ -32,7 +33,7 @@ fi for i in $(find $DIR/*/*/ -type f -name "fan1_input"); do speed=$(cat "$i") if [ "$speed" -gt 0 ]; then - printf "$BOLD1%s$UNDO$NONE%s$UNDO " "$speed" "rpm" + printf "$(color bold1)%s$(color undo)$(color none)%s$(color undo) " "$speed" "rpm" exit 0 fi done diff --git a/bin/hostname b/bin/hostname index 1b8133b6..7dacef4a 100755 --- a/bin/hostname +++ b/bin/hostname @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then hostname -f @@ -27,4 +28,4 @@ fi . "$HOME/.$PKG/status" [ "$whoami" = "1" ] && at="@" -printf "$BOLD2%s%s$UNDO" "$at" $(hostname -s 2>/dev/null || hostname) +printf "$(color bold2)%s%s$(color undo)" "$at" $(hostname -s 2>/dev/null || hostname) diff --git a/bin/ip_address b/bin/ip_address index 9c607a8b..a47fad19 100755 --- a/bin/ip_address +++ b/bin/ip_address @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then /sbin/ifconfig | grep "inet addr" | sed -e 's/^\s*//' -e 's/\s*$//' @@ -37,4 +38,4 @@ fi ipaddr=`/sbin/ifconfig "$interface" | grep "inet addr:" | sed -e "s/^.*inet addr://" -e "s/ .*$//"` -printf "%s$BOLD2%s$UNDO" "$space" "$ipaddr" +printf "%s$(color bold2)%s$(color undo)" "$space" "$ipaddr" diff --git a/bin/load_average b/bin/load_average index 0e995b92..d6d99579 100755 --- a/bin/load_average +++ b/bin/load_average @@ -18,10 +18,11 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then cat /proc/loadavg exit 0 fi -printf "$Yk%s$UNDO " $(awk '{print $1}' /proc/loadavg) +printf "$(color Y k)%s$(color undo) " $(awk '{print $1}' /proc/loadavg) diff --git a/bin/logo b/bin/logo index 802c1797..5e248740 100755 --- a/bin/logo +++ b/bin/logo @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then MARKUP="false" @@ -30,63 +31,63 @@ print_logo() { distro=`echo "$1" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' ` case "$distro" in *ubuntu*) - $MARKUP && printf "$bkr%s$ky%s$bkY%s" "\\" "o" "/" || printf "\\o/" + $MARKUP && printf "$(color b k r)%s$(color k y)%s$(color b k Y)%s" "\\" "o" "/" || printf "\\o/" ;; *altlinux*) logo="alt" - $MARKUP && printf "$Yk%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color Y k)%s" "$logo" || printf "$logo" ;; *arch*) logo=" A " - $MARKUP && printf "$bwb%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color b w b)%s" "$logo" || printf "$logo" ;; *centos*) logo="****" - $MARKUP && printf "$gw*$mw*$yw*$bw*" || printf "$logo" + $MARKUP && printf "$(color g w)*$(color m w)*$(color y w)*$(color b w)*" || printf "$logo" ;; *debian*) logo=" @ " - $MARKUP && printf "$wr%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color w r)%s" "$logo" || printf "$logo" ;; *fedora*) logo=" f " - $MARKUP && printf "$bw%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color b w)%s" "$logo" || printf "$logo" ;; *foresight*) logo="<@>" - $MARKUP && printf "$bWg%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color b W g)%s" "$logo" || printf "$logo" ;; *gentoo*) logo=" > " - $MARKUP && printf "$bcw%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color b c w)%s" "$logo" || printf "$logo" ;; *mandriva*) logo=" (* " - $MARKUP && printf "$bkc ($bky* " || printf "$logo" + $MARKUP && printf "$(color b k c) ($(color b k y)* " || printf "$logo" ;; *redhat*) logo=" RH " - $MARKUP && printf "$Rk%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color R k)%s" "$logo" || printf "$logo" ;; *rockhopper*) logo="palm" - $MARKUP && printf "$kw%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color k w)%s" "$logo" || printf "$logo" ;; *slackware*) logo=".S " - $MARKUP && printf "$uBk%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color u B k)%s" "$logo" || printf "$logo" ;; *suse*) logo="SuSE" - $MARKUP && printf "$Wg%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color W g)%s" "$logo" || printf "$logo" ;; *xandros*) logo=" X " - $MARKUP && printf "$Wr%s" "$logo" || printf "$logo" + $MARKUP && printf "$(color W r)%s" "$logo" || printf "$logo" ;; *) logo="[B]" - $MARKUP && printf "$bkW%s" "$logo" || printf " $logo " + $MARKUP && printf "$(color b k W)%s" "$logo" || printf " $logo " ;; esac } diff --git a/bin/mail b/bin/mail index 73f91b5a..914b71e7 100755 --- a/bin/mail +++ b/bin/mail @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } mailfile="/var/spool/mail/$USER" if [ "$1" = "--detail" ]; then @@ -25,4 +26,4 @@ if [ "$1" = "--detail" ]; then exit 0 fi -[ -s "$mailfile" ] && printf "$wk[M]$UNDO " || exit 0 +[ -s "$mailfile" ] && printf "$(color w k)[M]$(color undo) " || exit 0 diff --git a/bin/mem_available b/bin/mem_available index dced60a0..2a69784f 100755 --- a/bin/mem_available +++ b/bin/mem_available @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then free @@ -38,4 +39,4 @@ else mem="$mem" unit="KB" fi -printf "$bgW%s$UNDO$gW$unit%s$UNDO%s" "$mem" "$comma" "$whitespace" +printf "$(color b g W)%s$(color undo)$(color g W)$unit%s$(color undo)%s" "$mem" "$comma" "$whitespace" diff --git a/bin/mem_used b/bin/mem_used index 87a21c9b..908ac722 100755 --- a/bin/mem_used +++ b/bin/mem_used @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then cat /proc/meminfo @@ -25,4 +26,4 @@ if [ "$1" = "--detail" ]; then fi f=$(free | awk '/buffers\/cache:/ {printf "%.0f", 100*$3/($3 + $4)}') -printf "$bgW%s$UNDO$gW%%$UNDO " "$f" +printf "$(color b g W)%s$(color undo)$(color g W)%%$(color undo) " "$f" diff --git a/bin/menu b/bin/menu index 910bf579..d0ed1492 100755 --- a/bin/menu +++ b/bin/menu @@ -19,6 +19,7 @@ [ "$1" = "--detail" ] && exit 0 PKG="byobu" +color 2>/dev/null || color() { true; } [ -r "$HOME/.$PKG/keybindings" ] && bindings="$HOME/.$PKG/keybindings" || bindings="$HOME/.screenrc" @@ -31,4 +32,4 @@ else key="F9" fi -printf " $kw%s:<$UNDO$bkw$key$kw>" `gettext "Menu"` +printf " $(color k w)%s:<$(color undo)$(color b k w)$key$(color k w)>" `gettext "Menu"` diff --git a/bin/network b/bin/network index 08093f18..cb46722b 100755 --- a/bin/network +++ b/bin/network @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } # Allow interface overrides in $HOME/.$PKG/status if [ -n "$MONITORED_NETWORK" ]; then @@ -57,5 +58,5 @@ for i in up down; do unit="MB/s" fi fi - printf "$symbol$bmw$rate$UNDO$mw$unit$UNDO " + printf "$symbol$(color b m w)$rate$(color undo)$(color m w)$unit$(color undo) " done diff --git a/bin/processes b/bin/processes index 49289a18..193d4f48 100755 --- a/bin/processes +++ b/bin/processes @@ -18,10 +18,11 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then ps -ejH exit 0 fi -printf "$byw%s$UNDO$yw&$UNDO " $(ls -d /proc/[0-9]* 2>/dev/null| wc -l) +printf "$(color b y w)%s$(color undo)$(color y w)&$(color undo) " $(ls -d /proc/[0-9]* 2>/dev/null| wc -l) diff --git a/bin/reboot_required b/bin/reboot_required index e0af70b3..930cc5ad 100755 --- a/bin/reboot_required +++ b/bin/reboot_required @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } reboot="/var/run/reboot-required" [ -d "/var/run/screen/S-$USER" ] && DIR="/var/run/screen/S-$USER" || DIR="$HOME/.byobu" @@ -30,7 +31,7 @@ case "$1" in [ -e "$reboot" ] && printf "Yes" || printf "No" ;; *) - [ -e "$reboot" ] && printf "$bW($UNDO$bbW%s$UNDO$bW)$UNDO " "R" - [ -e "$reload" ] && printf "$bW<$UNDO$bbW%s$UNDO$bW>$UNDO " "F5" + [ -e "$reboot" ] && printf "$(color b W)($(color undo)$(color b b W)%s$(color undo)$(color b W))$(color undo) " "R" + [ -e "$reload" ] && printf "$(color b W)<$(color undo)$(color b b W)%s$(color undo)$(color b W)>$(color undo) " "F5" ;; esac diff --git a/bin/release b/bin/release index 146d4f1f..311d5c45 100755 --- a/bin/release +++ b/bin/release @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then cat /etc/issue @@ -54,4 +55,4 @@ else DISTRO="Byobu" fi -printf "$BOLD2%s$UNDO " "$DISTRO" +printf "$(color bold2)%s$(color undo) " "$DISTRO" diff --git a/bin/temp_c b/bin/temp_c index bb3239e0..0af30ee5 100755 --- a/bin/temp_c +++ b/bin/temp_c @@ -19,6 +19,7 @@ # PKG="byobu" +color 2>/dev/null || color() { true; } DIR="/proc/acpi/thermal_zone" if [ "$1" = "--detail" ]; then @@ -31,6 +32,6 @@ fi for i in $MONITORED_TEMP `ls $DIR/*/temperature 2>/dev/null`; do t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i") - printf "$bkY%s$UNDO$kY\260C$UNDO " "$t" + printf "$(color b k Y)%s$(color undo)$(color k Y)\260C$(color undo) " "$t" break done diff --git a/bin/temp_f b/bin/temp_f index 52415d45..963a9211 100755 --- a/bin/temp_f +++ b/bin/temp_f @@ -19,6 +19,7 @@ # PKG="byobu" +color 2>/dev/null || color() { true; } DIR="/proc/acpi/thermal_zone" if [ "$1" = "--detail" ]; then @@ -27,6 +28,6 @@ fi for i in `ls $DIR/*/temperature 2>/dev/null`; do t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i" | awk '{printf "%.0f", $1 *9/5 + 32}') - printf "$bkY%s$UNDO$kY\260F$UNDO " "$t" + printf "$(color b k Y)%s$(color undo)$(color k Y)\260F$(color undo) " "$t" break done diff --git a/bin/updates_available b/bin/updates_available index 099f6180..caa24f64 100755 --- a/bin/updates_available +++ b/bin/updates_available @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" -o "$1" = "--short" ]; then if which apt-get >/dev/null; then @@ -37,13 +38,13 @@ print_updates() { s=$2 if [ -n "$u" ]; then if [ "$u" -gt 0 ]; then - printf "$brW%d$UNDO$rW!" "$u" + printf "$(color b r W)%d$(color undo)$(color r W)!" "$u" if [ -n "$s" ]; then if [ "$s" -gt 0 ]; then printf "!" fi fi - printf "$UNDO " + printf "$(color undo) " fi fi } diff --git a/bin/uptime b/bin/uptime index 6a310266..37c110da 100755 --- a/bin/uptime +++ b/bin/uptime @@ -21,6 +21,7 @@ # PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then uptime @@ -28,7 +29,7 @@ if [ "$1" = "--detail" ]; then fi u=$(sed "s/\..*$//" /proc/uptime) -printf "$wb" +printf "$(color w b)" if [ "$u" -gt 86400 ]; then echo "$u" | awk '{printf "%dd%dh", $1 / 86400, ($1 % 86400)/3600 }' elif [ "$u" -gt 3600 ]; then @@ -38,4 +39,4 @@ elif [ "$u" -gt 60 ]; then else printf "%ds" "$u" fi -printf "$UNDO " +printf "$(color undo) " diff --git a/bin/users b/bin/users index c65f3299..4bcabd1b 100755 --- a/bin/users +++ b/bin/users @@ -21,6 +21,7 @@ # PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then ps -ef | grep "sshd;.*@" | grep -v grep @@ -30,4 +31,4 @@ fi # Note: we'd like to use pgrep -c, however, this isn't available in # busybox and some distro's pgrep (and it doesn't exit non-zero). count=`pgrep -f "sshd:.*@" | wc -l` || exit 0 -[ $count -gt 0 ] && printf "$bwr%d$UNDO$wr#$UNDO " $count +[ $count -gt 0 ] && printf "$(color b w r)%d$(color undo)$(color w r)#$(color undo) " $count diff --git a/bin/whoami b/bin/whoami index 6f40f7c7..f4f578d1 100755 --- a/bin/whoami +++ b/bin/whoami @@ -17,9 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +color 2>/dev/null || color() { true; } + if [ "$1" = "--detail" ]; then grep "^$USER:" /etc/passwd exit 0 fi -printf "$BOLD2%s$UNDO" $(whoami) +printf "$(color bold2)%s$(color undo)" $(whoami) diff --git a/bin/wifi_quality b/bin/wifi_quality index 6142e823..afdfe6a7 100755 --- a/bin/wifi_quality +++ b/bin/wifi_quality @@ -18,6 +18,7 @@ # along with this program. If not, see . PKG="byobu" +color 2>/dev/null || color() { true; } if [ "$1" = "--detail" ]; then /sbin/iwconfig 2>/dev/null @@ -28,4 +29,4 @@ iwconfig=`/sbin/iwconfig 2>/dev/null` bitrate=`echo "$iwconfig" | grep "Bit Rate." | sed -e "s/^.*Bit Rate.//" -e "s/ .*$//g"` [ -z "$bitrate" ] && bitrate="0" quality=`echo "$iwconfig" | grep "Link Quality." | sed -e "s/^.*Link Quality.//" -e "s/ .*$//g" | awk -F/ '{printf "%.0f", 100*$1/$2}'` -printf "$bCk%s$UNDO$Ck%s,$UNDO$bCk%s$UNDO$Ck%%$UNDO " "$bitrate" "Mbps" "$quality" +printf "$(color b C k)%s$(color undo)$(color C k)%s,$(color undo)$(color b C k)%s$(color undo)$(color C k)%%$(color UNDO) " "$bitrate" "Mbps" "$quality" diff --git a/byobu-status b/byobu-status index e00de9ae..628ae2b3 100755 --- a/byobu-status +++ b/byobu-status @@ -30,7 +30,29 @@ find_script () { fi } +# Define colors +ESC="\005" +color() { + case $1 in + "") true ;; + esc) printf "$ESC" ;; + undo) printf "$ESC{-}" ;; + bold1) printf "$ESC{=b }" ;; + bold2) printf "$ESC{+b }" ;; + none) printf "$ESC{= }" ;; + invert) printf "$ESC{=r }" ;; + *) + if [ "$#" = "2" ]; then + [ "$MONOCHROME" = "1" ] && printf "$ESC{ }" || printf "$ESC{= $1$2}" + else + [ "$MONOCHROME" = "1" ] && printf "$ESC{=$1 }" || printf "$ESC{=$1 $2$3}" + fi + ;; + esac +} + # Source configurations +[ -r "$HOME/.$PKG/color" ] && . "$HOME/.$PKG/color" [ -r "/etc/$PKG/statusrc" ] && . "/etc/$PKG/statusrc" [ -r "$HOME/.$PKG/status" ] && . "$HOME/.$PKG/status" [ -r "$HOME/.$PKG/statusrc" ] && . "$HOME/.$PKG/statusrc" @@ -53,7 +75,6 @@ case "$P" in done ;; color) - [ -r "$HOME/.$PKG/color" ] && . "$HOME/.$PKG/color" [ -z "$FOREGROUND" ] && FOREGROUND="k" [ -z "$BACKGROUND" ] && BACKGROUND="W" printf "$ESC{= $BACKGROUND$FOREGROUND}" diff --git a/debian/changelog b/debian/changelog index 3118bf12..89bbb661 100644 --- a/debian/changelog +++ b/debian/changelog @@ -63,6 +63,14 @@ byobu (2.40) unreleased; urgency=low uninstall utilities in /usr/bin * bin/*: drop sourcing of /etc/byobu/statusrc, as this is done in byobu-status now + * bin/apport, bin/battery, bin/cpu_freq, bin/custom, bin/disk, + bin/ec2_cost, bin/fan_speed, bin/hostname, bin/ip_address, + bin/load_average, bin/logo, bin/mail, bin/mem_available, bin/mem_used, + bin/menu, bin/network, bin/processes, bin/reboot_required, + bin/release, bin/temp_c, bin/temp_f, bin/updates_available, + bin/uptime, bin/users, bin/whoami, bin/wifi_quality, byobu-status, + statusrc: define and use a color function for all status indicators, + gives infinite flexibility -- Dustin Kirkland Tue, 10 Nov 2009 10:18:20 -0600 diff --git a/statusrc b/statusrc index 8f49c3ed..65d406d9 100644 --- a/statusrc +++ b/statusrc @@ -59,65 +59,3 @@ wifi_quality=0 #MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature #DISTRO=Ubuntu # END_CUT_HERE - -# Define colors -ESC="\005" -UNDO="$ESC{-}" -BOLD1="$ESC{=b }" -BOLD2="$ESC{+b }" -NONE="$ESC{= }" -INVERT="$ESC{=r }" - -bw="$ESC{= bw}" -bW="$ESC{= bW}" -cW="$ESC{= cW}" -gw="$ESC{= gw}" -gW="$ESC{= gW}" -mw="$ESC{= mw}" -rW="$ESC{= rW}" -kw="$ESC{= kw}" -kW="$ESC{= kW}" -ky="$ESC{= ky}" -kY="$ESC{= kY}" -wb="$ESC{= wb}" -wk="$ESC{= wk}" -wr="$ESC{= wr}" -yk="$ESC{= yk}" -yw="$ESC{= yw}" - -Ck="$ESC{= Ck}" -Gk="$ESC{= Gk}" -KG="$ESC{= KG}" -MW="$ESC{= MW}" -Rk="$ESC{= Rk}" -Wg="$ESC{= Wg}" -Wk="$ESC{= Wk}" -Wr="$ESC{= Wr}" -Yk="$ESC{= Yk}" - -bbW="$ESC{=b bW}" -bcw="$ESC{=b cw}" -bcW="$ESC{=b cW}" -bgW="$ESC{=b gW}" -bky="$ESC{=b ky}" -bkY="$ESC{=b kY}" -bkc="$ESC{=b kc}" -bkr="$ESC{=b kr}" -bkY="$ESC{=b kY}" -bkw="$ESC{=b kw}" -bkW="$ESC{=b kW}" -bmw="$ESC{=b mw}" -brW="$ESC{=b rW}" -bwb="$ESC{=b wb}" -bwr="$ESC{=b wr}" -byw="$ESC{=b yw}" -bCk="$ESC{=b Ck}" -bGk="$ESC{=b Gk}" -bKG="$ESC{=b KG}" -bMW="$ESC{=b MW}" -bRk="$ESC{=b Rk}" -bWg="$ESC{=b Wg}" -bWk="$ESC{=b Wk}" -bYk="$ESC{=b Yk}" - -uBk="$ESC{=u Bk}"