From fc5b78ebafa8865c8b1c9ae9e977fe0d1400ccf9 Mon Sep 17 00:00:00 2001 From: zorun Date: Mon, 24 Oct 2011 17:39:18 +0200 Subject: [PATCH 1/4] Fix battery handling with the /sys interface --- usr/lib/byobu/battery | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/usr/lib/byobu/battery b/usr/lib/byobu/battery index ee930d71..d69a45a9 100755 --- a/usr/lib/byobu/battery +++ b/usr/lib/byobu/battery @@ -26,10 +26,12 @@ __battery_detail() { cat "$bat/info" cat "$bat/state" done + # FIXME: do the same thing with the /sys interface } __battery() { - local bat line present sign state percent full rem color bcolor + local bat has_bat line present sign state percent full rem color bcolor + has_bat="" for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do present=""; full=""; rem=""; state="" case "$bat" in @@ -40,7 +42,7 @@ __battery() { full="$POWER_SUPPLY_CHARGE_FULL" rem="$POWER_SUPPLY_CHARGE_NOW" state="$POWER_SUPPLY_STATUS" - [ -n "$present" ] && [ -n "$full" ] && [ -n "$rem" ] && [ "$state" ] && break + [ "$present" = "1" ] && [ -n "$full" ] && [ -n "$rem" ] && [ -n "$state" ] && has_bat=1 && break fi ;; /proc/*) @@ -64,28 +66,31 @@ __battery() { esac [ -n "$rem" -a -n "$state" ] && break done < "$bat/state" + [ -n "$full" ] && [ -n "$rem" ] && [ -n "$state" ] && has_bat=1 && break ;; esac done - percent=$(((100*$rem)/$full)) - if [ "$percent" -lt 33 ]; then - color="R k" - bcolor="b R k" - elif [ "$percent" -lt 67 ]; then - color="Y k" - bcolor="b Y k" - else - color="G k" - bcolor="b G k" + if [ "$has_bat" = "1" ]; then + percent=$(((100*$rem)/$full)) + if [ "$percent" -lt 33 ]; then + color="R k" + bcolor="b R k" + elif [ "$percent" -lt 67 ]; then + color="Y k" + bcolor="b Y k" + else + color="G k" + bcolor="b G k" + fi + percent="$percent$PCT" + case $state in + charging|Charging|Unknown) sign="+" ;; + discharging|Discharging) sign="-" ;; + charged|Unknown|Full) sign="="; percent="" ;; + *) sign="$state" ;; + esac + color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- fi - percent="$percent$PCT" - case $state in - charging|Charging|Unknown) sign="+" ;; - discharging|Discharging) sign="-" ;; - charged|Unknown) sign="="; percent="" ;; - *) sign="$state" ;; - esac - color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- } # vi: syntax=sh ts=4 noexpandtab From 837f232e0cd1c37ced1f2a68f48189da56547ec6 Mon Sep 17 00:00:00 2001 From: zorun Date: Mon, 24 Oct 2011 18:12:07 +0200 Subject: [PATCH 2/4] Fix loading of screen-keys.conf for tmux --- usr/share/byobu/profiles/tmux | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr/share/byobu/profiles/tmux b/usr/share/byobu/profiles/tmux index 97aec165..8e878100 100644 --- a/usr/share/byobu/profiles/tmux +++ b/usr/share/byobu/profiles/tmux @@ -27,6 +27,8 @@ set -s escape-time 0 # Change to Screen's ctrl-a escape sequence source /usr/share/doc/tmux/examples/screen-keys.conf +# On Archlinux, this file is not under the same directory +source /usr/share/tmux/screen-keys.conf # Byobu's Keybindings bind-key -n F1 new-window -k -t config byobu-config From eca0f973b4ae67895e5e1be61ddc0eb0479ee943 Mon Sep 17 00:00:00 2001 From: zorun Date: Mon, 24 Oct 2011 22:49:06 +0200 Subject: [PATCH 3/4] Update documentation in statusrc, and add undocumented NETWORK_UNITS option --- usr/share/byobu/status/statusrc | 40 +++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/usr/share/byobu/status/statusrc b/usr/share/byobu/status/statusrc index e881a3d9..3e96dc7b 100644 --- a/usr/share/byobu/status/statusrc +++ b/usr/share/byobu/status/statusrc @@ -22,13 +22,39 @@ # Configurations that you can override; if you leave these commented out, # Byobu will try to auto-detect them. -#LOGO="\o/" -#MONITORED_DISK=/ -#DISK_IO_THRESHOLD=50 -#MONITORED_INTERFACE=eth0 -#NETWORK_THRESHOLD=20 -#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature -#TEMP=F + +# This should be auto-detected for most distro, but setting it here will save +# some call to lsb_release and the like. #DISTRO=Ubuntu + +# Default: depends on the distro (which is either auto-detected, either set +# via $DISTRO) +#LOGO="\o/" + +# Default: / +#MONITORED_DISK=/ + +# Minimum disk throughput that triggers the notification (in kB/s) +# Default: 50 +#DISK_IO_THRESHOLD=50 + +# Default: eth0 +#MONITORED_INTERFACE=eth0 + +# Unit used for network throughput (either bits per second or bytes per second) +# Default: bits +#NETWORK_UNITS=bytes + +# Minimum network throughput that triggers the notification (in kbit/s) +# Default: 20 +#NETWORK_THRESHOLD=20 + +# You can add an additional source of temperature here +#MONITORED_TEMP=/proc/acpi/thermal_zone/THM0/temperature + +# Default: C +#TEMP=F + #SERVICES="eucalyptus-nc|NC eucalyptus-cloud|CLC eucalyptus-walrus eucalyptus-cc|CC eucalyptus-sc|SC" + #FAN=$(find /sys -type f -name fan1_input | head -n1) From 24356426b83b1f8b23cfc96de4834d542930c5bb Mon Sep 17 00:00:00 2001 From: zorun Date: Tue, 25 Oct 2011 15:57:12 +0200 Subject: [PATCH 4/4] usr/lib/byobu/.shutil: fix incorrect use of 5165 in get_now, LP: #881437 --- usr/lib/byobu/.shutil | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index e98f7f54..a7c04478 100755 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -269,9 +269,7 @@ status_freq() { } get_now() { - if [ -n "${BASH_VERSION}" ] && [ -n "${SECONDS}" ]; then - _RET=${SECONDS} - elif [ -r /proc/uptime ]; then + if [ -r /proc/uptime ]; then # return the integer part of the first item in /proc/uptime local s c read s c < /proc/uptime