diff options
Diffstat (limited to 'menubar/model.swift')
| -rw-r--r-- | menubar/model.swift | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/menubar/model.swift b/menubar/model.swift index 67a693a..e891697 100644 --- a/menubar/model.swift +++ b/menubar/model.swift @@ -27,6 +27,7 @@ func mocha(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat = 1) -> NSColo let mochaText = mocha(205, 214, 244) let mochaSubtext = mocha(166, 173, 200) let mochaOverlay = mocha(108, 112, 134) +let mochaBlue = mocha(137, 180, 250) // MARK: herdr's status vocabulary @@ -73,6 +74,8 @@ struct Row: Equatable { let session: String let window: String let since: Int + /// The pane's working directory, home as "~". + var path: String = "" var location: String { "\(session) ยท \(window)" } var waiting: Bool { status == .blocked || status == .done } @@ -162,21 +165,24 @@ func tmux(_ args: [String]) -> String? { let dinggerBinary = environment["DINGGER_BIN"] ?? (NSHomeDirectory() + "/.local/bin/dingger") +private let home = NSHomeDirectory() + /// Every agent pane, in herdr's priority order, oldest waiting first. func fetchRows() -> [Row] { let format = [ "#{pane_id}", "#{@agent}", "#{@agent_state}", "#{@dingger_since}", "#{@agent_name}", - "#{session_name}", "#{window_name}", "#{window_panes}", "#{pane_index}", + "#{session_name}", "#{window_name}", "#{window_panes}", "#{pane_index}", "#{pane_current_path}", ].joined(separator: "\t") guard let out = tmux(["list-panes", "-a", "-F", format]) else { return [] } let rows: [Row] = out.split(separator: "\n").compactMap { line in let f = line.split(separator: "\t", omittingEmptySubsequences: false).map(String.init) - guard f.count >= 9, !f[1].isEmpty else { return nil } + guard f.count >= 10, !f[1].isEmpty else { return nil } let status = Status(rawValue: f[2]) ?? .unknown guard status != .unknown else { return nil } let window = (Int(f[7]) ?? 1) > 1 ? "\(f[6]).\(f[8])" : f[6] return Row(paneId: f[0], agent: f[1], name: f[4], status: status, - session: f[5], window: window, since: Int(f[3]) ?? Int.max) + session: f[5], window: window, since: Int(f[3]) ?? Int.max, + path: f[9].hasPrefix(home) ? "~" + f[9].dropFirst(home.count) : f[9]) } return rows.sorted { if $0.status.priority != $1.status.priority { return $0.status.priority > $1.status.priority } |
