This tmux alert system didn't work as nicely as I imagined
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import "TmuxModel.js" as TmuxModel
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
// Injected by omarchy-shell (the first-party service loader).
|
||||
property var shell: null
|
||||
|
||||
property int waitingCount: 0
|
||||
property string tooltip: ""
|
||||
property bool refreshPending: false
|
||||
|
||||
readonly property bool waiting: waitingCount > 0
|
||||
|
||||
// A bar surface exists per monitor and each one instantiates the indicator
|
||||
// twice (active and inactive block), so the probe lives here instead: one
|
||||
// process for the whole shell, and every indicator reads the same answer.
|
||||
function refresh() {
|
||||
if (statusProc.running) refreshPending = true
|
||||
else statusProc.running = true
|
||||
}
|
||||
|
||||
// tmux hooks cover the flag transitions, but output in a selected window
|
||||
// whose terminal sits on another workspace never fires one, and neither does
|
||||
// a window or session killed while it was still flagged.
|
||||
Timer {
|
||||
interval: 3000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: root.refresh()
|
||||
}
|
||||
|
||||
Process {
|
||||
id: statusProc
|
||||
command: ["omarchy-tmux-alert", "show", "--json"]
|
||||
stdout: StdioCollector {
|
||||
waitForEnd: true
|
||||
onStreamFinished: {
|
||||
var waiting = TmuxModel.waitingFromOutput(text)
|
||||
root.waitingCount = waiting.count
|
||||
root.tooltip = waiting.tooltip
|
||||
}
|
||||
}
|
||||
onExited: function(exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
root.waitingCount = 0
|
||||
root.tooltip = ""
|
||||
}
|
||||
|
||||
if (root.refreshPending) {
|
||||
root.refreshPending = false
|
||||
root.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: refresh()
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// Shape of `omarchy-tmux-alert show --json`. The command emits one JSON object
|
||||
// on the last line; anything tmux or a shell profile printed before it is
|
||||
// ignored so a noisy environment cannot blank the indicator.
|
||||
function waitingFromOutput(output) {
|
||||
var text = String(output === undefined || output === null ? "" : output).trim()
|
||||
if (!text) return { count: 0, tooltip: "" }
|
||||
|
||||
var lines = text.split("\n")
|
||||
var data
|
||||
try {
|
||||
data = JSON.parse(lines[lines.length - 1])
|
||||
} catch (e) {
|
||||
return { count: 0, tooltip: "" }
|
||||
}
|
||||
|
||||
if (!data || typeof data !== "object") return { count: 0, tooltip: "" }
|
||||
|
||||
var count = Number(data.count)
|
||||
return {
|
||||
count: isFinite(count) && count > 0 ? Math.floor(count) : 0,
|
||||
tooltip: data.tooltip === undefined || data.tooltip === null ? "" : String(data.tooltip)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = {
|
||||
waitingFromOutput: waitingFromOutput
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "omarchy.tmux",
|
||||
"name": "Tmux",
|
||||
"version": "1.0.0",
|
||||
"author": "Omarchy",
|
||||
"description": "Owns the set of tmux windows waiting for attention for the bar indicator.",
|
||||
"kinds": [
|
||||
"service"
|
||||
],
|
||||
"entryPoints": {
|
||||
"service": "Service.qml"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user