Detailed status

* bin/*: add special actions if --detail is specified; basically,
    print all relevant information on stdout without formatting
  * screen-profiles-status: add support for --detail, loop through
    all status scripts with --detail specified
  * screen-profiles-status-detail: wrapper using sensible-pager
  * screen-profiles-status-detail.1: documentation added


Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-04-27 21:14:43 -05:00
commit 3adea2d373
29 changed files with 177 additions and 16 deletions

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
uname -a
exit 0
fi
printf "%s " $(uname -m)

View file

@ -31,6 +31,14 @@ search () {
BATS=$(ls /proc/acpi/battery)
NB=$(echo "$BATS" | wc -l)
if [ "$1" = "--detail" ]; then
for bat in $BATS; do
cat "/proc/acpi/battery/$bat/info"
cat "/proc/acpi/battery/$bat/state"
done
exit 0
fi
for bat in $BATS; do
if [ "$NB" -gt 1 ]; then
echo -n "$bat: "

View file

@ -19,3 +19,7 @@
count=`grep -c "^processor.*:" /proc/cpuinfo`
[ "$count" = "1" ] || echo $count"x"
if [ "$1" = "--detail" ]; then
echo
exit 0
fi

View file

@ -17,6 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
cat /proc/cpuinfo
exit 0
fi
mhz=`egrep -i -m 1 "^cpu MHz|^clock|^bogomips" /proc/cpuinfo | awk -F"[:.]" '{print $2}'`
speed=$(echo $mhz | awk '{ printf "%.1f", $1 / 1000 }')

View file

@ -17,4 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
date
exit 0
fi
printf "\005Y-\005m-\005d "

View file

@ -78,7 +78,6 @@ uptime_cost=`echo "$hours" | awk "{printf \"%f\", "$CPU_RATE" * $hours}"`
total_cost=`echo "$network_cost" "$uptime_cost" | awk '{printf "~\$%.2f", $1 + $2}'`
if [ "$DETAIL" = "1" ]; then
echo
echo "================================================"
echo "Estimated cost in Amazon's EC2 since last reboot"
echo "================================================"
@ -91,7 +90,6 @@ if [ "$DETAIL" = "1" ]; then
echo "------------------------------------------------"
echo "Total cost: $total_cost"
echo "================================================"
echo
exit 0
fi

View file

@ -17,6 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
hostname -f
exit 0
fi
at=
grep -qs "^whoami=1$" "$HOME/.screen-profiles/status" && at="@"

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
cat /proc/loadavg
exit 0
fi
printf "\005{= Yk}%s\005{-} " $(cat /proc/loadavg | cut -d " " -f -1)

View file

@ -17,32 +17,49 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
MARKUP="false"
else
MARKUP="true"
fi
print_logo() {
distro="$1"
if echo "$distro" | grep -qsi "ubuntu"; then
printf "\005{=b kr}\\\\\005{= ky}o\005{=b kY}/"
$MARKUP && printf "\005{=b kr}\\\\\005{= ky}o\005{=b kY}/" || printf "\\o/"
elif echo "$distro" | grep -qsi "arch"; then
printf "\005{=b wb} A "
logo=" A "
$MARKUP && printf "\005{=b wb}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "centos"; then
printf "\005{= gw}*\005{= mw}*\005{= yw}*\005{= bw}*%{=b Wk}"
logo="****"
$MARKUP && printf "\005{= gw}*\005{= mw}*\005{= yw}*\005{= bw}*%{=b Wk}" || printf "$logo"
elif echo "$distro" | grep -qsi "debian"; then
printf "\005{= wr} @ "
logo=" @ "
$MARKUP && printf "\005{= wr}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "fedora"; then
printf "\005{=b bw} f "
logo=" f "
$MARKUP && printf "\005{=b bw}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "foresight"; then
printf "\005{=b Wg}<@>"
logo="<@>"
$MARKUP && printf "\005{=b Wg}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "gentoo"; then
printf "\005{=b cw} > "
logo=" > "
$MARKUP && printf "\005{=b cw}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "mandriva"; then
printf "\005{=b kc} (\005{=b ky}* "
logo=" (* "
$MARKUP && printf "\005{=b kc} (\005{=b ky}* " || printf "$logo"
elif echo "$distro" | grep -qsi "redhat"; then
printf "\005{= Rk} RH "
logo=" RH "
$MARKUP && printf "\005{= Rk}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "slackware"; then
printf "\005{=u Bk},S "
logo=",S "
$MARKUP && printf "\005{=u Bk}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "suse"; then
printf "\005{= Wg}SuSE"
logo="SuSE"
$MARKUP && printf "\005{= Wg}$logo" || printf "$logo"
elif echo "$distro" | grep -qsi "xandros"; then
printf "\005{= Wr} X "
logo=" X "
$MARKUP && printf "\005{= Wr}$logo" || printf "$logo"
else
false
fi

View file

@ -17,6 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
free
exit 0
fi
comma=
whitespace=
if [ -r "$HOME/.screen-profiles/status" ]; then

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
cat /proc/meminfo
exit 0
fi
free | awk '/buffers\/cache:/ {printf "\005{= gW}%.0f%%\005{-} ", 100*$3/($3 + $4)}'

View file

@ -17,4 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
[ "$1" = "--detail" ] && exit 0
printf " \005{= kw}%s" `gettext "Menu:<F9>"`

View file

@ -21,6 +21,11 @@ cache="$HOME/.screen-profiles/network-down"
interface=`/sbin/route -n | tail -n 1 | sed "s/^.* //"`
unit="kB/s"
if [ "$1" = "--detail" ]; then
ifconfig "$interface"
exit 0
fi
t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0
t2=`date +%s`

View file

@ -22,6 +22,11 @@ cache="$HOME/.screen-profiles/network-up"
interface=`/sbin/route -n | tail -n 1 | sed "s/^.* //"`
unit="kB/s"
if [ "$1" = "--detail" ]; then
ifconfig "$interface"
exit 0
fi
t1=`stat -c %Y "$cache"` 2>/dev/null || t1=0
t2=`date +%s`

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
ps -ejH
exit 0
fi
printf "\005{= yk}%s&\005{-} " $(ps -e | wc -l)

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
[ -e /var/run/reboot-required ] && printf "Yes" || printf "No"
exit 0
fi
[ -e /var/run/reboot-required ] && printf "\005{=b bW}(@)\005{-} "

View file

@ -18,6 +18,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if which lsb_release >/dev/null; then
if [ "$1" = "--detail" ]; then
lsb_release -a 2>/dev/null
exit 0
fi
# If lsb_release is available, use it
r=$(lsb_release -s -d)
if echo "$r" | grep -qs "^Ubuntu .*\..*\..*$"; then
@ -31,6 +35,10 @@ if which lsb_release >/dev/null; then
printf "\005{=b }%s %s\005{-} " "$i" "$r"
fi
elif [ -r "/etc/issue" ]; then
if [ "$1" = "--detail" ]; then
cat /etc/issue
exit 0
fi
# Otherwise, grab part of /etc/issue
printf "\005{=b }%s\005{-} " $(head -n1 /etc/issue | awk '{print $1}')
else

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
date
exit 0
fi
printf "\0050c:\005s"

View file

@ -17,6 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
if [ -x "/usr/bin/apt-get" ]; then
/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade | grep ^Inst
fi
exit 0
fi
# expire the cache in X seconds; 1 hour by default
EXPIRATION=3600

View file

@ -20,6 +20,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if [ "$1" = "--detail" ]; then
uptime
exit 0
fi
u=$(sed "s/\..*$//" /proc/uptime)
printf "\005{= wb}"
if [ "$u" -gt 86400 ]; then

View file

@ -20,4 +20,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if [ "$1" = "--detail" ]; then
who
exit 0
fi
printf "\005{= wr}%d#\005{-} " `who | wc -l`

View file

@ -17,4 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ "$1" = "--detail" ]; then
whoami
exit 0
fi
printf "\005{=b }%s\005{-}" $(whoami)

View file

@ -18,6 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
interface=`/sbin/route -n | tail -n 1 | sed "s/^.* //"`
if [ "$1" = "--detail" ]; then
iwconfig 2>/dev/null
exit 0
fi
bitrate=`iwconfig "$interface" 2>/dev/null | grep "Bit Rate." | sed "s/^.*Bit Rate.//" | sed "s/ .*$//g"`
[ -z "$bitrate" ] && bitrate="0"
quality=`iwconfig "$interface" 2>/dev/null | grep "Link Quality=" | sed "s/^.*Link Quality=//" | sed "s/ .*$//g"`

10
debian/changelog vendored
View file

@ -4,7 +4,15 @@ screen-profiles (1.51) unreleased; urgency=low
* bin/hostname: hostname -s fails sometimes, it seems
* screen: respect $SCREENRC environment variable, LP: #367250
-- Dustin Kirkland <kirkland@ubuntu.com> Sun, 26 Apr 2009 12:07:41 -0500
Detailed status
* bin/*: add special actions if --detail is specified; basically,
print all relevant information on stdout without formatting
* screen-profiles-status: add support for --detail, loop through
all status scripts with --detail specified
* screen-profiles-status-detail: wrapper using sensible-pager
* screen-profiles-status-detail.1: documentation added
-- Dustin Kirkland <kirkland@ubuntu.com> Mon, 27 Apr 2009 21:10:40 -0500
screen-profiles (1.50-0ubuntu1) jaunty; urgency=low

1
debian/install vendored
View file

@ -12,6 +12,7 @@ screen usr/bin
select-screen-profile usr/bin
screen-profiles usr/bin
screen-profiles-status usr/bin
screen-profiles-status-detail usr/bin
screen-launcher-install usr/share/screen-profiles
screen-launcher-uninstall usr/share/screen-profiles
motd+shell usr/bin

2
debian/rules vendored
View file

@ -57,7 +57,7 @@ binary-indep: build install
dh_testdir -i
dh_testroot -i
dh_installdocs -X.bzr -i
dh_installman -i screen-launcher.1 screen-profiles.1 select-screen-profile.1 motd+shell.1 screen-profiles-export.1 screen-profiles-status.1
dh_installman -i screen-launcher.1 screen-profiles.1 select-screen-profile.1 motd+shell.1 screen-profiles-export.1 screen-profiles-status.1 screen-profiles-status-detail.1
dh_installchangelogs -i
dh_installdebconf -i
dh_compress -i

View file

@ -45,3 +45,4 @@ bindkey -k k9 screen -t help 0 screen-profiles # F9 | Configuration
# F10 | 'toolbar' in gnome-terminal
# F11 | 'fullscreen' in gnome-terminal
bindkey -k F2 lockscreen # F12 | Lock this terminal
bind $ screen -t status 0 screen-profiles-status-detail # ctrl-a $ | show detailed status

View file

@ -45,6 +45,18 @@ case "$P" in
arch|battery|ec2-cost|hostname|network-down|network-up|processes|users|whoami|wifi-quality)
grep -qs -m1 "^$P=1$" "$HOME/.screen-profiles/status" || exit 0
;;
--detail)
for i in `ls "$DIR"`; do
[ "$i" = "menu" ] && continue
echo
echo " ______________________________________________________________________"
echo "/ * $i:"
out=`"$DIR"/$i --detail`
echo "$out" | sed "s/^/| /g"
echo "\\______________________________________________________________________"
done
exit 0
;;
*)
exit 1
;;

View file

@ -0,0 +1,15 @@
.TH screen-profiles-status-detail 1 "27 Apr 2009" screen-profiles "screen-profiles"
.SH NAME
screen\-profiles\-status\-detail \- Wrapper that uses a sensible pager
.SH DESCRIPTION
\fBscreen\-profiles\-status\-detail\fP is a simple script that uses a sensible pager for displaying the detailed status of all screen\-profiles status scripts.
.TP
\fIhttp://launchpad.net/screen-profiles\fP
.PD
.SH AUTHOR
This manpage and the utility was written by Dustin Kirkland <kirkland@canonical.com> for Ubuntu systems (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 published by the Free Software Foundation.
On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL.