* bin/battery, bin/custom, bin/fan_speed, bin/temp, bin/temp_f: don't

use ls programatically in for-loops, LP: #452405
* bin/cpu_temp, bin/temp_f, bin/temp_c, byobu-config, byobu.1,
  profiles/common, rpm/byobu.spec, statusrc: merge temp_f and temp_c
  into a single cpu_temp script
This commit is contained in:
Dustin Kirkland 2010-01-11 22:40:01 -06:00
commit 36e371c8bf
11 changed files with 32 additions and 55 deletions

View file

@ -30,21 +30,21 @@ search () {
if [ "$1" = "--detail" ]; then
for bat in $(ls /proc/acpi/battery); do
cat "/proc/acpi/battery/$bat/info"
cat "/proc/acpi/battery/$bat/state"
for bat in /proc/acpi/battery/*; do
cat "$bat/info"
cat "$bat/state"
done
exit 0
fi
for bat in $(ls /proc/acpi/battery); do
for bat in /proc/acpi/battery/*; do
# make sure that this battery is present
infofile=$(cat "/proc/acpi/battery/$bat/info")
infofile=$(cat "$bat/info")
present=$(search "$infofile" "present: *\(.*\)")
[ "${present}" = "no" ] && continue
# obtain full and remaining battery values
statefile=$(cat "/proc/acpi/battery/$bat/state")
statefile=$(cat "$bat/state")
full=$(search "$infofile" "last full capacity: *\(.*\) m[AW]h")
rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h")

View file

@ -1,6 +1,6 @@
#!/bin/sh -e
#
# temp_c: cpu temperature in celsius
# cpu_temp: cpu temperature
# Copyright (C) 2008 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>
@ -30,8 +30,14 @@ if [ "$1" = "--detail" ]; then
exit 0
fi
for i in $MONITORED_TEMP `ls $DIR/*/temperature 2>/dev/null`; do
for i in $MONITORED_TEMP $DIR/*/temperature; do
if [ "$TEMP" = "F" ]; then
t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i" | awk '{printf "%.0f", $1 *9/5 + 32}')
unit="F"
else
t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i")
printf "$(color b k Y)%s$(color -)$(color k Y)\260C$(color -) " "$t"
unit="C"
fi
printf "$(color b k Y)%s$(color -)$(color k Y)\260%s$(color -) " "$t" "$unit"
break
done

View file

@ -27,7 +27,7 @@ NOW=$(date +%s)
CACHE="$DIR/$PKG.custom"
# Loop over custom scripts
for i in $(ls "$HOME/.$PKG/bin/"[0-9]*_* 2>/dev/null); do
for i in "$HOME"/.$PKG/bin/[0-9]*_*; do
[ -x "$i" ] || continue
script=$(basename "$i")
freq=$(echo "$script" | awk -F_ '{print $1}')

View file

@ -23,7 +23,7 @@ color 2>/dev/null || color() { true; }
DIR="/sys/class/hwmon"
if [ "$1" = "--detail" ]; then
for i in `ls $DIR 2>/dev/null`; do
for i in $DIR/*; do
echo "$i:"
cat "$DIR/$i"/* 2>/dev/null
done

View file

@ -1,33 +0,0 @@
#!/bin/sh -e
#
# temp_f: cpu temperature in farenheit
# Copyright (C) 2008 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
PKG="byobu"
color 2>/dev/null || color() { true; }
DIR="/proc/acpi/thermal_zone"
if [ "$1" = "--detail" ]; then
exit 0
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 "$(color b k Y)%s$(color -)$(color k Y)\260F$(color -) " "$t"
break
done

View file

@ -279,6 +279,7 @@ def readstatus():
status["battery"]=0
status["cpu_count"]=1
status["cpu_freq"]=1
status["cpu_temp"]=0
status["custom"]=1
status["date"]=1
status["disk"]=0
@ -297,8 +298,6 @@ def readstatus():
status["reboot_required"]=1
status["release"]=1
status["services"]=1
status["temp_c"]=0
status["temp_f"]=0
status["time"]=1
status["users"]=0
status["updates_available"]=1

View file

@ -21,6 +21,8 @@ byobu \- wrapper script for seeding a user's byobu configuration and launching s
\fBcpu_freq\fP \- the current frequency of the cpu in GHz; displayed in the lower bar toward the right in white text on a light blue background
\fBcpu_temp\fP \- the cpu temperature in Celsius (default) or Fahrenheit, configure TEMP=F or TEMP=C in \fI$HOME/.byobu/statusrc\fP; displayed in the lower bar toward the right in yellow text on a black background; you may override the detected cpu temperature device by setting MONITORED_TEMP=/proc/acpi/whatever in \fI$HOME/.byobu/statusrc\fP
\fBcustom\fP \- user defined custom scripts; must be executable programs of any kind in \fI$HOME/.byobu/bin\fP; must be named N_NAME, where N is the frequency in seconds to refresh the status indicator, and NAME is the name of the script; N should not be less than 5 seconds; script should echo a small amount of text to standard out, standard error is discared; the indicator will be displayed in the lower panel, in inverted colors to your current background/foreground scheme, unless you manually specify the colors in your script's output; BEWARE, cpu-intensive custom scripts may impact your overall system performance and could upset your system administrator!
\fBdate\fP \- the system date in YYYY-MM-DD formate; displayed in the lower on the far right in the default text color on the default background
@ -55,8 +57,6 @@ byobu \- wrapper script for seeding a user's byobu configuration and launching s
\fBrelease\fP \- distribution and version information about the release running on the current system as reported by \fBlsb_release(1)\fP or \fI/etc/issue\fP; displayed in the lower bar in bold black text toward the left on a grey background; you may override the detected release with DISTRO=Whatever in \fI$HOME/.byobu/statusrc\fP
\fBtemp_c\fP, \fBtemp_f\fP \- the cpu temperature in Celsius or Fahrenheit; displayed in the lower bar toward the right in yellow text on a black background; you may override the detected cpu temperature device by setting MONITORED_TEMP=/proc/acpi/whatever in \fI$HOME/.byobu/statusrc\fP
\fBtime\fP \- the system time in HH:MM:SS format; displayed in the lower bar on the far right in the default text and default background colors
\fBupdates_available\fP \- the number of updates available on the system; displayed in the lower bar toward the right in white text on a red background with a trailing '!' sign; if any updates are marked 'security updates', then there will be a total of two trailing exclamation points, '!!'

6
debian/changelog vendored
View file

@ -12,6 +12,12 @@ byobu (2.46) unreleased; urgency=low
* byobu: deprecate code that prevented nested byobu sessions; this is
is actually quite useful, although you should choose different
escape sequences for each nested host, LP: #403988
* bin/battery, bin/custom, bin/fan_speed, bin/temp, bin/temp_f: don't
use ls programatically in for-loops, LP: #452405
* bin/cpu_temp, bin/temp_f, bin/temp_c, byobu-config, byobu.1,
profiles/common, rpm/byobu.spec, statusrc: merge temp_f and temp_c
into a single cpu_temp script
-- Dustin Kirkland <kirkland@ubuntu.com> Thu, 07 Jan 2010 21:53:14 -0600

View file

@ -62,8 +62,8 @@ backtick 121 86113 86113 byobu-status time
backtick 122 127 127 byobu-status ip_address
backtick 123 13 13 byobu-status disk
backtick 124 86117 86117 true
backtick 125 19 19 byobu-status temp_c
backtick 126 19 19 byobu-status temp_f
backtick 125 19 19 byobu-status cpu_temp
backtick 126 86117 86117 true
backtick 127 5 5 byobu-status mail
backtick 128 23 23 byobu-status fan_speed
backtick 129 67 67 byobu-status apport

View file

@ -104,8 +104,7 @@ rm -rf $RPM_BUILD_ROOT
/usr/lib/byobu/reboot_required
/usr/lib/byobu/release
/usr/lib/byobu/services
/usr/lib/byobu/temp_c
/usr/lib/byobu/temp_f
/usr/lib/byobu/temp
/usr/lib/byobu/time
/usr/lib/byobu/updates_available
/usr/lib/byobu/uptime

View file

@ -25,6 +25,7 @@ arch=0
battery=0
cpu_count=1
cpu_freq=1
cpu_temp=0
custom=1
date=1
disk=0
@ -43,8 +44,6 @@ processes=0
reboot_required=1
release=1
services=1
temp_c=0
temp_f=0
time=1
users=0
updates_available=1
@ -58,6 +57,7 @@ wifi_quality=0
#MONITORED_DISK=/
#MONITORED_INTERFACE=eth0
#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature
#TEMP=F
#DISTRO=Ubuntu
#SERVICES="eucalyptus-nc|NC eucalyptus-cloud|CLC eucalyptus-walrus eucalyptus-cc|CC eucalyptus-sc|SC"
# END_CUT_HERE