feat(04-02): add vmux i3bar subcommand with i3status wrapping

- runI3Bar: standalone mode (polling 2s) and i3status wrapping mode
- i3bar protocol v1: header + infinite JSON array on stdout
- queryVmuxBlock: daemon offline fallback in gray
- CLI: vmux i3bar auto-detects i3status in PATH
- Stdout sync after each write to avoid buffering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-03-23 21:30:30 +01:00
parent a28e8d6f1e
commit 221a4447e2
2 changed files with 137 additions and 0 deletions

13
main.go
View File

@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
@@ -141,6 +142,17 @@ func main() {
}
fmt.Println("Daemon stopped.")
case "i3bar":
if err := EnsureDaemon(sockPath); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
i3statusCmd := ""
if _, err := exec.LookPath("i3status"); err == nil {
i3statusCmd = "i3status"
}
runI3Bar(sockPath, i3statusCmd)
case "daemon":
runDaemon(sockPath)
@@ -199,6 +211,7 @@ Commands:
switch <query> Switch to the workspace of the matching session
label <id> <text> Assign a label to a session
focus <minutes> Suppress notifications for N minutes
i3bar Output i3bar JSON (use as status_command in i3 config)
stop Stop the vmux daemon
daemon Run the daemon in foreground (used internally)