commit 86cfe8e2812b91a99a5cd893efafca2ab76005d6 parent e8ae16b65bc219f8dd4e45b47fb476d8327e849a Author: Sivaldo <gxixtx@xsxixvxaxlxdxoxdxaxvxix.xcxoxm> Date: Sun, 28 Jun 2026 13:13:05 -0300 feat(statusbar): adiciona sincronização e contador de e-mails não lidos Diffstat:
| M | .local/bin/statusbar | | | 30 | +++++++++++++++++++++++++++--- |
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/.local/bin/statusbar b/.local/bin/statusbar @@ -4,9 +4,11 @@ BAT_INT=30 VOL_INT=2 NET_INT=30 +MAIL_CHECK_INT=5 # Checa o disco para ver se há e-mails não lidos a cada 5s +MAIL_SYNC_INT=120 # Baixa e-mails novos da internet (mbsync) a cada 3 minutos -last_bat=0; last_vol=0; last_net=0 -s_bat=""; s_vol=""; s_net="" +last_bat=0; last_vol=0; last_net=0; last_mail_check=0; last_mail_sync=0 +s_bat=""; s_vol=""; s_net=""; s_mail="" old_status="" while true; do @@ -72,10 +74,32 @@ while true; do last_net=$now fi + # ── E-MAIL: SINCRONIZAÇÃO (INTERNET) ────────────────────────────────────── + if [ $(( now - last_mail_sync )) -ge $MAIL_SYNC_INT ]; then + + mbsync disroot-sync >/dev/null 2>&1 & + last_mail_sync=$now + fi + + # ── E-MAIL: CONTADOR (DISCO LOCAL) ──────────────────────────────────────── + if [ $(( now - last_mail_check )) -ge $MAIL_CHECK_INT ]; then + + unread_count=$(find "$HOME/.local/share/mail/INBOX/new" -type f 2>/dev/null | wc -l) + + if [ "${unread_count:-0}" -gt 0 ]; then + new_mail="📩 $unread_count" + else + new_mail="" + fi + + [ "$new_mail" != "$s_mail" ] && s_mail="$new_mail" && changed=1 + last_mail_check=$now + fi + # ── ATUALIZA O XSETROOT ─────────────────────────────────────────────────── if [ "$changed" -eq 1 ]; then status="" - for seg in "$s_bat" "$s_vol" "$s_net"; do + for seg in "$s_mail" "$s_bat" "$s_vol" "$s_net"; do [ -n "$seg" ] || continue [ -n "$status" ] && status="$status | " status="$status$seg"