GlazeWM-js ·
JS library for inter-process communication (IPC) with GlazeWM. Programmatically query GlazeWM's state, subscribe to events, and run WM commands with a simple and type-safe API.
The library is packaged for CommonJS and ESM. Can be used from both NodeJS and the browser (eg. in an Electron or Tauri application).
Installation
ws needs to be additionally installed on NodeJS. The built-in Websocket API is used on browsers.
Using npm:
npm i ws
npm i glazewm
Using yarn:
yarn add ws
yarn add glazewm
Example usage
import { GwmClient } from 'glazewm';
const client = new GwmClient();
client.onConnect(() => console.log('Connected!'));
client.onDisconnect(() => console.log('Disconnected!'));
client.onError(() => console.log('Connection error!'));
const monitors = await client.getMonitors();
const workspaces = await client.getWorkspaces();
const windows = await client.getWindows();
await client.runCommand('focus workspace 1');
await client.runCommand('move left', windows[0]);
await client.subscribe(GwmEventType.FOCUS_CHANGED, (event: FocusChangedEvent) =>
console.log(event),
);
await client.subscribeMany(
[GwmEventType.WORSPACE_ACTIVATED, GwmEventType.WORSPACE_DEACTIVATED],
(event: WorkspaceActivatedEvent | WorkspaceDeactivatedEvent) =>
console.log(event),
);