From 6d78fe1f44c13cfd51c2e757fc688b6b1cdf63c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 23 Sep 2026 16:38:16 +0300 Subject: [PATCH] writer: append to song_detail_last instead of in-place rewrite tail -F is offset-based: an in-place rewrite with same byte length (icon flip, position tick) leaves offset == size, so tail emits nothing and waybar shows a stale line until a longer line happens. Append-only keeps the inode and delivers every state change; trim to the last line at startup once the log passes 1 MiB. --- .config/scripts/shared/song_detail_writer.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.config/scripts/shared/song_detail_writer.sh b/.config/scripts/shared/song_detail_writer.sh index 57f6527..6dc99bd 100755 --- a/.config/scripts/shared/song_detail_writer.sh +++ b/.config/scripts/shared/song_detail_writer.sh @@ -46,9 +46,12 @@ atomic_write() { printf '%s\n' "$content" > "$tmp" && mv -f "$tmp" "$target" } -# Same inode so `tail -F` does not observe a replace/unlink. +# Append-only stream. tail -F is offset-based: an in-place rewrite whose new +# content is the SAME BYTE LENGTH as the old (icon flip, position tick) is +# invisible to it — the bar goes stale until some longer line happens by. +# Appending keeps the inode put and delivers every state change. write_output() { - printf '%s\n' "$1" > "$OUTPUT_FILE" + printf '%s\n' "$1" >> "$OUTPUT_FILE" } last_emit="__init__" @@ -81,6 +84,11 @@ pango_escape() { # File must exist so `tail -F` can attach; do not wipe a live line. [[ -e "$OUTPUT_FILE" ]] || : > "$OUTPUT_FILE" +# Append-mode log grows with every emitted line; keep only the newest once large. +if [[ -f "$OUTPUT_FILE" ]] && (( $(stat -c %s "$OUTPUT_FILE" 2>/dev/null || echo 0) > 1048576 )); then + tail -n 1 "$OUTPUT_FILE" > "$OUTPUT_FILE.trim" && mv -f "$OUTPUT_FILE.trim" "$OUTPUT_FILE" +fi + while true; do if ! command -v playerctl &>/dev/null; then emit ""