From a0074a8e50820982d1d3bcb35394dd5d89138bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Tue, 12 Dec 2023 19:10:41 +0900 Subject: [PATCH] byobu 5.2 --- CHANGELOG.md | 65 +++++++ README.md | 5 +- bin/byobu | 12 +- bin/byobu-ctrl-a | 2 +- bin/byobu-disable | 2 +- bin/byobu-disable-prompt | 2 +- bin/byobu-enable | 2 +- bin/byobu-enable-prompt | 2 +- bin/byobu-export | 4 +- bin/byobu-janitor | 2 +- bin/byobu-launch | 2 +- bin/byobu-launcher | 2 +- bin/byobu-launcher-install | 2 +- bin/byobu-launcher-uninstall | 2 +- bin/byobu-layout | 2 +- bin/byobu-prompt | 2 +- bin/byobu-quiet | 2 +- bin/byobu-reconnect-sockets | 2 +- bin/byobu-select-backend | 2 +- bin/byobu-select-profile | 2 +- bin/byobu-shell | 2 +- bin/byobu-silent | 2 +- bin/byobu-status | 2 +- bin/byobu-status-detail | 2 +- bin/byobu-ugraph | 2 +- bin/byobu-ulevel | 2 +- lib/byobu/battery | 198 ++++++++++++-------- lib/byobu/cpu_freq | 2 +- lib/byobu/cpu_temp | 89 +++++---- lib/byobu/disk | 45 ++--- lib/byobu/include/config.py | 2 +- lib/byobu/include/dirs | 18 +- lib/byobu/include/select-session.py | 2 +- lib/byobu/include/toggle-utf8 | 2 +- lib/byobu/memory | 2 +- lib/byobu/release | 8 +- share/byobu/keybindings/f-keys.tmux.disable | 2 +- share/byobu/profiles/screenrc | 2 +- share/byobu/status/status | 2 +- share/byobu/status/statusrc | 2 +- 40 files changed, 292 insertions(+), 214 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f03b03a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,65 @@ +# 5.2 +* 今度から、テクニカル諏訪子ちゃんは更新します。 +* メモリ、ディスク、CPU温度、及びCPUプロセスがLinux、OpenBSD、及びFreeBSDに対応する様にしました。 +* 「.byobu」→「.config/byobu」、「.byoburc」→「.config/byoburc」 + +# 5.133 +* fix FTBFS on README + +# 5.132 +* pep8 binary is gone from Debian, disable for now + +# 5.131 +* build-depend on python3-pep8, rather than pep8 transitional package +* change disk status to white on darker magenta/purple, helps with readability on some terminals +* commit edeae41 fixed the excessive creation of sessions by not creating different sessions. This commit adjust the behavior in a way that having .reuse-sessions enabled tmux will properly attach and remove sessions when dettaching and will also kill the last session available +* When more than two sessions exist, tmux asks which session to use +* Update usage of tmux swap-window so that focus stays with the original window. + +# 5.130 +* add Raspbian colors / logo +* Force UTF-8 when attaching in `select-session.py` +* ignore new pep8 rules around hard tabs and whitespaces, related to bug 1843729 +* Flatten these files into a single README.md +* Minor updates in the process + +# 5.129 +* recommend less package, for BYOBU_PAGER + +# 5.128 +* Quotes are needed around "$@" to keep parameters from splitting on spaces. +* "SuSE" name is an outdated version of it. Use the modern one: SUSE +* use env python3 for portability to other Linux and Mac systems (hopefully that's still okay for Debian / Ubuntu? +* https://github.com/dustinkirkland/byobu/pull/30 +* prefer iwconfig over iw for now, iw is not working for me +* flatten some of our color configuration to match the new tmux format +* ensure some values are set to zero, if unreadable +* fixes a bug where disk_io causes the rest of the status line to fail +* fix bug creating a mess of sessions, where cycling through a bunch of copies of the same session +* On tmux version 1.9 all the styles *-bg/fg/attr were deprecated and replaced with *-style bg=/ fg=/ attribute In the upcoming version 2.9, this commands are gone and will break byobu style. this fix that issue and mantain compatibility with upcoming tmux versions. +* Do not include the user's .screenrc in the apport generated crash report +* Test if $HOME/.bashrc exists before modifying it (and potentially creating it) +* Use echo if the gettext command is not available +* Use readlink if the tty command is not available +* Add fallback if the install command is not available +* Don't autolaunch for ARM serial consoles +* Ensure the detected mount point device exists +* Read from /proc/sys/kernel/hostname if the hostname command is not available +* Add logo for OpenWrt +* Handle stderr for ps, e.g. unsupported options +* Remove unnecessary awk call; wc -l only outputs one value +* Ensure /proc/mdstat is readable +* Fix typo +* Fix reading services from $BYOBU_CONFIG_DIR/statusrc +* Fix screen session regex +* Add support for opkg (OpenWrt) +* Handle stderr for ps, e.g. unsupported options +* Fix trailing '#' sign +* Use id if the whoami command is not available +* Read from /etc/passwd if the getent command is not available +* Add support for iw (preferred over iwconfig) +* Make logic more similar to other status notifications +* 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. +* Rename the new window created after adding a new session + +もっと: [https://launchpad.net/byobu/+download](https://launchpad.net/byobu/+download) diff --git a/README.md b/README.md index 86d3d86..34c124c 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -元のbyobuはDebian向けらしい、だからArtix、CRUX、OpenBSD、及びFreeBSDでもうまく機能している間で変更した +元のbyobuはDebian向けらしい、だからArtix、CRUX、OpenBSD、及びFreeBSDでもうまく機能している間で変更した。 + +更新:\ +元のbyobuの開発者は辞めたらしいから、バージョン5.2からあたしが開発者だわ〜 diff --git a/bin/byobu b/bin/byobu index f71dd05..8766bd4 100755 --- a/bin/byobu +++ b/bin/byobu @@ -18,7 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -VERSION=5.133 +VERSION=5.2 PKG="byobu" # All sorts of things go wrong if you don't own your $HOME dir. @@ -33,21 +33,21 @@ if [ ! -O "$HOME" ]; then fi # Source local byobu config -if [ -r "$HOME/.byoburc" ]; then +if [ -r "$HOME/.config/byoburc" ]; then # Ensure that this configuration is usable - . "$HOME/.byoburc" || mv -f "$HOME/.byoburc" "$HOME/.byoburc".orig + . "$HOME/.config/byoburc" || mv -f "$HOME/.config/byoburc" "$HOME/.config/byoburc".orig fi if [ -z "${BYOBU_PREFIX}" ]; then # Find and export the installation location prefix greadlink -f . >/dev/null 2>&1 && export BYOBU_READLINK="greadlink" || export BYOBU_READLINK="readlink" prefix="$(dirname $(dirname $($BYOBU_READLINK -f $0)))" if [ "$prefix" != "/usr" ]; then - echo "export BYOBU_PREFIX='$prefix'" >> "$HOME/.byoburc" - . "$HOME/.byoburc" + echo "export BYOBU_PREFIX='$prefix'" >> "$HOME/.config/byoburc" + . "$HOME/.config/byoburc" fi fi export BYOBU_CHARMAP=$(locale charmap) -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-ctrl-a b/bin/byobu-ctrl-a index a43a4b9..84ba73c 100755 --- a/bin/byobu-ctrl-a +++ b/bin/byobu-ctrl-a @@ -26,7 +26,7 @@ EOF } PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-disable b/bin/byobu-disable index 59f0bb8..57b4359 100755 --- a/bin/byobu-disable +++ b/bin/byobu-disable @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-disable-prompt b/bin/byobu-disable-prompt index 0efb2e9..5fe288a 100755 --- a/bin/byobu-disable-prompt +++ b/bin/byobu-disable-prompt @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-enable b/bin/byobu-enable index ebacff5..523cda0 100755 --- a/bin/byobu-enable +++ b/bin/byobu-enable @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-enable-prompt b/bin/byobu-enable-prompt index 1ea9048..386d824 100755 --- a/bin/byobu-enable-prompt +++ b/bin/byobu-enable-prompt @@ -20,7 +20,7 @@ [ "$SHELL" = "/bin/bash" ] || exit 1 PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-export b/bin/byobu-export index bc46c40..bd11922 100755 --- a/bin/byobu-export +++ b/bin/byobu-export @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" @@ -34,7 +34,7 @@ The byobu-export utility is now deprecated. To install byobu on a system for which byobu is not packaged, or where you are not the root user, simply: * Download the latest release (>= 3.0) from: - https://launchpad.net/byobu/+download + https://gitler.moe/suwako/byobu * And follow the instructions in the README " diff --git a/bin/byobu-janitor b/bin/byobu-janitor index 63c8a41..eb88671 100755 --- a/bin/byobu-janitor +++ b/bin/byobu-janitor @@ -20,7 +20,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-launch b/bin/byobu-launch index de38f28..d9f4724 100755 --- a/bin/byobu-launch +++ b/bin/byobu-launch @@ -42,7 +42,7 @@ elif [ "$BYOBU_SOURCED_PROFILE" != "1" ] && [ "$LC_BYOBU" != "0" ] && [ "$BYOBU_ unset _tty BYOBU_SOURCED_PROFILE=1 PKG="byobu" - [ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" + [ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" # Ensure that autolaunch is not explicitly disabled diff --git a/bin/byobu-launcher b/bin/byobu-launcher index 7a3ee9d..7e1af03 100755 --- a/bin/byobu-launcher +++ b/bin/byobu-launcher @@ -21,7 +21,7 @@ PKG="byobu" # Bad things happen if you run byobu, but you don't own your $HOME # ie, rather than "sudo byobu", you must run "sudo -H byobu" if [ -O "$HOME" ]; then - [ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" + [ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" if [ -e "$BYOBU_CONFIG_DIR/disable-autolaunch" ]; then diff --git a/bin/byobu-launcher-install b/bin/byobu-launcher-install index 82e5b76..460b79e 100755 --- a/bin/byobu-launcher-install +++ b/bin/byobu-launcher-install @@ -19,7 +19,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-launcher-uninstall b/bin/byobu-launcher-uninstall index f697ae0..60bfb4b 100755 --- a/bin/byobu-launcher-uninstall +++ b/bin/byobu-launcher-uninstall @@ -19,7 +19,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-layout b/bin/byobu-layout index 70b55cc..bfa5d7e 100755 --- a/bin/byobu-layout +++ b/bin/byobu-layout @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-prompt b/bin/byobu-prompt index ce12eae..c96ead3 100755 --- a/bin/byobu-prompt +++ b/bin/byobu-prompt @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-quiet b/bin/byobu-quiet index 26baa60..032cf2a 100755 --- a/bin/byobu-quiet +++ b/bin/byobu-quiet @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-reconnect-sockets b/bin/byobu-reconnect-sockets index db37f3b..70ec34c 100755 --- a/bin/byobu-reconnect-sockets +++ b/bin/byobu-reconnect-sockets @@ -24,7 +24,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-select-backend b/bin/byobu-select-backend index c5eb98f..32d39af 100755 --- a/bin/byobu-select-backend +++ b/bin/byobu-select-backend @@ -19,7 +19,7 @@ PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-select-profile b/bin/byobu-select-profile index 7494b31..b76357f 100755 --- a/bin/byobu-select-profile +++ b/bin/byobu-select-profile @@ -23,7 +23,7 @@ # ./debian/rules get-po PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-shell b/bin/byobu-shell index 0adcb90..7ff722b 100755 --- a/bin/byobu-shell +++ b/bin/byobu-shell @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-silent b/bin/byobu-silent index f7c1b78..33a8a9a 100755 --- a/bin/byobu-silent +++ b/bin/byobu-silent @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-status b/bin/byobu-status index 431912f..4a96268 100755 --- a/bin/byobu-status +++ b/bin/byobu-status @@ -19,7 +19,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-status-detail b/bin/byobu-status-detail index 0a04f93..47783b6 100755 --- a/bin/byobu-status-detail +++ b/bin/byobu-status-detail @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-ugraph b/bin/byobu-ugraph index bf33f34..02015b8 100755 --- a/bin/byobu-ugraph +++ b/bin/byobu-ugraph @@ -25,7 +25,7 @@ #--------------------------------------------------------------------- PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/bin/byobu-ulevel b/bin/byobu-ulevel index 877de32..c0cfa7c 100755 --- a/bin/byobu-ulevel +++ b/bin/byobu-ulevel @@ -36,7 +36,7 @@ # command-line option. PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" diff --git a/lib/byobu/battery b/lib/byobu/battery index 6e995b3..f0083ad 100755 --- a/lib/byobu/battery +++ b/lib/byobu/battery @@ -1,92 +1,132 @@ #!/bin/sh -e +# +# battery: print the state of the battery +# +# Copyright (C) 2009 Raphaël Pinson. +# Copyright (C) 2011-2014 Dustin Kirkland +# +# Authors: Raphaël Pinson +# 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 . __battery_detail() { local bat for bat in /proc/acpi/battery/*; do - cat "$bat/info" - cat "$bat/state" + 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 + # Linux support present=""; full="0"; rem="0"; state="" - case "$(uname)" in - OpenBSD) - percent=$(apm -l) - case $(apm -a) in - 0) state="discharging";; - 1) state="charging";; - 2) state="on-line";; - esac - ;; - Linux) - for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do - case "$bat" in - /sys/*) - if [ -r "$bat/uevent" ]; then - . "$bat/uevent" - case "$POWER_SUPPLY_NAME" in AC|ac|Ac|aC) continue ;; esac - present="$POWER_SUPPLY_PRESENT" - [ -n "$POWER_SUPPLY_CHARGE_FULL" ] && full=$((POWER_SUPPLY_CHARGE_FULL+full)) - [ -n "$POWER_SUPPLY_ENERGY_FULL" ] && full=$((POWER_SUPPLY_ENERGY_FULL+full)) - [ -n "$POWER_SUPPLY_CHARGE_NOW" ] && rem=$((POWER_SUPPLY_CHARGE_NOW+rem)) - [ -n "$POWER_SUPPLY_ENERGY_NOW" ] && rem=$((POWER_SUPPLY_ENERGY_NOW+rem)) - if [ -n "$POWER_SUPPLY_CAPACITY" ] && [ ! -n "$POWER_SUPPLY_ENERGY_NOW" ] && [ ! -n "$POWER_SUPPLY_CHARGE_NOW" ]; then - rem="$POWER_SUPPLY_CAPACITY" && full="100" - fi - [ "$POWER_SUPPLY_STATUS" != "Unknown" ] && state="$POWER_SUPPLY_STATUS" - fi - ;; - /proc/*) - [ -f "$bat/info" ] || continue - while read line; do - set -- ${line} - case "$line" in - present:*) - [ "$2" = "no" ] && continue 2 - present="$2";; - last\ full\ capacity:*) full="$4";; - esac - [ -n "$present" -a -n "$full" ] && break - done < "${bat}/info" - while read line; do - set -- ${line} - case "$line" in - remaining\ capacity:*) rem="$3";; - charging\ state:*) state="$3";; - esac - [ -n "$rem" -a -n "$state" ] && break - done < "$bat/state" - [ -n "$full" ] && [ -n "$rem" ] && [ -n "$state" ] && break - ;; - esac - done - esac - - if [ $percent -ge 0 ]; then - if [ "$percent" -lt 33 ]; then - color="R w" - bcolor="b R w" - elif [ "$percent" -lt 67 ]; then - color="Y k" - bcolor="b Y k" - else - color="G k" - bcolor="b G k" - fi - percent="${percent}${PCT}" - state=$(printf "%s" "$state" | $BYOBU_SED 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/') - case $state in - charging) sign="+" ;; - discharging) sign="-" ;; - on-line) sign="=" ;; - *) sign="$state" ;; - esac - if [ -z "$percent" ]; then - rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/battery"* - return - fi - color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- + for bat in $BATTERY /sys/class/power_supply/* /proc/acpi/battery/*; do + case "$bat" in + /sys/*) + if [ -r "$bat/uevent" ]; then + . "$bat/uevent" + case "$POWER_SUPPLY_NAME" in AC|ac|Ac|aC) continue ;; esac + present="$POWER_SUPPLY_PRESENT" + # Some use "CHARGE", others use "ENERGY", still others "CAPACITY" + [ -n "$POWER_SUPPLY_CHARGE_FULL" ] && full=$((POWER_SUPPLY_CHARGE_FULL+full)) + [ -n "$POWER_SUPPLY_ENERGY_FULL" ] && full=$((POWER_SUPPLY_ENERGY_FULL+full)) + [ -n "$POWER_SUPPLY_CHARGE_NOW" ] && rem=$((POWER_SUPPLY_CHARGE_NOW+rem)) + [ -n "$POWER_SUPPLY_ENERGY_NOW" ] && rem=$((POWER_SUPPLY_ENERGY_NOW+rem)) + if [ -n "$POWER_SUPPLY_CAPACITY" ] && [ ! -n "$POWER_SUPPLY_ENERGY_NOW" ] && [ ! -n "$POWER_SUPPLY_CHARGE_NOW" ]; then + rem="$POWER_SUPPLY_CAPACITY" && full="100" + fi + [ "$POWER_SUPPLY_STATUS" != "Unknown" ] && state="$POWER_SUPPLY_STATUS" + fi + ;; + /proc/*) + [ -f "$bat/info" ] || continue + while read line; do + set -- ${line} + case "$line" in + present:*) + # make sure that this battery is present + [ "$2" = "no" ] && continue 2 + present="$2";; + last\ full\ capacity:*) full="$4";; + esac + [ -n "$present" -a -n "$full" ] && break + done < "${bat}/info" + while read line; do + set -- ${line} + case "$line" in + remaining\ capacity:*) rem="$3";; + charging\ state:*) state="$3";; + esac + [ -n "$rem" -a -n "$state" ] && break + done < "$bat/state" + [ -n "$full" ] && [ -n "$rem" ] && [ -n "$state" ] && break + ;; + esac + done + # Mac OS X support + if eval $BYOBU_TEST /usr/sbin/ioreg >/dev/null 2>&1; then + # MacOS support + local key + for key in CurrentCapacity MaxCapacity ExternalChargeCapable FullyCharged; do + line=$(/usr/sbin/ioreg -n AppleSmartBattery -w0 | grep $key | sed -e 's/|//g' | awk '{ print $3 }') + case "$key" in + CurrentCapacity) rem="$line";; + MaxCapacity) full="$line";; + ExternalChargeCapable) + if [ "${line}" = "Yes" ]; then + state="charging" + elif [ "${line}" = "No" ]; then + state="discharging" + fi + ;; + FullyCharged) + if [ "${line}" = "Yes" ]; then + state="charged" + fi + ;; + esac + done + fi + if [ $rem -ge 0 ] && [ $full -gt 0 ]; then + percent=$(((100*$rem)/$full)) + if [ "$percent" -lt 33 ]; then + color="R w" + bcolor="b R w" + elif [ "$percent" -lt 67 ]; then + color="Y k" + bcolor="b Y k" + else + color="G k" + bcolor="b G k" + fi + percent="${percent}${PCT}" + # Convert state to lower case + state=$(printf "%s" "$state" | $BYOBU_SED 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/') + case $state in + charging) sign="+" ;; + discharging) sign="-" ;; + charged|unknown|full) sign="=" ;; + *) sign="$state" ;; + esac + if [ -z "$percent" ]; then + rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/battery"* + return + fi + color $bcolor; printf "%s" "$percent"; color -; color $color; printf "%s" "$sign"; color -- fi } + +# vi: syntax=sh ts=4 noexpandtab diff --git a/lib/byobu/cpu_freq b/lib/byobu/cpu_freq index 1c7f568..27a2240 100755 --- a/lib/byobu/cpu_freq +++ b/lib/byobu/cpu_freq @@ -1,4 +1,3 @@ -#!/bin/sh -e __cpu_freq_detail() { cat /proc/cpuinfo } @@ -45,6 +44,7 @@ __cpu_freq() { unit="MHz" fi fi + [ -n "$freq" ] || return color c W; printf "%s" "${cores}x"; color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$unit"; color -- } diff --git a/lib/byobu/cpu_temp b/lib/byobu/cpu_temp index ccd8690..31dc41b 100755 --- a/lib/byobu/cpu_temp +++ b/lib/byobu/cpu_temp @@ -1,54 +1,53 @@ #!/bin/sh -e -# -# cpu_temp: cpu temperature -# -# Copyright (C) 2008 Canonical Ltd. -# Copyright (C) 2011-2014 Dustin Kirkland -# -# 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 . __cpu_temp_detail() { - local i - for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do - [ -r "$i" ] || continue - printf "%s\n" "$i:" - cat "$i"/* - done + case "$(uname)" in + "OpenBSD") + sysctl hw.sensors | grep -E 'hw.sensors.*temp' + ;; + "FreeBSD") + sysctl dev.cpu | grep -E 'dev.cpu.*temperature' + ;; + "Linux") + local i + for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do + [ -r "$i" ] || continue + printf "%s\n" "$i:" + cat "$i"/* + done + ;; + esac } __cpu_temp() { - local i t unit - for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do - case "$i" in - *temp*_input|*thermal_zone*/temp) - [ -s "$i" ] && read t < "$i" && t=$(($t/1000)) - ;; - *) - [ -s "$i" ] && t=$($BYOBU_SED -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i") - ;; - esac - if [ -n "$t" ] && [ "$t" -gt 0 ]; then - unit="$ICON_C" - if [ "$TEMP" = "F" ]; then - t=$(($t*9/5 + 32)) - unit="$ICON_F" - fi - color b k Y; printf "%s" "$t"; color -; color k Y; printf "%s" "$unit"; color -- - break - fi - done + local i t unit + case "$(uname)" in + "OpenBSD") + t=$(sysctl hw.sensors | grep -E 'hw.sensors.*temp' | awk '{ print $1 }' | head -1 | sed 's/^.*=//' | sed 's/\..*$//') + color b k Y; printf "%s" "$t"; color -- + ;; + "FreeBSD") + t=$(sysctl dev.cpu | grep -E 'dev.cpu.*temperature' | awk '{ print $2 }' | head -1 | sed 's/\..*$/C/') + color b k Y; printf "%s" "$t"; color -- + ;; + "Linux") + for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do + case "$i" in + *temp*_input|*thermal_zone*/temp) + [ -s "$i" ] && read t < "$i" && t=$(($t/1000)) + ;; + *) + [ -s "$i" ] && t=$($BYOBU_SED -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i") + ;; + esac + + if [ -n "$t" ] && [ "$t" -gt 0 ]; then + color b k Y; printf "%sC" "$t"; color -- + break + fi + done + ;; + esac } # vi: syntax=sh ts=4 noexpandtab diff --git a/lib/byobu/disk b/lib/byobu/disk index dd348b8..485deee 100755 --- a/lib/byobu/disk +++ b/lib/byobu/disk @@ -1,40 +1,23 @@ #!/bin/sh -e __disk_detail() { - df -h -P + if [ $(uname) = "FreeBSD" ]; then + df -h + else + df -h -P + fi } __disk() { - local out="" MP="" size="" free="" unit="" - [ -z "$MONITORED_DISK" ] && MP="/" || MP="$MONITORED_DISK" - case $MP in - /dev/*) MP=$(awk '$1 == m { print $2; exit(0); }' "m=$MP" /proc/mounts);; - esac - - if [ "$(uname)" = "FreeBSD" ]; then - out=$(df -h | grep "${MP}$" | awk '{ printf("%s %s", $4, $2); }') + local use="" total="" + if [ $(uname) = "FreeBSD" ]; then + use=$(zpool list | tail -1 | awk '{ print $3 }') + total=$(zpool list | tail -1 | awk '{ print $2 }') else - out=$({ df -h -P "$MP" 2>/dev/null || df -h "$MP"; } | awk 'END { printf("%s %s", $3, $2); }') + use=$(df -h "/" | tail -1 | awk '{ print $3 }') + total=$(df -h "/" | tail -1 | awk '{ print $2 }') fi - - set -- ${out} - free=${1}; size=${2}; - free_unit=${free#${free%?}} - free=${free%?}; - unit=${size#${size%?}} - size=${size%?}; - case "$unit" in - k*|K*) unit="$ICON_KB" ;; - m*|M*) unit="$ICON_MB" ;; - g*|G*) unit="$ICON_GB" ;; - t*|T*) unit="$ICON_TB" ;; - esac - case "$free_unit" in - k*|K*) free_unit="$ICON_KB" ;; - m*|M*) free_unit="$ICON_MB" ;; - g*|G*) free_unit="$ICON_GB" ;; - t*|T*) free_unit="$ICON_TB" ;; - esac - [ -n "$size" ] || return - color b m W; printf "%s%s/%s%s" "$free" "$free_unit" "$size" "$unit"; color --; + color b m W; printf "%s/" "$use"; color -; color b m W; printf "%s" "$total"; color -; } + +# vi: syntax=sh ts=4 noexpandtab diff --git a/lib/byobu/include/config.py b/lib/byobu/include/config.py index 6e36dfa..f5dd560 100755 --- a/lib/byobu/include/config.py +++ b/lib/byobu/include/config.py @@ -49,7 +49,7 @@ except Exception: PKG = "byobu" HOME = os.getenv("HOME") USER = os.getenv("USER") -BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu") +BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.config/byobu") BYOBU_RUN_DIR = os.getenv("BYOBU_RUN_DIR", HOME + "/.cache/byobu") BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux") BYOBU_SOCKETDIR = os.getenv("SOCKETDIR", "/var/run/screen") diff --git a/lib/byobu/include/dirs b/lib/byobu/include/dirs index 1a10565..879ef07 100755 --- a/lib/byobu/include/dirs +++ b/lib/byobu/include/dirs @@ -21,25 +21,11 @@ PKG="byobu" # Some users build and install byobu themselves, rather than from a distro -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -n "$BYOBU_PREFIX" ] || BYOBU_PREFIX="/usr" # Create and export the user configuration directory -if [ -d "$BYOBU_CONFIG_DIR" ]; then - export BYOBU_CONFIG_DIR="$BYOBU_CONFIG_DIR" -elif [ -d "$XDG_CONFIG_HOME" ]; then - # Use XDG, as some users insist on such nonsense :-) - export BYOBU_CONFIG_DIR="$XDG_CONFIG_HOME/$PKG" -elif [ -d "$HOME/.config/$PKG" ]; then - # Use XDG config directory, if it exists - export BYOBU_CONFIG_DIR="$HOME/.config/$PKG" -elif [ -d "$HOME/.local/share/$PKG" ]; then - # Use XDG local directory, if it exists - export BYOBU_CONFIG_DIR="$HOME/.local/share/$PKG" -else - # And to default to good old classic config dir location! - export BYOBU_CONFIG_DIR="$HOME/.$PKG" -fi +export BYOBU_CONFIG_DIR="$HOME/.config/$PKG" [ -d "$BYOBU_CONFIG_DIR" ] || mkdir -p "$BYOBU_CONFIG_DIR/bin" # Grab the global, then local socket directory diff --git a/lib/byobu/include/select-session.py b/lib/byobu/include/select-session.py index b28c901..186c8c0 100755 --- a/lib/byobu/include/select-session.py +++ b/lib/byobu/include/select-session.py @@ -35,7 +35,7 @@ except Exception: PKG = "byobu" SHELL = os.getenv("SHELL", "/bin/bash") HOME = os.getenv("HOME") -BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.byobu") +BYOBU_CONFIG_DIR = os.getenv("BYOBU_CONFIG_DIR", HOME + "/.config/byobu") BYOBU_BACKEND = os.getenv("BYOBU_BACKEND", "tmux") choice = -1 sessions = [] diff --git a/lib/byobu/include/toggle-utf8 b/lib/byobu/include/toggle-utf8 index 9bed9aa..f90f63a 100755 --- a/lib/byobu/include/toggle-utf8 +++ b/lib/byobu/include/toggle-utf8 @@ -18,7 +18,7 @@ # along with this program. If not, see . PKG="byobu" -[ -r "$HOME/.byoburc" ] && . "$HOME/.byoburc" +[ -r "$HOME/.config/byoburc" ] && . "$HOME/.config/byoburc" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" [ -r "$BYOBU_CONFIG_DIR/statusrc" ] && . "$BYOBU_CONFIG_DIR/statusrc" diff --git a/lib/byobu/memory b/lib/byobu/memory index eaf11f7..9b60c85 100755 --- a/lib/byobu/memory +++ b/lib/byobu/memory @@ -28,7 +28,7 @@ __memory() { ;; OpenBSD) total=$(($(sysctl -n hw.physmem) / 1024 / 1024)) - used_mb=$(($(vmstat | tail -1 | awk '{print $4}') / 1024)) + used_mb=$(vmstat | tail -1 | awk '{print substr($3, 1, length($3)-1)}') ;; FreeBSD) total=$(($(sysctl -n hw.realmem) / 1024 / 1024)) diff --git a/lib/byobu/release b/lib/byobu/release index 294df89..1dcea02 100755 --- a/lib/byobu/release +++ b/lib/byobu/release @@ -13,8 +13,10 @@ __release() { elif [ -r "/etc/os-release" ]; then if grep -q -E '^(Arch|Artix|Gentoo|Void)' /etc/os-release; then RELEASE="" # ローリングリリースの場合 - else + elif grep -q -E '^ID=crux' /etc/os-release; then RELEASE=$(. /etc/os-release && echo "$VERSION") + else + RELEASE=$(. /etc/os-release && echo "$VERSION_ID") fi elif [ -r "/etc/issue" ]; then local issue @@ -23,12 +25,12 @@ __release() { Ubuntu*) set -- $issue; RELEASE="$2"; - ;; + ;; Debian*) local ver read ver < /etc/debian_version RELEASE="$ver" - ;; + ;; esac elif eval $BYOBU_TEST sw_vers >/dev/null 2>&1; then RELEASE="$(sw_vers -productVersion)" diff --git a/share/byobu/keybindings/f-keys.tmux.disable b/share/byobu/keybindings/f-keys.tmux.disable index cc556c2..e8ac310 100644 --- a/share/byobu/keybindings/f-keys.tmux.disable +++ b/share/byobu/keybindings/f-keys.tmux.disable @@ -78,7 +78,7 @@ unbind-key -n C-F9 unbind-key -n M-F11 unbind-key -n C-F11 unbind-key -n S-F11 -bind-key -n S-F12 source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux \; source $HOME/.byobu/keybindings.tmux \; display-message "Byobu F-keys: ENABLED" +bind-key -n S-F12 source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux \; source $HOME/.config/byobu/keybindings.tmux \; display-message "Byobu F-keys: ENABLED" unbind-key -n M-F12 unbind-key -n C-S-F12 unbind-key -n M-IC diff --git a/share/byobu/profiles/screenrc b/share/byobu/profiles/screenrc index 22071a1..47ceaee 100644 --- a/share/byobu/profiles/screenrc +++ b/share/byobu/profiles/screenrc @@ -2,7 +2,7 @@ # Load: # * the stock byobu profile # * any windows -# * and the local .screenrc (instead of .byoburc) +# * and the local .screenrc (instead of .config/byoburc) # Used at startup but not profile refresh # # Copyright (C) 2009-2011 Canonical Ltd. diff --git a/share/byobu/status/status b/share/byobu/status/status index b0a2883..5bb2e6c 100644 --- a/share/byobu/status/status +++ b/share/byobu/status/status @@ -2,7 +2,7 @@ # # Override these in $BYOBU_CONFIG_DIR/status # where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, -# and $HOME/.byobu otherwise. +# and $HOME/.config/byobu otherwise. # # Copyright (C) 2009-2011 Canonical Ltd. # diff --git a/share/byobu/status/statusrc b/share/byobu/status/statusrc index 472e45c..28a01b0 100644 --- a/share/byobu/status/statusrc +++ b/share/byobu/status/statusrc @@ -2,7 +2,7 @@ # # Override these in $BYOBU_CONFIG_DIR/statusrc # where BYOBU_CONFIG_DIR is XDG_CONFIG_HOME if defined, -# and $HOME/.byobu otherwise. +# and $HOME/.config/byobu otherwise. # # Copyright (C) 2009-2011 Canonical Ltd. #