← back to Ticket System
Auto-start and flash RAM Sniper above 75 percent CPU
2df0dd6984c3ae9412cbe3674713f5d89fd97603 · 2026-09-08 14:13:16 -0700 · Steve Abrams
Files touched
M desktop-bar/TicketBar.swift
Diff
commit 2df0dd6984c3ae9412cbe3674713f5d89fd97603
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue Sep 8 14:13:16 2026 -0700
Auto-start and flash RAM Sniper above 75 percent CPU
---
desktop-bar/TicketBar.swift | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/desktop-bar/TicketBar.swift b/desktop-bar/TicketBar.swift
index 2b89a901..385c488d 100644
--- a/desktop-bar/TicketBar.swift
+++ b/desktop-bar/TicketBar.swift
@@ -582,14 +582,21 @@ private final class BarController: NSObject, NSApplicationDelegate, NSWindowDele
DispatchQueue.global(qos: .utility).async { [weak self] in
guard let self else { return }
let top = self.runCommand("/usr/bin/top", ["-l", "1", "-n", "0", "-s", "0"])
+ let cpuUsed: Double
let cpuText: String
if let line = top.split(separator: "\n").first(where: { $0.contains("CPU usage") }),
let user = line.split(separator: ",").first(where: { $0.contains("user") }),
let sys = line.split(separator: ",").first(where: { $0.contains("sys") }) {
let number: (Substring) -> Double = { part in Double(part.split(separator: "%").first?.split(separator: " ").last ?? "0") ?? 0 }
- cpuText = String(format: "CPU · %.0f%%", number(user) + number(sys))
- } else { cpuText = "CPU · —" }
- let sniper = !self.runCommand("/usr/bin/pgrep", ["-f", "/Users/macstudio3/bin/ram-sniper.sh"]).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
+ cpuUsed = number(user) + number(sys)
+ cpuText = String(format: "CPU · %.0f%%", cpuUsed)
+ } else { cpuUsed = 0; cpuText = "CPU · —" }
+ var sniper = !self.runCommand("/usr/bin/pgrep", ["-f", "/Users/macstudio3/bin/ram-sniper.sh"]).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
+ if !sniper && cpuUsed >= 75 {
+ self.startRamSniper()
+ DispatchQueue.main.async { self.flashSniperButton() }
+ sniper = true
+ }
DispatchQueue.main.async {
self.cpuLabel.stringValue = cpuText
self.sniperButton.title = sniper ? "RAM Sniper · ON" : "RAM Sniper · OFF"
@@ -612,13 +619,26 @@ private final class BarController: NSObject, NSApplicationDelegate, NSWindowDele
if running {
_ = runCommand("/usr/bin/pkill", ["-TERM", "-f", "/Users/macstudio3/bin/ram-sniper.sh"])
} else {
- let task = Process(); task.executableURL = URL(fileURLWithPath: "/bin/zsh")
- task.arguments = ["-lc", "nohup /Users/macstudio3/bin/ram-sniper.sh >/tmp/ram-sniper.stdout 2>&1 &"]
- try? task.run()
+ startRamSniper()
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) { [weak self] in self?.refreshSystem() }
}
+ private func startRamSniper() {
+ let task = Process(); task.executableURL = URL(fileURLWithPath: "/bin/zsh")
+ task.arguments = ["-lc", "nohup /Users/macstudio3/bin/ram-sniper.sh >/tmp/ram-sniper.stdout 2>&1 &"]
+ try? task.run()
+ }
+
+ private func flashSniperButton() {
+ guard let button = sniperButton else { return }
+ button.layer?.backgroundColor = NSColor(calibratedRed: 0.20, green: 1.0, blue: 0.35, alpha: 0.95).cgColor
+ button.layer?.borderColor = NSColor.white.cgColor
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) { [weak self] in
+ self?.styleSniperButton(active: true)
+ }
+ }
+
// ── ◉ Terminal-dots dropdown ────────────────────────────────────────────────
// SELECTION MODEL: click-to-jump (the robust fallback). AppKit does not support
// keeping an NSMenu open across checkbox toggles without private API / custom
← d0dd2041 Use light green active sniper state
·
back to Ticket System
·
auto-data-snapshot: 2026-09-08T14:18:02 (1 data files) — dat ec951bc7 →