Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The native part is written in Rust ([napi-rs](https://napi.rs) + [x11rb](https:/
`npm install wmctrljs`

## Description
Every type and function carries JSDoc, so your editor shows what it does, its parameters and its errors.

Every function exists in two flavours: `xxxSync` runs on the calling thread, `xxx` returns a promise and runs on the libuv thread pool.

Errors are `Error` objects whose message looks like `[functionName] NO_WINDOW_FOUND (24)`.
Expand Down Expand Up @@ -185,11 +187,11 @@ function getWindowList():Promise<Window[]>

Get Window by id
```TS
function getWindowByIdSync():Window
function getWindowById():Promise<Window>
function getWindowByIdSync(win_id:number):Window
function getWindowById(win_id:number):Promise<Window>
```

Get the current active window, it is possible no window is active for now then return value can be `null`
Get the current active window. When no window has the focus, it throws `NO_WINDOW_ACTIVE_FOR_NOW (28)`
```TS
function getActiveWindowSync():Window
function getActiveWindow():Promise<Window>
Expand Down
13 changes: 10 additions & 3 deletions scripts/build-native.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Builds the addon into prebuilds/<dir>/wmctrljs.node and the X11 test fixture into fixtures/<dir>/.
// Usage: node scripts/build-native.js [--target <rust triple>[.<glibc version>]] [--dir <platform>-<arch>[-musl]] [--zig]
// --zig cross-compiles with cargo-zigbuild, which also accepts a minimum glibc suffix (x86_64-unknown-linux-gnu.2.17).
/**
* @file Builds the addon into prebuilds/<dir>/wmctrljs.node and the X11 test fixture into fixtures/<dir>/.
* Usage: node scripts/build-native.js [--target <rust triple>[.<glibc version>]] [--dir <platform>-<arch>[-musl]] [--zig]
* --zig cross-compiles with cargo-zigbuild, which also accepts a minimum glibc suffix (x86_64-unknown-linux-gnu.2.17).
*/
const { parseArgs } = require("node:util");
const { execFileSync } = require("node:child_process");
const fs = require("node:fs");
Expand All @@ -12,6 +14,11 @@ const triple = opts.target?.replace(/(\.\d+)+$/, "");
const musl = process.platform === "linux" && !process.report.getReport().header.glibcVersionRuntime;
const dir = opts.dir ?? `${process.platform}-${process.arch}${musl ? "-musl" : ""}`;
const platform = dir.split("-")[0];
/**
* Runs a command in native/, showing its output, and throws if it fails.
* @param {string} cmd
* @param {string[]} args
*/
const run = (cmd, args) => execFileSync(cmd, args, { cwd: native, stdio: "inherit" });

if (triple)
Expand Down
Loading
Loading