Files
omarchycn/shell/plugins/bar/indicators/TmuxAlert.qml
T
David Heinemeier HanssonandClaude Fable 5 5b130c1063 Make tmux alert parsing and focus more robust
Session names can contain pipes but never colons, so split fields on
colons instead. Remember refreshes that arrive while the indicator is
already polling, and jump to the most recently used tmux client rather
than an arbitrary one.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 17:40:47 -07:00

71 lines
1.5 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Io
import qs.Ui
BarIndicator {
id: root
property int waitingCount: 0
property string tooltip: ""
property bool refreshPending: false
active: waitingCount > 0
activeText: "󰆍"
inactiveText: "󰆍"
activeTooltipText: tooltip
inactiveTooltipText: "No terminal is waiting"
function refresh() {
if (statusProc.running) refreshPending = true
else statusProc.running = true
}
function update(raw) {
var data = extractData(raw)
waitingCount = Number(data.count || 0)
tooltip = String(data.tooltip || "")
}
Component.onCompleted: refresh()
// Alerts can also disappear without a hook, such as when the window or its
// session is killed while still flagged.
Timer {
interval: 5000
running: root.active
repeat: true
onTriggered: root.refresh()
}
Connections {
target: root.indicatorHost
ignoreUnknownSignals: true
function onRefreshRequested() { root.refresh() }
}
Process {
id: statusProc
command: ["omarchy-tmux-alert", "show", "--json"]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: root.update(text)
}
onExited: function(exitCode) {
if (exitCode !== 0) {
root.waitingCount = 0
root.tooltip = ""
}
if (root.refreshPending) {
root.refreshPending = false
root.refresh()
}
}
}
onPressed: function() {
Quickshell.execDetached(["omarchy-tmux-alert", "focus"])
}
}