From 12551449f730c832e533484bea0be364497d1a2a Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Fri, 9 Jan 2009 14:42:34 -0600 Subject: [PATCH] added load-average and mem-available status bar items --- bin/cpu-count | 2 +- bin/cpu-freq | 4 ++-- bin/load-average | 3 +++ bin/mem-available | 12 ++++++++++++ debian/changelog | 8 ++++++-- debian/install | 2 ++ profiles/common | 4 +++- profiles/ubuntu.screenrc | 6 +++++- 8 files changed, 34 insertions(+), 7 deletions(-) create mode 100755 bin/load-average create mode 100755 bin/mem-available diff --git a/bin/cpu-count b/bin/cpu-count index ae8f9d4e..fa923ef4 100755 --- a/bin/cpu-count +++ b/bin/cpu-count @@ -4,5 +4,5 @@ count=`grep -c "^processor.*:" /proc/cpuinfo` if [ "$count" = "1" ]; then echo else - echo $count"x " + echo $count"x" fi diff --git a/bin/cpu-freq b/bin/cpu-freq index 5a03eb06..8ab97745 100755 --- a/bin/cpu-freq +++ b/bin/cpu-freq @@ -3,7 +3,7 @@ mhz=`grep -m 1 "^cpu MHz" /proc/cpuinfo | sed "s/^.*: //" | sed "s/\..*$//"` if [ $mhz -gt 1000 -a -x /usr/bin/bc ]; then ghz=$(echo "scale=1; $mhz/1000" | bc) - echo "$ghz GHz" + echo "$ghz""GHz" else - echo "$mhz MHz" + echo "$mhz""MHz" fi diff --git a/bin/load-average b/bin/load-average new file mode 100755 index 00000000..0ed04d55 --- /dev/null +++ b/bin/load-average @@ -0,0 +1,3 @@ +#!/bin/sh + +cat /proc/loadavg | cut -d " " -f -1 diff --git a/bin/mem-available b/bin/mem-available new file mode 100755 index 00000000..b33a8b2c --- /dev/null +++ b/bin/mem-available @@ -0,0 +1,12 @@ +#!/bin/sh + +mem=`grep -m 1 "^MemTotal:" /proc/meminfo | sed 's/ kB$//' | sed 's/^.* //'` +if [ $mem -gt 1000000 -a -x /usr/bin/bc ]; then + mem=$(echo "scale=1; $mem/1000000" | bc) + echo "$mem""GB" +elif [ $mem -gt 1000 -a -x /usr/bin/bc ]; then + mem=$(echo "scale=1; $mem/1000" | bc) + echo "$mem""MB" +else + echo "$mem""KB" +fi diff --git a/debian/changelog b/debian/changelog index 51d3a16d..c8c7c03b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,12 @@ screen-profiles (1.5) UNRELEASED; urgency=low - * + [ Dustin Kirkland ] + * bin/mem-available: added a memory count script + * bin/load-average: added a load average script + * debian/install, profiles/common, profiles/ubuntu.screenrc: + updated with mem and load status scripts - -- Dustin Kirkland Wed, 07 Jan 2009 17:44:59 -0600 + -- Dustin Kirkland Fri, 09 Jan 2009 14:42:08 -0600 screen-profiles (1.4-0ubuntu1) jaunty; urgency=low diff --git a/debian/install b/debian/install index f6c7ad19..44ac7470 100644 --- a/debian/install +++ b/debian/install @@ -1,5 +1,7 @@ bin/cpu-count usr/share/screen-profiles/bin bin/cpu-freq usr/share/screen-profiles/bin +bin/load-average usr/share/screen-profiles/bin +bin/mem-available usr/share/screen-profiles/bin bin/reboot-required usr/share/screen-profiles/bin bin/release usr/share/screen-profiles/bin bin/updates-available usr/share/screen-profiles/bin diff --git a/profiles/common b/profiles/common index de567abe..d0d38cfd 100644 --- a/profiles/common +++ b/profiles/common @@ -27,7 +27,9 @@ backtick 100 3600 3600 /usr/share/screen-profiles/bin/release backtick 101 3600 3600 /usr/share/screen-profiles/bin/updates-available backtick 102 10 10 /usr/share/screen-profiles/bin/reboot-required backtick 103 5 5 /usr/share/screen-profiles/bin/cpu-freq -backtick 104 999999 999999 /usr/share/screen-profiles/bin/cpu-count +backtick 104 3600 3600 /usr/share/screen-profiles/bin/cpu-count +backtick 105 3600 3600 /usr/share/screen-profiles/bin/mem-available +backtick 106 5 5 /usr/share/screen-profiles/bin/load-average hardstatus alwayslastline diff --git a/profiles/ubuntu.screenrc b/profiles/ubuntu.screenrc index f85ad769..f6910bde 100644 --- a/profiles/ubuntu.screenrc +++ b/profiles/ubuntu.screenrc @@ -21,4 +21,8 @@ source /usr/share/screen-profiles/profiles/common -hardstatus string '%{Wk} %{= Wk}%{+b r}\%{= Wy}o%{=b WY}/%{+b Wk} %100` %{= Wk}|%= |%{+B bW}%102`%{= Wk}|%{+b rW}%101`%{= Wk}|%{k}%104`%{+b gW}%103`%{= Wk}|%{= Wk}%Y-%m-%d %c:%s' +hardstatus string '%{+b Wr}\%{= Wy}o%{=b WY}/%{=b Wk} %100` %{= Wk}|%= |%{=B bW}%102`%{= Wk}|%{=b rW}%101`%{= Wk}|%{= Yk}%106`%{= Wk}|%{= Wk}%104`%{=b gW}%103`%{= Wk} %{=b gW}%105`%{= Wk}|%Y-%m-%d %c:%s' + +# NOTE: There's a strange limit of only being able to change colors 16 times +# in this 'hardstatus string'. Probably need to increase the size of some +# data structure in the screen code itself.