mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 22:34:23 -07:00
use /proc/uptime or SECONDS (bash) to get 'now' variable
Instead of using now=$(date +%s), use a function 'getnow'. That function will be defined to either use variable SECONDS (if bash), /proc/uptime if available, or fall back to bash. TODO: need to expire existing status files on startup if they have 'now' data newer than the existing now. That would cover: - system time change - new 'getnow' that used a different "now" (ie, if you moved from using date to uptime, it would go backwards.
This commit is contained in:
parent
27e28f8d18
commit
ca48252763
2 changed files with 16 additions and 2 deletions
|
@ -38,7 +38,7 @@ while true; do
|
|||
rm -f "$BYOBU_RUN_DIR/status"/* "$BYOBU_RUN_DIR/.last"/*
|
||||
exit 0
|
||||
fi
|
||||
now=$(date +%s)
|
||||
getnow; now=${_RET}
|
||||
# Re-source configuration, if changed since last run
|
||||
for i in "${BYOBU_PREFIX}/share/$PKG/status/status" "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/status" "$BYOBU_CONFIG_DIR/statusrc"; do
|
||||
[ -r "$i" ] && [ "$i" -nt "$BYOBU_RUN_DIR/status" ] && . "$i"
|
||||
|
@ -65,7 +65,7 @@ while true; do
|
|||
if [ "$path" -nt "$last" ] || [ ! -e "$last" ]; then
|
||||
. "$path"
|
||||
fi
|
||||
eval "__$i" > "$cache"
|
||||
"__$i" > "$cache"
|
||||
echo "$now" > "$last"
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -257,4 +257,18 @@ status_freq() {
|
|||
esac
|
||||
}
|
||||
|
||||
getnow() { _RET=$(date +%s); }
|
||||
if [ -n "${BASH_VERSION}" -a -n "${SECONDS}" ]; then
|
||||
getnow() {
|
||||
_RET=${SECONDS}
|
||||
}
|
||||
elif [ -r /proc/cpuinfo ]; then
|
||||
getnow() {
|
||||
# return the integer part of the first item in /proc/uptime
|
||||
local s c
|
||||
read s c < /proc/uptime
|
||||
_RET=${s%.*}
|
||||
}
|
||||
fi
|
||||
|
||||
# vi: syntax=sh ts=4 noexpandtab
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue