mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2026-02-27 12:22:43 -08:00
update
This commit is contained in:
22
.agents/skills/screenshot/scripts/macos_display_info.swift
Normal file
22
.agents/skills/screenshot/scripts/macos_display_info.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
||||
struct Response: Encodable {
|
||||
let count: Int
|
||||
let displays: [Int]
|
||||
}
|
||||
|
||||
let count = max(NSScreen.screens.count, 1)
|
||||
let displays = Array(1...count)
|
||||
|
||||
let response = Response(count: count, displays: displays)
|
||||
let encoder = JSONEncoder()
|
||||
encoder.outputFormatting = [.sortedKeys]
|
||||
|
||||
if let data = try? encoder.encode(response),
|
||||
let json = String(data: data, encoding: .utf8) {
|
||||
print(json)
|
||||
} else {
|
||||
fputs("{\"count\":\(count)}\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
Reference in New Issue
Block a user