aboutsummaryrefslogtreecommitdiff
path: root/menubar/main.swift
diff options
context:
space:
mode:
Diffstat (limited to 'menubar/main.swift')
-rw-r--r--menubar/main.swift24
1 files changed, 24 insertions, 0 deletions
diff --git a/menubar/main.swift b/menubar/main.swift
index 2230817..82931ab 100644
--- a/menubar/main.swift
+++ b/menubar/main.swift
@@ -236,6 +236,16 @@ final class Menubar: NSObject, NSApplicationDelegate, NSMenuDelegate {
refresh()
}
+ /// Reload the agents on an old extension: those that can now, the
+ /// others as they become idle and leave the screen (the daemon's job).
+ @objc private func reloadOutdated() {
+ log("reload agents: requested")
+ DispatchQueue.global().async {
+ let result = runReporting(dinggerBinary, ["reload-agents"])
+ log("reload agents: \(result.ok ? "" : "failed: ")\(result.output.replacingOccurrences(of: "\n", with: "; "))")
+ }
+ }
+
@objc private func restoreFromMenu(_ sender: NSMenuItem) {
restore(sessions: (sender.representedObject as? String).map { [$0] } ?? [])
}
@@ -304,6 +314,16 @@ final class Menubar: NSObject, NSApplicationDelegate, NSMenuDelegate {
menu.addItem(item)
menu.addItem(.separator())
}
+ let outdated = fetchOutdated()
+ if !outdated.isEmpty {
+ let item = NSMenuItem(title: "⟳ \(outdated.title)", action: outdated.canReload ? #selector(reloadOutdated) : nil,
+ keyEquivalent: "")
+ item.target = self
+ item.isEnabled = outdated.canReload
+ item.subtitle = outdated.detail
+ menu.addItem(item)
+ menu.addItem(.separator())
+ }
if rows.isEmpty {
let none = NSMenuItem(title: "No agents", action: nil, keyEquivalent: "")
none.isEnabled = false
@@ -443,6 +463,10 @@ if arguments.contains("--selftest") {
if arguments.contains("--print") {
let rows = fetchRows()
print("title: \(plainTitle(for: rows))")
+ let outdated = fetchOutdated()
+ if !outdated.isEmpty {
+ print("⟳ \(outdated.title)\t\(outdated.detail)\(outdated.canReload ? "" : "\t(disabled)")")
+ }
for row in rows {
print("\(row.status.symbol) \(row.status.rawValue)\t\(row.markedLabel)\t\(row.subtitle)")
}