window-info
window-info
is a readable stream that pushes data about windows on screen on MacOS.
It opens a Python process which uses Quartz
library to get information about windows.
yarn add -E window-info
Table of Contents
API
The default exported class is WindowInfo
which is a Readable stream.
WindowInfo
Stream
WindowInfo
is a Readable stream open in object mode with high watermark set to 0 to prevent caching of window data when receiving streams haven't processed previous data. This ensures that the newer data is always as fresh as possible. The presence of the delay value ensures that no data is written before the delay has passed since last write.
constructor(
delay?: number = 1000,
): WindowInfo
Create a new stream. The delay
argument controls how often to query data.
async { const wi = delay: 1000 let receivedData = 0 const limit = 1 wi }
winid | App Name | Window Title | pid |
---|---|---|---|
33 | SystemUIServer | AppleClockExtra | 386 |
73 | Avira | Item-0 | 501 |
60 | PostgresMenuHelper | Item-0 | 525 |
51 | Little Snitch Agent | Item-0 | 348 |
20 | SystemUIServer | AppleBluetoothExtra | 386 |
24 | SystemUIServer | AirPortExtra | 386 |
29 | SystemUIServer | AppleTextInputExtra | 386 |
37 | SystemUIServer | AppleUser | 386 |
45 | Spotlight | Item-0 | 405 |
18 | SystemUIServer | Siri | 386 |
16 | SystemUIServer | NotificationCenter | 386 |
3 | Window Server | Menubar | 177 |
4292 | Visual Studio Code | 2-fork.md — window-info | 367 |
4291 | Visual Studio Code | package.json — documentary | 367 |
4171 | Google Chrome | artdecocode/window-info: Window Info is a readable stream that pushes data about windows on screen on MacOS. | 51791 |
59 | iTunes | iTunes | 382 |
4 | Window Server | Backstop Menubar | 177 |
49 | Finder | 387 | |
41 | Dock | Desktop Picture - Sierra 2.jpg | 384 |
2 | Window Server | Desktop | 177 |
destroy(): void
Call the destroy
method to kill the underlying python process and end the stream.
Data
Type
Each data row in the read chunk contains information about open windows in form of an array.
For example, WindowInfo
can generate the following:
480 "Code" "example.js — window-info" 405 89 "Google Chrome" "Stream | Node.js v10.2.1 Documentation" 410
The type definition then is according to the position in the array.
Property | Type | Description | Example |
---|---|---|---|
winid |
number | position 0 | 480 89 |
App Name |
string | position 1 | Code Google Chrome |
Window Title |
string | position 2 | example.js — window-info Stream | Node.js v10.2.1 Documentation |
pid |
number | position 3 | 405 410 |
(c) Art Deco 2018