fix: kitty status bar clock — redraw via add_timer, drop bogus tab_bar_timeout

kitty has no tab_bar_timeout option (ignored with a warning), so the clock/CPU/mem
only refreshed on tab changes. tab_bar.py now registers a repeating 10s timer that
marks every tab bar dirty. Verified in Xvfb: idle window's clock ticked 16:21 -> 16:22.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mortdecai
2026-09-29 16:22:25 -04:00
parent 0c0066fef1
commit b339b3e738
3 changed files with 18 additions and 4 deletions
+2 -2
View File
@@ -114,12 +114,12 @@ All read from `/proc` (no subprocess overhead except git):
- **Colors**: Edit `_ORANGE`, `_DIM`, `_TAB_BG`, `_BAR_BG` in `tab_bar.py` - **Colors**: Edit `_ORANGE`, `_DIM`, `_TAB_BG`, `_BAR_BG` in `tab_bar.py`
- **Status items**: Add/remove cells in the `if is_last:` block in `tab_bar.py` - **Status items**: Add/remove cells in the `if is_last:` block in `tab_bar.py`
- **Refresh rate**: Change `tab_bar_timeout` in `kitty-theme.conf` (seconds) - **Refresh rate**: Change `REFRESH_SECS` in `tab_bar.py` (seconds)
- **User prefix**: The `_prefix` logic in `tab_bar.py` shows `user@` for non-seth users - **User prefix**: The `_prefix` logic in `tab_bar.py` shows `user@` for non-seth users
## Troubleshooting ## Troubleshooting
- **Icons show as boxes**: Nerd Font not installed or kitty not using it. Check `font_family` in kitty.conf. - **Icons show as boxes**: Nerd Font not installed or kitty not using it. Check `font_family` in kitty.conf.
- **Status bar not updating**: Ensure `tab_bar_timeout 60.0` is set in kitty-theme.conf. - **Status bar not updating**: `REFRESH_SECS` timer in `tab_bar.py` drives redraws (kitty has no `tab_bar_timeout` option); check `kitty` stderr for tab_bar.py errors.
- **F12 does nothing**: Ensure `allow_remote_control yes` and `listen_on unix:/tmp/kitty-{kitty_pid}` are in config. Restart kitty (not just reload). - **F12 does nothing**: Ensure `allow_remote_control yes` and `listen_on unix:/tmp/kitty-{kitty_pid}` are in config. Restart kitty (not just reload).
- **CPU shows "..."**: Normal on first draw — needs two samples to compute delta. - **CPU shows "..."**: Normal on first draw — needs two samples to compute delta.
+1 -2
View File
@@ -29,8 +29,7 @@ inactive_tab_font_style normal
tab_bar_background #0d0d0d tab_bar_background #0d0d0d
tab_bar_margin_height 2.0 0.0 tab_bar_margin_height 2.0 0.0
# Refresh tab bar for clock updates # Clock/stats refresh: timer in tab_bar.py (REFRESH_SECS) — kitty has no tab_bar_timeout option
tab_bar_timeout 60.0
# Toggle tab/status bar # Toggle tab/status bar
map f12 remote_control load-config --override tab_bar_min_tabs=999 map f12 remote_control load-config --override tab_bar_min_tabs=999
+15
View File
@@ -9,6 +9,7 @@ import os
import subprocess import subprocess
from datetime import datetime from datetime import datetime
from kitty.fast_data_types import add_timer, get_boss
from kitty.tab_bar import ( from kitty.tab_bar import (
DrawData, DrawData,
ExtraData, ExtraData,
@@ -36,6 +37,16 @@ _DIM = as_rgb(0x666666)
_TAB_BG = as_rgb(0x1A1A1A) _TAB_BG = as_rgb(0x1A1A1A)
_BAR_BG = as_rgb(0x0D0D0D) _BAR_BG = as_rgb(0x0D0D0D)
# kitty only redraws the tab bar on tab changes; this timer keeps the clock/stats live.
# ponytail: 10s = clock lags <=10s; each redraw runs git on kitty's main thread, so don't go much lower.
REFRESH_SECS = 10.0
_timer_id = None
def _refresh(_timer_id) -> None:
for tm in get_boss().all_tab_managers:
tm.mark_tab_bar_dirty()
def _get_git_branch() -> str: def _get_git_branch() -> str:
try: try:
@@ -106,6 +117,10 @@ def draw_tab(
is_last: bool, is_last: bool,
extra_data: ExtraData, extra_data: ExtraData,
) -> int: ) -> int:
global _timer_id
if _timer_id is None:
_timer_id = add_timer(_refresh, REFRESH_SECS, True)
# Build tab title # Build tab title
title = tab.title title = tab.title
if _prefix: if _prefix: