From 72485d5dfa2026fe1c18c56f38933036aea97c37 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:08:03 +0800 Subject: [PATCH 01/19] * usr/lib/byobu/logo: - Add logo for OpenWrt --- debian/changelog | 5 +++++ usr/lib/byobu/logo | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index 133de16d..a78a8b15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ byobu (5.128) unreleased; urgency=medium + [ Dustin Kirkland ] * usr/bin/ctail: - Quotes are needed around "$@" to keep parameters from splitting on spaces. @@ -18,6 +19,10 @@ byobu (5.128) unreleased; urgency=medium All colors in command prompt should be escaped with [ ] - https://github.com/dustinkirkland/byobu/pull/30 + [ Jeffery To ] + * usr/lib/byobu/logo: + - Add logo for OpenWrt + -- Dustin Kirkland Sun, 12 Aug 2018 11:37:11 -0500 byobu (5.127-0ubuntu1) cosmic; urgency=medium diff --git a/usr/lib/byobu/logo b/usr/lib/byobu/logo index 09e67b14..0d546c1f 100755 --- a/usr/lib/byobu/logo +++ b/usr/lib/byobu/logo @@ -111,6 +111,10 @@ __logo() { logo=" lm " $MARKUP && printf "$(color g w)$logo$(color -)$(color g w)$(color -) " || printf "$logo" ;; + *openwrt*) + logo="OWrt" + $MARKUP && printf "$(color b colour66 W)%s$(color -)" "$logo" || printf "$logo" + ;; *red*hat*|*rhel*) logo=" RH " $MARKUP && printf "$(color R k)%s$(color -)" "$logo" || printf "$logo" From b6fb57f94f859e748ee26fcccca9535dedf6dc88 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:09:25 +0800 Subject: [PATCH 02/19] * usr/bin/byobu-disable-prompt.in, usr/bin/byobu-janitor.in: - Test if $HOME/.bashrc exists before modifying it (and potentially creating it) --- debian/changelog | 4 ++++ usr/bin/byobu-disable-prompt.in | 2 ++ usr/bin/byobu-janitor.in | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a78a8b15..3daff1c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,10 @@ byobu (5.128) unreleased; urgency=medium - https://github.com/dustinkirkland/byobu/pull/30 [ Jeffery To ] + * usr/bin/byobu-disable-prompt.in, + usr/bin/byobu-janitor.in: + - Test if $HOME/.bashrc exists before modifying it (and potentially + creating it) * usr/lib/byobu/logo: - Add logo for OpenWrt diff --git a/usr/bin/byobu-disable-prompt.in b/usr/bin/byobu-disable-prompt.in index 59b5e0e7..2e3946db 100755 --- a/usr/bin/byobu-disable-prompt.in +++ b/usr/bin/byobu-disable-prompt.in @@ -22,6 +22,8 @@ PKG="byobu" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="@prefix@" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" +[ -w "$HOME/.bashrc" ] || exit 1 + $BYOBU_SED_INLINE -e "/#byobu-prompt#$/d" "$HOME/.bashrc" if [ "$1" != "--no-reload" ]; then diff --git a/usr/bin/byobu-janitor.in b/usr/bin/byobu-janitor.in index 38ddebe8..071b82ca 100755 --- a/usr/bin/byobu-janitor.in +++ b/usr/bin/byobu-janitor.in @@ -112,7 +112,8 @@ killall -u $USER byobu-statusd >/dev/null 2>&1 || true rm -f "$FLAG" "/var/run/screen/S-$USER/$PKG.reload-required" # Affects: Upgrades from <= byobu 5.50, install byobu prompt if using stock bashrc -if ! (grep -qs "#byobu-prompt#$" "$HOME/.bashrc") && ! [ -e "$BYOBU_CONFIG_DIR/prompt" ]; then +if [ -r /etc/skel/.bashrc ] && [ -r "$HOME/.bashrc" ] && [ -w "$HOME/.bashrc" ] && \ + ! (grep -qs "#byobu-prompt#$" "$HOME/.bashrc") && ! [ -e "$BYOBU_CONFIG_DIR/prompt" ]; then if eval $BYOBU_TEST diff >/dev/null 2>&1; then if diff /etc/skel/.bashrc "$HOME/.bashrc" >/dev/null 2>&1; then printf "[ -r $BYOBU_CONFIG_DIR/prompt ] && . $BYOBU_CONFIG_DIR/prompt #byobu-prompt#\n" >> "$HOME/.bashrc" From 213e22fb7133f77032f16c297f2920f04e9e87a9 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:10:22 +0800 Subject: [PATCH 03/19] * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will not trigger a new window; the given command is executed in the current window instead. --- debian/changelog | 5 +++++ usr/share/byobu/keybindings/f-keys.tmux | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3daff1c8..57c8ca65 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,11 @@ byobu (5.128) unreleased; urgency=medium creating it) * usr/lib/byobu/logo: - Add logo for OpenWrt + * usr/share/byobu/keybindings/f-keys.tmux: + - Remove -k for new-window. In older versions of tmux, -k without + -t had no effect. In tmux 2.8, -k without -t will + not trigger a new window; the given command is executed in the + current window instead. -- Dustin Kirkland Sun, 12 Aug 2018 11:37:11 -0500 diff --git a/usr/share/byobu/keybindings/f-keys.tmux b/usr/share/byobu/keybindings/f-keys.tmux index 2e0eca04..2617e31c 100644 --- a/usr/share/byobu/keybindings/f-keys.tmux +++ b/usr/share/byobu/keybindings/f-keys.tmux @@ -26,8 +26,8 @@ source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux.disable # Byobu's Keybindings # Documented in: $BYOBU_PREFIX/share/doc/byobu/help.tmux.txt -bind-key -n F1 new-window -k -n config byobu-config -bind-key -n S-F1 new-window -k -n help "sh -c '$BYOBU_PAGER $BYOBU_PREFIX/share/doc/byobu/help.tmux.txt'" +bind-key -n F1 new-window -n config byobu-config +bind-key -n S-F1 new-window -n help "sh -c '$BYOBU_PAGER $BYOBU_PREFIX/share/doc/byobu/help.tmux.txt'" bind-key -n F2 new-window -c "#{pane_current_path}" \; rename-window "-" bind-key -n C-F2 display-panes \; split-window -h -c "#{pane_current_path}" bind-key -n S-F2 display-panes \; split-window -v -c "#{pane_current_path}" @@ -54,7 +54,7 @@ bind-key -n M-S-Left resize-pane -L bind-key -n M-S-Right resize-pane -R bind-key -n F5 source $BYOBU_PREFIX/share/byobu/profiles/tmuxrc bind-key -n M-F5 run-shell '$BYOBU_PREFIX/lib/byobu/include/toggle-utf8' \; source $BYOBU_PREFIX/share/byobu/profiles/tmuxrc -bind-key -n S-F5 new-window -k "$BYOBU_PREFIX/lib/byobu/include/cycle-status" \; source $BYOBU_PREFIX/share/byobu/profiles/tmuxrc +bind-key -n S-F5 new-window "$BYOBU_PREFIX/lib/byobu/include/cycle-status" \; source $BYOBU_PREFIX/share/byobu/profiles/tmuxrc bind-key -n C-F5 send-keys ". $BYOBU_PREFIX/bin/byobu-reconnect-sockets" \; send-keys Enter bind-key -n C-S-F5 new-window -d "byobu-select-profile -r" bind-key -n F6 detach @@ -68,9 +68,9 @@ bind-key -n M-PPage copy-mode \; send-keys PPage bind-key -n F8 command-prompt -p "(rename-window) " "rename-window '%%'" bind-key -n C-F8 command-prompt -p "(rename-session) " "rename-session '%%'" bind-key -n S-F8 next-layout -bind-key -n M-S-F8 new-window -k "byobu-layout restore; clear; $SHELL" +bind-key -n M-S-F8 new-window "byobu-layout restore; clear; $SHELL" bind-key -n C-S-F8 command-prompt -p "Save byobu layout as:" "run-shell \"byobu-layout save '%%'\"" -bind-key -n F9 new-window -k -n config byobu-config +bind-key -n F9 new-window -n config byobu-config bind-key -n S-F9 command-prompt -p "Send command to all panes:" "run-shell \"$BYOBU_PREFIX/lib/byobu/include/tmux-send-command-to-all-panes '%%'\"" bind-key -n C-F9 command-prompt -p "Send command to all windows:" "run-shell \"$BYOBU_PREFIX/lib/byobu/include/tmux-send-command-to-all-windows '%%'\"" bind-key -n M-F9 display-panes \; setw synchronize-panes From 479754946c597baadd0f9dc6132d2183af668376 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:10:55 +0800 Subject: [PATCH 04/19] * usr/share/byobu/keybindings/f-keys.tmux: - Rename the new window created after adding a new session --- debian/changelog | 1 + usr/share/byobu/keybindings/f-keys.tmux | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 57c8ca65..d55a47c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,7 @@ byobu (5.128) unreleased; urgency=medium -t had no effect. In tmux 2.8, -k without -t will not trigger a new window; the given command is executed in the current window instead. + - Rename the new window created after adding a new session -- Dustin Kirkland Sun, 12 Aug 2018 11:37:11 -0500 diff --git a/usr/share/byobu/keybindings/f-keys.tmux b/usr/share/byobu/keybindings/f-keys.tmux index 2617e31c..eabacf87 100644 --- a/usr/share/byobu/keybindings/f-keys.tmux +++ b/usr/share/byobu/keybindings/f-keys.tmux @@ -31,7 +31,7 @@ bind-key -n S-F1 new-window -n help "sh -c '$BYOBU_PAGER $BYOBU_PREFIX/share/doc bind-key -n F2 new-window -c "#{pane_current_path}" \; rename-window "-" bind-key -n C-F2 display-panes \; split-window -h -c "#{pane_current_path}" bind-key -n S-F2 display-panes \; split-window -v -c "#{pane_current_path}" -bind-key -n C-S-F2 new-session +bind-key -n C-S-F2 new-session \; rename-window "-" bind-key -n F3 previous-window bind-key -n F4 next-window bind-key -n M-Left previous-window From 558da18bf37cd98620e4359b9dd78a887c651202 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:12:21 +0800 Subject: [PATCH 05/19] * usr/lib/byobu/disk_io: - Ensure the detected mount point device exists --- debian/changelog | 2 ++ usr/lib/byobu/disk_io | 1 + 2 files changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index d55a47c7..be77d117 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ byobu (5.128) unreleased; urgency=medium usr/bin/byobu-janitor.in: - Test if $HOME/.bashrc exists before modifying it (and potentially creating it) + * usr/lib/byobu/disk_io: + - Ensure the detected mount point device exists * usr/lib/byobu/logo: - Add logo for OpenWrt * usr/share/byobu/keybindings/f-keys.tmux: diff --git a/usr/lib/byobu/disk_io b/usr/lib/byobu/disk_io index d7bc2301..44db71ad 100755 --- a/usr/lib/byobu/disk_io +++ b/usr/lib/byobu/disk_io @@ -50,6 +50,7 @@ __disk_io() { /dev/*) part="${mount_point}";; *) part=$(awk '$2 == mp { print $1 ; exit(0); }' "mp=$mount_point" /etc/mtab);; esac + [ -e "$part" ] || return getdisk "$part" local disk=${_RET} local t2=$(date +%s) t1= From 7cd5821d801e79f5b122864617cf9f973dee4354 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:12:44 +0800 Subject: [PATCH 06/19] * usr/lib/byobu/hostname: - Read from /proc/sys/kernel/hostname if the hostname command is not available --- debian/changelog | 3 +++ usr/lib/byobu/hostname | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index be77d117..624744f1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,9 @@ byobu (5.128) unreleased; urgency=medium creating it) * usr/lib/byobu/disk_io: - Ensure the detected mount point device exists + * usr/lib/byobu/hostname: + - Read from /proc/sys/kernel/hostname if the hostname command is not + available * usr/lib/byobu/logo: - Add logo for OpenWrt * usr/share/byobu/keybindings/f-keys.tmux: diff --git a/usr/lib/byobu/hostname b/usr/lib/byobu/hostname index 4e6ba317..348aed76 100755 --- a/usr/lib/byobu/hostname +++ b/usr/lib/byobu/hostname @@ -20,12 +20,16 @@ # along with this program. If not, see . __hostname_detail() { - hostname -f + hostname -f 2>/dev/null } __hostname() { local h= - h=$(hostname -s 2>/dev/null || hostname) + if eval $BYOBU_TEST hostname >/dev/null 2>&1; then + h=$(hostname -s 2>/dev/null || hostname) + elif [ -r /proc/sys/kernel/hostname ]; then + read h < /proc/sys/kernel/hostname + fi if metadata_available; then local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/hostname" # Background a retrieval of our public hostname From 9eaa9598d24d0a10f546c6dbd5ff652a44510676 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:13:47 +0800 Subject: [PATCH 07/19] * usr/lib/byobu/processes: - Handle stderr for ps, e.g. unsupported options - Remove unnecessary awk call; wc -l only outputs one value --- debian/changelog | 3 +++ usr/lib/byobu/processes | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 624744f1..6f8f6984 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,9 @@ byobu (5.128) unreleased; urgency=medium available * usr/lib/byobu/logo: - Add logo for OpenWrt + * usr/lib/byobu/processes: + - Handle stderr for ps, e.g. unsupported options + - Remove unnecessary awk call; wc -l only outputs one value * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/processes b/usr/lib/byobu/processes index 6e5ae29f..7049691e 100755 --- a/usr/lib/byobu/processes +++ b/usr/lib/byobu/processes @@ -20,15 +20,15 @@ # along with this program. If not, see . __processes_detail() { - ps -ej + ps -ej 2>/dev/null } __processes() { local count= if [ -r /proc ]; then - count=$(ls -d /proc/[0-9]* 2>/dev/null| wc -l) + count=$(ls -d /proc/[0-9]* 2>/dev/null | wc -l) else - count=$(ps -ef | wc -l | awk '{print $1}') + count=$(ps -ef | wc -l) fi [ -n "$count" ] || return color b y w; printf "%s" "$count"; color -; color y w; printf "&"; color -- From 9ff72f478357dd87a4a9468f296d0ee9f74735ad Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:14:28 +0800 Subject: [PATCH 08/19] * usr/lib/byobu/release: - Fix typo --- debian/changelog | 2 ++ usr/lib/byobu/release | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 6f8f6984..7c1d1bcc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -34,6 +34,8 @@ byobu (5.128) unreleased; urgency=medium * usr/lib/byobu/processes: - Handle stderr for ps, e.g. unsupported options - Remove unnecessary awk call; wc -l only outputs one value + * usr/lib/byobu/release: + - Fix typo * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/release b/usr/lib/byobu/release index 3328a1a4..382dbf81 100755 --- a/usr/lib/byobu/release +++ b/usr/lib/byobu/release @@ -30,7 +30,7 @@ __release() { true elif [ -r "/etc/os-release" ]; then # lsb_release is *really* slow; try to use /etc/os-release - release=$(. /etc/os-release && echo "$VERSION_ID") + RELEASE=$(. /etc/os-release && echo "$VERSION_ID") elif [ -r "/etc/issue" ]; then # next try /etc/issue first local issue From 0875bfed2dd7395459111ef8606b207e36bab7eb Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:15:02 +0800 Subject: [PATCH 09/19] * usr/lib/byobu/services: - Fix reading services from $BYOBU_CONFIG_DIR/statusrc --- debian/changelog | 2 ++ usr/lib/byobu/services | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 7c1d1bcc..4af9e84a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,8 @@ byobu (5.128) unreleased; urgency=medium - Remove unnecessary awk call; wc -l only outputs one value * usr/lib/byobu/release: - Fix typo + * usr/lib/byobu/services: + - Fix reading services from $BYOBU_CONFIG_DIR/statusrc * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/services b/usr/lib/byobu/services index 6bdfb851..b52e95c2 100755 --- a/usr/lib/byobu/services +++ b/usr/lib/byobu/services @@ -43,7 +43,7 @@ service_running() { } __services() { - local services= + local services="$SERVICES" # Users can define a list of services to monitor in $BYOBU_CONFIG_DIR/status if [ -z "$services" ]; then if [ -f "/etc/eucalyptus/eucalyptus.conf" ]; then From 6e62ff2ffccf508288df25e02d0138fb37ab025a Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:15:34 +0800 Subject: [PATCH 10/19] * usr/lib/byobu/updates_available: - Add support for opkg (OpenWrt) --- debian/changelog | 2 ++ usr/lib/byobu/updates_available | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4af9e84a..31b1104f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -38,6 +38,8 @@ byobu (5.128) unreleased; urgency=medium - Fix typo * usr/lib/byobu/services: - Fix reading services from $BYOBU_CONFIG_DIR/statusrc + * usr/lib/byobu/updates_available: + - Add support for opkg (OpenWrt) * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/updates_available b/usr/lib/byobu/updates_available index e8b5482b..691ccc88 100755 --- a/usr/lib/byobu/updates_available +++ b/usr/lib/byobu/updates_available @@ -67,9 +67,16 @@ ___update_cache() { elif eval $BYOBU_TEST pacman >/dev/null; then # If pacman (Archlinux) exists, use it LC_ALL=C flock -xn "$flock" pacman -Sup | grep -vc "^\(::\| \)" >$mycache 2>/dev/null & + elif eval $BYOBU_TEST opkg >/dev/null; then + # If opkg (OpenWrt) exists, use it, also background if flock exists + if eval $BYOBU_TEST flock >/dev/null; then + flock -xn "$flock" opkg list-upgradable | wc -l >$mycache 2>/dev/null & + else + opkg list-upgradable | wc -l >$mycache & + fi elif eval $BYOBU_TEST brew >/dev/null; then # If homebrew (Mac OSX) exists, use it, also background if flock exists - if eval $BYOBU_TEST flock; then + if eval $BYOBU_TEST flock >/dev/null; then flock -xn "$flock" brew outdated | wc -l >$mycache 2>/dev/null & else brew outdated | wc -l >$mycache & @@ -106,6 +113,18 @@ ___update_needed() { [ "$db" -nt "$mycache" ] && return 0 done return 1 + elif eval $BYOBU_TEST opkg >/dev/null; then + # OpenWrt + [ ! -e /var/lock/opkg.lock ] || return 1 + if [ -d /var/opkg-lists ]; then + [ /var/opkg-lists -nt "$mycache" ] + return $? + else + local u s + read u s < "$mycache" + [ "$u" -gt 0 ] + return $? + fi elif eval $BYOBU_TEST brew >/dev/null; then # Mac OSX # check if any new versions have been installed since From e537a69098545122d262fa584d11f11ed39588a7 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:15:56 +0800 Subject: [PATCH 11/19] * usr/lib/byobu/whoami: - Use id if the whoami command is not available - Read from /etc/passwd if the getent command is not available --- debian/changelog | 3 +++ usr/lib/byobu/whoami | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 31b1104f..26682ee4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,9 @@ byobu (5.128) unreleased; urgency=medium - Fix reading services from $BYOBU_CONFIG_DIR/statusrc * usr/lib/byobu/updates_available: - Add support for opkg (OpenWrt) + * usr/lib/byobu/whoami: + - Use id if the whoami command is not available + - Read from /etc/passwd if the getent command is not available * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/whoami b/usr/lib/byobu/whoami index 93a6702f..f3c4f26b 100755 --- a/usr/lib/byobu/whoami +++ b/usr/lib/byobu/whoami @@ -19,12 +19,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +___get_user() { + if eval $BYOBU_TEST whoami >/dev/null 2>&1; then + whoami + elif eval $BYOBU_TEST id >/dev/null 2>&1; then + id -un + fi +} + __whoami_detail() { - getent -- passwd "$USER" + local user=$(___get_user) + [ -n "$user" ] || return + if eval $BYOBU_TEST getent >/dev/null 2>&1; then + getent -- passwd "$user" + else + grep "^$user:" /etc/passwd + fi } __whoami() { - color bold2; printf "%s@" "$(whoami)"; color - + local user=$(___get_user) + [ -n "$user" ] || return + color bold2; printf "%s@" "$user"; color - } # vi: syntax=sh ts=4 noexpandtab From 388fba847c54a31f693ed8519a989151bc90d8f9 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:16:21 +0800 Subject: [PATCH 12/19] * usr/lib/byobu/wifi_quality: - Add support for iw (preferred over iwconfig) - Make logic more similar to other status notifications --- debian/changelog | 3 ++ usr/lib/byobu/wifi_quality | 68 ++++++++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/debian/changelog b/debian/changelog index 26682ee4..a718a034 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,6 +43,9 @@ byobu (5.128) unreleased; urgency=medium * usr/lib/byobu/whoami: - Use id if the whoami command is not available - Read from /etc/passwd if the getent command is not available + * usr/lib/byobu/wifi_quality: + - Add support for iw (preferred over iwconfig) + - Make logic more similar to other status notifications * usr/share/byobu/keybindings/f-keys.tmux: - Remove -k for new-window. In older versions of tmux, -k without -t had no effect. In tmux 2.8, -k without -t will diff --git a/usr/lib/byobu/wifi_quality b/usr/lib/byobu/wifi_quality index 67a52f79..5b687c0e 100755 --- a/usr/lib/byobu/wifi_quality +++ b/usr/lib/byobu/wifi_quality @@ -19,32 +19,64 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +___get_dev_list() { + if [ -n "$MONITORED_NETWORK" ]; then + echo "$MONITORED_NETWORK" + else + iw dev | grep Interface | cut -f2 -d\ + fi +} + __wifi_quality_detail() { - /sbin/iwconfig 2>/dev/null + if eval $BYOBU_TEST iw >/dev/null 2>&1; then + local dev + for dev in $(___get_dev_list); do + iw dev "$dev" info + iw dev "$dev" link + echo + done + elif eval $BYOBU_TEST iwconfig >/dev/null 2>&1; then + iwconfig 2>/dev/null + fi } __wifi_quality() { local out bitrate quality - # iwconfig is expected to output lines like: - # Bit Rate=54 Mb/s Tx-Power=15 dBm - # Link Quality=60/70 Signal level=-50 dBm - # the awk below tokenizes the output and prints shell evalable results - out=`iwconfig $MONITORED_NETWORK 2>/dev/null | - awk '$0 ~ /[ ]*Link Quality./ { - sub(/.*=/,"",$2); split($2,a,"/"); - printf "quality=%.0f\n", 100*a[1]/a[2] }; - $0 ~ /[ ]*Bit Rate/ { sub(/.*[:=]/,"",$2); printf("bitrate=%s\n", $2); } - '` - eval "$out" - [ -z "$bitrate" ] && bitrate="0" - if [ -z "$quality" ] || [ "$quality" = "0" ]; then - quality="0" + if eval $BYOBU_TEST iw >/dev/null 2>&1; then + local dev + for dev in $(___get_dev_list); do + # iw is expected to output lines like: + # signal: -50 dBm + # rx bitrate: 216.0 MBit/s MCS 13 40MHz + # signal to quality: https://superuser.com/a/1360447 + out=`iw dev "$dev" link 2>/dev/null | + awk '$0 ~ /^\s*signal:/ { a = 100 * ($2 + 110) / 70; + printf "quality=%.0f\n", (a > 100) ? 100 : ((a < 0) ? 0 : a); } + $0 ~ /^\s*rx bitrate:/ { printf "bitrate=%s\n", $3; } + '` + eval "$out" + [ -z "$bitrate" ] || [ -z "$quality" ] || break + done + elif eval $BYOBU_TEST iwconfig >/dev/null 2>&1; then + # iwconfig is expected to output lines like: + # Bit Rate=54 Mb/s Tx-Power=15 dBm + # Link Quality=60/70 Signal level=-50 dBm + # the awk below tokenizes the output and prints shell evalable results + out=`iwconfig $MONITORED_NETWORK 2>/dev/null | + awk '$0 ~ /[ ]*Link Quality./ { + sub(/.*=/,"",$2); split($2,a,"/"); + printf "quality=%.0f\n", 100*a[1]/a[2] }; + $0 ~ /[ ]*Bit Rate/ { sub(/.*[:=]/,"",$2); printf("bitrate=%s\n", $2); } + '` + eval "$out" fi - if [ "$bitrate" = "0" ] || [ "$quality" = "0" ] || [ -z "$bitrate" ] || [ -z "$quality"]; then + [ -n "$bitrate" ] || bitrate=0 + [ -n "$quality" ] || quality=0 + if [ "$bitrate" -gt 0 ] && [ "$quality" -gt 0 ]; then + printf "${ICON_WIFI}"; color b C k; printf "%s" "$bitrate"; color -; color C k; printf "%s" "$ICON_MBPS"; color -; color b C k; printf "%s" "$quality"; color -; color C k; printf "%s" "$PCT"; color -- + else rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/wifi_quality"* - return fi - printf "${ICON_WIFI}"; color b C k; printf "%s" "$bitrate"; color -; color C k; printf "%s" "$ICON_MBPS"; color -; color b C k; printf "%s" "$quality"; color -; color C k; printf "%s" "$PCT"; color -- } # vi: syntax=sh ts=4 noexpandtab From 4f3be73ee9788746ffa79e92518af3180a067330 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:16:42 +0800 Subject: [PATCH 13/19] * usr/lib/byobu/raid: - Ensure /proc/mdstat is readable --- debian/changelog | 2 ++ usr/lib/byobu/raid | 1 + 2 files changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index a718a034..04b02f7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -34,6 +34,8 @@ byobu (5.128) unreleased; urgency=medium * usr/lib/byobu/processes: - Handle stderr for ps, e.g. unsupported options - Remove unnecessary awk call; wc -l only outputs one value + * usr/lib/byobu/raid: + - Ensure /proc/mdstat is readable * usr/lib/byobu/release: - Fix typo * usr/lib/byobu/services: diff --git a/usr/lib/byobu/raid b/usr/lib/byobu/raid index 96743447..01f2fed8 100755 --- a/usr/lib/byobu/raid +++ b/usr/lib/byobu/raid @@ -24,6 +24,7 @@ __raid_detail() { } __raid() { + [ -r /proc/mdstat ] || return while read line; do local p msg # Errors in your raid From 0c292308c8e188804871b276fe7dfeaaa0bb8f15 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:17:01 +0800 Subject: [PATCH 14/19] * usr/lib/byobu/session: - Fix screen session regex --- debian/changelog | 2 ++ usr/lib/byobu/session | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 04b02f7a..e787db8a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,8 @@ byobu (5.128) unreleased; urgency=medium - Fix typo * usr/lib/byobu/services: - Fix reading services from $BYOBU_CONFIG_DIR/statusrc + * usr/lib/byobu/session: + - Fix screen session regex * usr/lib/byobu/updates_available: - Add support for opkg (OpenWrt) * usr/lib/byobu/whoami: diff --git a/usr/lib/byobu/session b/usr/lib/byobu/session index 082054b9..534f2467 100755 --- a/usr/lib/byobu/session +++ b/usr/lib/byobu/session @@ -34,7 +34,7 @@ __session() { fi ;; screen) - local count=$(screen -ls | grep "^ .*\)$" | wc -l) + local count=$(screen -ls | grep "^\s\+.*)$" | wc -l) if [ $count -gt 1 ]; then color u W k; printf "${ICON_SESSION}%S"; color -- else From 02737c8f4511ed1eda8b8fc487b9d2d5edcf6e75 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:17:23 +0800 Subject: [PATCH 15/19] * usr/bin/byobu.in: - Use readlink if the tty command is not available --- debian/changelog | 2 ++ usr/bin/byobu.in | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e787db8a..25264011 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ byobu (5.128) unreleased; urgency=medium usr/bin/byobu-janitor.in: - Test if $HOME/.bashrc exists before modifying it (and potentially creating it) + * usr/bin/byobu.in: + - Use readlink if the tty command is not available * usr/lib/byobu/disk_io: - Ensure the detected mount point device exists * usr/lib/byobu/hostname: diff --git a/usr/bin/byobu.in b/usr/bin/byobu.in index b4df33ae..fc5096f4 100755 --- a/usr/bin/byobu.in +++ b/usr/bin/byobu.in @@ -62,7 +62,11 @@ esac export BYOBU_BACKEND # Store the parent tty -export BYOBU_TTY=$(tty) +if eval $BYOBU_TEST tty >/dev/null 2>&1; then + export BYOBU_TTY=$(tty) +else + export BYOBU_TTY=$(readlink /proc/$$/fd/0) +fi # Get the default window name [ -n "$BYOBU_WINDOW_NAME" ] || BYOBU_WINDOW_NAME=- From 69871dedc83f7b0cc3d1504fc1cdb3c0f0a0e6ea Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:17:42 +0800 Subject: [PATCH 16/19] * usr/bin/byobu-launch.in: - Don't autolaunch for ARM serial consoles --- debian/changelog | 2 ++ usr/bin/byobu-launch.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 25264011..372da95c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ byobu (5.128) unreleased; urgency=medium creating it) * usr/bin/byobu.in: - Use readlink if the tty command is not available + * usr/bin/byobu-launch.in: + - Don't autolaunch for ARM serial consoles * usr/lib/byobu/disk_io: - Ensure the detected mount point device exists * usr/lib/byobu/hostname: diff --git a/usr/bin/byobu-launch.in b/usr/bin/byobu-launch.in index 77cd57e3..9d177207 100755 --- a/usr/bin/byobu-launch.in +++ b/usr/bin/byobu-launch.in @@ -31,7 +31,7 @@ # $HOME/.bashrc: export BYOBU_DISABLE=1 _tty=$(tty) -if [ "${_tty#/dev/ttyS}" != "$_tty" ]; then +if [ "${_tty#/dev/ttyS}" != "$_tty" ] && [ "${_tty#/dev/ttyAMA}" != "$_tty" ]; then # Don't autolaunch byobu on serial consoles # You can certainly run 'byobu' manually, though echo From b10c7b6f652db812a456cbcabf4661e70d02f766 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:18:06 +0800 Subject: [PATCH 17/19] * usr/bin/byobu-janitor.in: - Add fallback if the install command is not available --- debian/changelog | 2 ++ usr/bin/byobu-janitor.in | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 372da95c..e13afd48 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ byobu (5.128) unreleased; urgency=medium creating it) * usr/bin/byobu.in: - Use readlink if the tty command is not available + * usr/bin/byobu-janitor.in: + - Add fallback if the install command is not available * usr/bin/byobu-launch.in: - Don't autolaunch for ARM serial consoles * usr/lib/byobu/disk_io: diff --git a/usr/bin/byobu-janitor.in b/usr/bin/byobu-janitor.in index 071b82ca..840f98d4 100755 --- a/usr/bin/byobu-janitor.in +++ b/usr/bin/byobu-janitor.in @@ -41,7 +41,14 @@ DEFAULT_PROFILE="light" PROFILE="$BYOBU_CONFIG_DIR/profile" # Create byobu-exchange buffer file, with secure permissions, if it doesn't exist -[ -e "$BYOBU_RUN_DIR/printscreen" ] || install -m 600 /dev/null "$BYOBU_RUN_DIR/printscreen" +if ! [ -e "$BYOBU_RUN_DIR/printscreen" ]; then + if eval $BYOBU_TEST install >/dev/null 2>&1; then + install -m 600 /dev/null "$BYOBU_RUN_DIR/printscreen" + else + cp /dev/null "$BYOBU_RUN_DIR/printscreen" + chmod 600 "$BYOBU_RUN_DIR/printscreen" + fi +fi # Affects: users who launched using sudo, such that their config dir # is not writable by them From 768f08712db39d08f2df667d7273aa753ca18b16 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:18:32 +0800 Subject: [PATCH 18/19] * usr/lib/byobu/users: - Handle stderr for ps, e.g. unsupported options - Fix trailing '#' sign --- debian/changelog | 3 +++ usr/lib/byobu/users | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index e13afd48..8a41f1ec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -50,6 +50,9 @@ byobu (5.128) unreleased; urgency=medium - Fix screen session regex * usr/lib/byobu/updates_available: - Add support for opkg (OpenWrt) + * usr/lib/byobu/users: + - Handle stderr for ps, e.g. unsupported options + - Fix trailing '#' sign * usr/lib/byobu/whoami: - Use id if the whoami command is not available - Read from /etc/passwd if the getent command is not available diff --git a/usr/lib/byobu/users b/usr/lib/byobu/users index 1f16f066..0d8dd21f 100755 --- a/usr/lib/byobu/users +++ b/usr/lib/byobu/users @@ -22,7 +22,7 @@ # along with this program. If not, see . __users_detail() { - ps -ef | grep "sshd:.*@" | grep -v grep + ps -ef 2>/dev/null | grep "sshd:.*@" | grep -v grep } __users() { @@ -35,7 +35,7 @@ __users() { count=$(pgrep -f "^sshd:.*@|^/usr/sbin/sshd -i" | wc -l) || return fi if [ $count -gt 0 ]; then - color b w r; printf "%d" "$count"; color -; color w r; printf "#"; color -- + color b w r; printf "%d" "$count"; color -; color w r; printf "##"; color -- else rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/users"* fi From c3d8f078c8d874711a314a68a21471a86f496989 Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Mon, 27 May 2019 03:18:53 +0800 Subject: [PATCH 19/19] * usr/bin/byobu-export.in: - Use echo if the gettext command is not available --- debian/changelog | 2 ++ usr/bin/byobu-export.in | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 8a41f1ec..49a8eccd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ byobu (5.128) unreleased; urgency=medium usr/bin/byobu-janitor.in: - Test if $HOME/.bashrc exists before modifying it (and potentially creating it) + * usr/bin/byobu-export.in: + - Use echo if the gettext command is not available * usr/bin/byobu.in: - Use readlink if the tty command is not available * usr/bin/byobu-janitor.in: diff --git a/usr/bin/byobu-export.in b/usr/bin/byobu-export.in index 916dccec..8b1d712f 100755 --- a/usr/bin/byobu-export.in +++ b/usr/bin/byobu-export.in @@ -22,7 +22,13 @@ PKG="byobu" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="@prefix@" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" -gettext " +if eval $BYOBU_TEST gettext >/dev/null 2>&1; then + command=gettext +else + command=echo +fi + +$command " The byobu-export utility is now deprecated. To install byobu on a system for which byobu is not packaged, or