Skip to content

Comments

Add Configurable Status Bar Widgets#83

Open
JonathanRiche wants to merge 6 commits intorockorager:mainfrom
JonathanRiche:main
Open

Add Configurable Status Bar Widgets#83
JonathanRiche wants to merge 6 commits intorockorager:mainfrom
JonathanRiche:main

Conversation

@JonathanRiche
Copy link

@JonathanRiche JonathanRiche commented Jan 9, 2026

I used Opus after i did a review of whats needed(fed it a plan.md file on how prise widgets could work)

Here's the whole session/chat : https://opncd.ai/share/PBAUOlj1

Changes:

  1. Added new Zig APIs (src/ui.zig):
    • prise.get_battery() - Returns {percent, charging} table or nil (supports macOS via pmset and Linux via /sys/class/power_supply)
    • prise.get_hostname() - Returns system hostname
    • prise.exec() - Executes shell commands with optional timeout
  2. Created widget system in Lua (src/lua/tiling.lua):
    • Widget registry with built-in widgets: mode, git, zoom, time, battery, hostname
    • Shell command widgets for custom data (e.g., weather)
    • Per-widget refresh intervals via timers
    • Auto-hide widgets when data unavailable (e.g., battery on desktop)
    • Support for left, center, and right sections
  3. Updated documentation (docs/prise.5.md):
    • Full documentation of widget configuration
    • Examples for built-in widgets, shell widgets, and custom render functions
  4. Battery level icons: Added 10 different battery icons based on charge percentage (both charging and discharging states).
    Git Commits Made
    16ec408 feat(battery): show charge level icons based on percentage
    f4d8cb8 feat: add customizable status bar widget system
    Files Modified
  • src/ui.zig - New Lua API bindings
  • src/lua/tiling.lua - Widget system implementation
  • docs/prise.5.md - Documentation
    Example User Configuration
ui.setup({
    status_bar = {
        widgets = {
            left = { "mode", "git", "zoom" },
            center = { "hostname" },
            right = {
                { type = "shell", command = "curl -s 'wttr.in?format=1'", interval = 600000, icon = "" },
                "battery",
                "time",
            },
        },
    },
})

What Could Be Done Next

  1. Async shell execution for shell widgets to avoid blocking
  2. CPU/Memory widgets (APIs exist in plan but not implemented)
  3. Shell command caching with TTL (partially implemented in Lua, could be moved to Zig)
  4. More battery icons or color changes for low battery warning

Add a widget-based status bar system that allows users to configure
left, center, and right sections with built-in or custom widgets.

New features:
- Built-in widgets: mode, git, zoom, time, battery, hostname
- Shell command widgets for custom data (e.g., weather)
- Per-widget refresh intervals
- Auto-hide widgets when data unavailable (e.g., battery on desktop)

New Lua APIs (in ui.zig):
- prise.get_battery() - returns {percent, charging} or nil
- prise.get_hostname() - returns system hostname
- prise.exec() - execute shell commands with optional timeout

Example configuration:
  status_bar = {
    widgets = {
      left = { 'mode', 'git', 'zoom' },
      center = { 'hostname' },
      right = { 'battery', 'time' },
    },
  }

Backwards compatible: omitting widgets config uses legacy layout.
Battery widget now displays different icons based on charge level:
- Charging: 6 states from empty to full (󰂀→󰂅)
- Discharging: 10 states from low to full (󰁺→󰁹)

Icons update at 10% intervals for a visual indication of remaining charge.
Fix two issues with status bar widget rendering:

1. Right-side powerline arrows now use correct color ordering (fg=next_bg,
   bg=prev_bg) so arrows visually point into segments properly, matching
   the left-side appearance.

2. Center and right section widgets now auto-alternate between bg3/bg4
   backgrounds based on visible position. This ensures visual separation
   between adjacent widgets regardless of their order or count.
@JonathanRiche
Copy link
Author

JonathanRiche commented Jan 12, 2026

Fixed the issue with powerline symbols latest session with opencode as well : https://opncd.ai/share/zfK2yfuP

image

@JonathanRiche JonathanRiche changed the title Configurable Status Bar Widgets Add Configurable Status Bar Widgets Jan 12, 2026
Fix two issues causing the terminal to freeze when detaching:

1. Thread-safe should_quit flag: Changed from plain bool to
   std.atomic.Value(bool) with proper acquire/release semantics.
   The TTY thread reads this flag while the main thread writes it,
   and without atomics the compiler could cache the value in release
   builds, causing the TTY thread to never see the quit signal.

2. io_uring pending operations not draining: When detaching, individual
   task.cancel() calls only queue cancel SQEs to the io_uring ring -
   they don't complete synchronously. The loop waits for pending count
   to reach 0, but cancelled operations (especially recv on a closed fd)
   may never complete, causing the loop to block forever.

   Added Loop.cancelAll() which cancels all pending operations AND
   clears the pending map immediately, allowing the io loop to exit
   without waiting for cancel completions that may never arrive.
Fix two issues causing the terminal to freeze when detaching:

1. Thread-safe should_quit flag: Changed from plain bool to
   std.atomic.Value(bool) with proper acquire/release semantics.
   The TTY thread reads this flag while the main thread writes it,
   and without atomics the compiler could cache the value in release
   builds, causing the TTY thread to never see the quit signal.

2. io_uring/kqueue pending operations not draining: When detaching,
   individual task.cancel() calls only queue cancel requests - they
   don't complete synchronously. The loop waits for pending count
   to reach 0, but cancelled operations (especially recv on a closed fd)
   may never complete, causing the loop to block forever.

   Added Loop.cancelAll() to both io_uring and kqueue backends which
   cancels all pending operations AND clears the pending map immediately,
   allowing the io loop to exit without waiting for cancel completions
   that may never arrive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant