X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=system-status;h=3ccde7c023e1fb06017a24b5a9c3d7a627d4cc6a;hb=56c55d8e02cdd6ec67d2fe53cc03785d8876442e;hp=c11024bc5ba2c125615beb78c285f6193755c201;hpb=802e885e3e7fa3857f8bc4f54c261d5ca76f2454;p=distro-setup diff --git a/system-status b/system-status index c11024b..3ccde7c 100755 --- a/system-status +++ b/system-status @@ -143,7 +143,7 @@ write-status() { if (( ${#files[@]} )); then snaps=($(ls -1avdr "${files[@]}" 2>/dev/null |head -n1 || : )) fi - now=$(date +%s) + now=$EPOCHSECONDS maxtime=0 for s in ${snaps[@]}; do file=${s##*/} @@ -194,14 +194,21 @@ write-status() { esac fi - - if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then - emacsfiles="$(emacsclient --eval "$(cat /usr/local/bin/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')" - if [[ $emacsfiles ]]; then - chars+=("$emacsfiles") + # We do this once every 5 minutes, since this is not a grave problem. + # For formatted elisp, see /b/ds/unsaved-buffers.el + elisp='(format "%s" (-reduce-from (lambda (acc buf) (let ((bpath (buffer-file-name buf))) (if (and bpath (buffer-modified-p buf)) (cons bpath acc ) acc))) nil (buffer-list)))' + if [[ ! $last_emacs_check || $emacsfiles ]] || (( last_emacs_check < EPOCHSECONDS - 300 )); then + if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then + # i dun care if this fails + emacsfiles="$(timeout 1 emacsclient --eval "$elisp"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//' ||:)" + if [[ $emacsfiles ]]; then + chars+=("$emacsfiles") + fi fi + last_emacs_check=$EPOCHSECONDS fi + glob=(/nocow/btrfs-stale/*) if [[ -e ${glob[0]} ]]; then chars+=(STALE) @@ -212,16 +219,6 @@ write-status() { fi p $var_mail_msg | loday -1 var_mail - - tmp=(/var/local/cron-errors/mailtest-check*) - if (( ${#tmp[@]} )); then - chars+=(MAILPING) - fi - tmp=(/var/local/cron-errors/mailtest-slow*) - if (( ${#tmp[@]} )); then - chars+=(SPAMD) - fi - # early in install process, we dont have permission yet for exiqgrep. # 1100 helps allow for system restarts qlen=$(/usr/sbin/exiqgrep -o 1100 -c -b | awk '{print $1}') ||: @@ -261,7 +258,7 @@ write-status() { # shellcheck disable=SC2043 for _ in 1; do if [[ -e $f ]]; then - now=$(date +%s) + now=$EPOCHSECONDS fsec=$(stat -c%Y $f) # the / 60 makes it 0-59 seconds less strict, +1 to help make sure we # dont have any false positives.