summaryrefslogtreecommitdiff
path: root/.config/kitty/kitty-themes/.tools/windowid.swift
blob: 1dc95e6fd6d660bac4c2cfa20f4efc9467de9197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/swift
import Foundation
import Cocoa
import CoreGraphics.CGWindow

let windows : NSArray = CGWindowListCopyWindowInfo(CGWindowListOption.excludeDesktopElements, kCGNullWindowID)! as NSArray

let search_for_app = CommandLine.arguments[1]
let search_for_win = CommandLine.arguments[2]

for window in windows {
    let window = window as! NSDictionary
    
    let app_name = window[kCGWindowOwnerName] as! String
    let window_name = window[kCGWindowName] as? String
    
    if app_name == search_for_app && window_name == search_for_win {
        print("\(window[kCGWindowNumber]!)")
    }
}