diff --git a/bin/battery b/bin/battery index c26aafb4..b8fbdca3 100755 --- a/bin/battery +++ b/bin/battery @@ -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") diff --git a/bin/temp_c b/bin/cpu_temp similarity index 71% rename from bin/temp_c rename to bin/cpu_temp index 0e0d2899..f0dda885 100755 --- a/bin/temp_c +++ b/bin/cpu_temp @@ -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 @@ -30,8 +30,14 @@ if [ "$1" = "--detail" ]; then exit 0 fi -for i in $MONITORED_TEMP `ls $DIR/*/temperature 2>/dev/null`; do - t=$(sed -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i") - printf "$(color b k Y)%s$(color -)$(color k Y)\260C$(color -) " "$t" +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") + unit="C" + fi + printf "$(color b k Y)%s$(color -)$(color k Y)\260%s$(color -) " "$t" "$unit" break done diff --git a/bin/custom b/bin/custom index 6230fd01..b9fc8742 100755 --- a/bin/custom +++ b/bin/custom @@ -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}') diff --git a/bin/fan_speed b/bin/fan_speed index 7be2c826..cac17357 100755 --- a/bin/fan_speed +++ b/bin/fan_speed @@ -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 diff --git a/bin/temp_f b/bin/temp_f deleted file mode 100755 index f2737255..00000000 --- a/bin/temp_f +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -e -# -# temp_f: cpu temperature in farenheit -# Copyright (C) 2008 Canonical Ltd. -# -# Authors: Dustin Kirkland - -# 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 . -# - -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 diff --git a/byobu-config b/byobu-config index 7595c8f5..8e7314ee 100755 --- a/byobu-config +++ b/byobu-config @@ -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 diff --git a/byobu.1 b/byobu.1 index 2b028064..8063eb7d 100644 --- a/byobu.1 +++ b/byobu.1 @@ -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, '!!' diff --git a/debian/changelog b/debian/changelog index 3a88002e..c4b3d4b1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Thu, 07 Jan 2010 21:53:14 -0600 diff --git a/profiles/common b/profiles/common index 0b10e05f..dc2c1fed 100644 --- a/profiles/common +++ b/profiles/common @@ -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 diff --git a/rpm/byobu.spec b/rpm/byobu.spec index 6cedf756..8ef99695 100644 --- a/rpm/byobu.spec +++ b/rpm/byobu.spec @@ -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 diff --git a/statusrc b/statusrc index 40178790..10110af5 100644 --- a/statusrc +++ b/statusrc @@ -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