← back to Ticket System
Color RAM Sniper button by state
0095349476bb5a586caefcee4c18a6febd443660 · 2026-09-08 13:59:38 -0700 · Steve Abrams
Files touched
M desktop-bar/TicketBar.swift
Diff
commit 0095349476bb5a586caefcee4c18a6febd443660
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue Sep 8 13:59:38 2026 -0700
Color RAM Sniper button by state
---
desktop-bar/TicketBar.swift | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/desktop-bar/TicketBar.swift b/desktop-bar/TicketBar.swift
index d760c82b..9d6922ae 100644
--- a/desktop-bar/TicketBar.swift
+++ b/desktop-bar/TicketBar.swift
@@ -180,6 +180,9 @@ private final class BarController: NSObject, NSApplicationDelegate, NSWindowDele
cpuLabel.widthAnchor.constraint(equalToConstant: 112).isActive = true
sniperButton = NSButton(title: "RAM Sniper · ON", target: self, action: #selector(toggleRamSniper))
sniperButton.bezelStyle = .inline
+ sniperButton.wantsLayer = true
+ sniperButton.layer?.cornerRadius = 6
+ sniperButton.layer?.borderWidth = 1
sniperButton.toolTip = "Toggle the background CPU/RAM priority sniper"
sniperButton.setContentHuggingPriority(.required, for: .horizontal)
stack = NSStackView(views: tiles + [cpuLabel, sniperButton, open, themeButton, posButton, dotsButton])
@@ -361,7 +364,7 @@ private final class BarController: NSObject, NSApplicationDelegate, NSWindowDele
: NSColor(calibratedRed: 0.08, green: 0.42, blue: 0.24, alpha: 1)
openButton?.contentTintColor = night ? .white : NSColor(calibratedWhite: 0.15, alpha: 1)
themeButton?.title = night ? "🌙" : "☀️"
- sniperButton?.contentTintColor = night ? NSColor(calibratedRed: 0.45, green: 0.90, blue: 0.65, alpha: 1) : NSColor(calibratedRed: 0.08, green: 0.42, blue: 0.24, alpha: 1)
+ styleSniperButton(active: sniperButton?.title.contains("ON") == true)
panel.invalidateShadow()
panel.contentView?.needsDisplay = true
}
@@ -590,11 +593,21 @@ private final class BarController: NSObject, NSApplicationDelegate, NSWindowDele
DispatchQueue.main.async {
self.cpuLabel.stringValue = cpuText
self.sniperButton.title = sniper ? "RAM Sniper · ON" : "RAM Sniper · OFF"
- self.sniperButton.contentTintColor = sniper ? NSColor.systemGreen : NSColor.systemOrange
+ self.styleSniperButton(active: sniper)
}
}
}
+ private func styleSniperButton(active: Bool) {
+ guard let button = sniperButton else { return }
+ let green = NSColor(calibratedRed: 0.10, green: 0.48, blue: 0.26, alpha: 0.95)
+ let orange = NSColor(calibratedRed: 0.65, green: 0.30, blue: 0.08, alpha: 0.95)
+ let tint = active ? NSColor(calibratedRed: 0.62, green: 1.0, blue: 0.75, alpha: 1) : NSColor(calibratedRed: 1.0, green: 0.78, blue: 0.42, alpha: 1)
+ button.layer?.backgroundColor = (active ? green : orange).cgColor
+ button.layer?.borderColor = tint.cgColor
+ button.contentTintColor = tint
+ }
+
@objc private func toggleRamSniper() {
let running = !runCommand("/usr/bin/pgrep", ["-f", "/Users/macstudio3/bin/ram-sniper.sh"]).trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
if running {
← 1d532474 Add CPU readout and RAM Sniper control to desktop bar
·
back to Ticket System
·
Use light green active sniper state d0dd2041 →