Screenshots from implementers
This commit is contained in:
@@ -136,5 +136,13 @@ func capture(window id: Int?, display: Int?, crop: [String: Any]?, maxEdge: Doub
|
||||
|
||||
func captureTool(_ args: [String: Any]) async throws -> [Content] {
|
||||
let shot = try await capture(window: args.int("window"), display: args.int("display"), crop: args.dict("crop"), maxEdge: args.double("max_edge") ?? 1568)
|
||||
return [.text(shot.note), .png(shot.png)]
|
||||
guard args.bool("save") else {
|
||||
return [.text(shot.note), .png(shot.png)]
|
||||
}
|
||||
guard let dir = mediaDir else {
|
||||
throw ToolError("save needs byre's media folder, and this byre-hands has none")
|
||||
}
|
||||
let url = URL(filePath: dir).appending(path: "capture-\(UUID().uuidString.prefix(8).lowercased()).png")
|
||||
try shot.png.write(to: url)
|
||||
return [.text("\(shot.note); saved to \(url.path)"), .png(shot.png)]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user