1import Cocoa
2
3// Compilation: swiftc appearance.swift -o appearance
4// Usage: ./appearance
5
6func getAccentColor() -> String {
7 if #available(macOS 10.14, *) {
8 let color = NSColor.controlAccentColor.usingColorSpace(.sRGB)
9 if let color = color {
10 let r = Int(color.redComponent * 255)
11 let g = Int(color.greenComponent * 255)
12 let b = Int(color.blueComponent * 255)
13 return String(format: "#%02X%02X%02X", r, g, b)
14 }
15 }
16 return "#007AFF" // Default macOS blue
17}
18
19func isDarkMode() -> Bool {
20 let mode = UserDefaults.standard.string(forKey: "AppleInterfaceStyle")
21 return mode == "Dark"
22}
23
24print("\(isDarkMode()) \(getAccentColor())")