This tmux alert system didn't work as nicely as I imagined
This commit is contained in:
@@ -1,46 +0,0 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import qs.Ui
|
||||
|
||||
BarIndicator {
|
||||
id: root
|
||||
|
||||
readonly property var tmuxService: bar?.shell?.firstPartyServiceFor("omarchy.tmux")
|
||||
|
||||
active: tmuxService ? tmuxService.waiting : false
|
||||
activeText: ""
|
||||
inactiveText: ""
|
||||
activeTooltipText: tmuxService ? tmuxService.tooltip : ""
|
||||
inactiveTooltipText: "No Terminal Waiting"
|
||||
|
||||
// The service owns the probe and its polling; the tmux hooks still reach it
|
||||
// through the indicator host's refresh broadcast, which coalesces into a
|
||||
// single run no matter how many bars relay it.
|
||||
function refresh() {
|
||||
if (root.tmuxService) root.tmuxService.refresh()
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
running: root.active
|
||||
loops: Animation.Infinite
|
||||
|
||||
PauseAnimation { duration: 2740 }
|
||||
NumberAnimation { target: root; property: "textRotation"; to: -10; duration: 50; easing.type: Easing.OutQuad }
|
||||
NumberAnimation { target: root; property: "textRotation"; to: 10; duration: 70; easing.type: Easing.InOutQuad }
|
||||
NumberAnimation { target: root; property: "textRotation"; to: -7; duration: 55; easing.type: Easing.InOutQuad }
|
||||
NumberAnimation { target: root; property: "textRotation"; to: 7; duration: 45; easing.type: Easing.InOutQuad }
|
||||
NumberAnimation { target: root; property: "textRotation"; to: 0; duration: 40; easing.type: Easing.OutQuad }
|
||||
|
||||
onStopped: root.textRotation = 0
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root.indicatorHost
|
||||
ignoreUnknownSignals: true
|
||||
function onRefreshRequested() { root.refresh() }
|
||||
}
|
||||
|
||||
onPressed: function() {
|
||||
Quickshell.execDetached(["omarchy-tmux-alert", "focus"])
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,6 @@
|
||||
"placeholderText": "Search indicators...",
|
||||
"emptyText": "No indicators",
|
||||
"options": [
|
||||
{
|
||||
"value": "TmuxAlert",
|
||||
"label": "Tmux alert",
|
||||
"description": "Tmux windows waiting for attention"
|
||||
},
|
||||
{
|
||||
"value": "Dictation",
|
||||
"label": "Dictation",
|
||||
|
||||
@@ -8,7 +8,7 @@ BarWidget {
|
||||
id: root
|
||||
moduleName: "omarchy.indicators"
|
||||
|
||||
readonly property var defaultIndicatorEntries: [ "TmuxAlert", "Dictation", "ScreenRecording", "Reminder", "NightLight", "Dnd", "StayAwake" ]
|
||||
readonly property var defaultIndicatorEntries: [ "Dictation", "ScreenRecording", "Reminder", "NightLight", "Dnd", "StayAwake" ]
|
||||
readonly property var indicatorEntries: indicatorEntriesFromSettings(settings)
|
||||
property var activeIndicatorIds: []
|
||||
property var indicatorActiveStates: ({})
|
||||
|
||||
@@ -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