# glazewm

> Library for inter-process communication (IPC) with GlazeWM.

Latest version **1.7.0** (published 2024-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install glazewm
pnpm add glazewm
yarn add glazewm
bun add glazewm
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2024-11-30 |
| First published | 2023-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 77.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Maintainers | lars-berger |
| Keywords | glazewm, windows, window manager, ipc, typescript |

## Links

- npm: https://www.npmjs.com/package/glazewm
- Repository: https://github.com/glzr-io/glazewm-js
- Homepage: https://github.com/glzr-io/glazewm-js#readme
- Issues: https://github.com/glzr-io/glazewm-js/issues
- npm.io page: https://npm.io/package/glazewm

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) 2.6.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.7.0 (latest) — 2024-11-30
- 1.1.2-next.1 (develop) — 2023-11-19
- 1.6.0 — 2024-10-04
- 1.5.2 — 2024-09-24
- 1.5.1 — 2024-09-24
- 1.5.0 — 2024-09-23
- 1.4.3 — 2024-09-11
- 1.4.2 — 2024-09-11
- 1.4.1 — 2024-07-26
- 1.4.0 — 2024-07-26
- 1.3.1 — 2024-07-26
- 1.3.0 — 2024-07-25
- 1.2.2 — 2024-07-21
- 1.2.0 — 2024-02-17
- 1.1.2 — 2023-11-19
- … 4 more at https://npm.io/package/glazewm/versions

## README

# GlazeWM-js &middot; [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/glzr-io/GlazeWM-js/pulls) [![License](https://img.shields.io/github/license/glzr-io/glazewm-js)](https://github.com/glzr-io/glazewm-js/blob/main/LICENSE.md) [![Discord invite](https://img.shields.io/discord/1041662798196908052.svg?logo=discord&colorB=7289DA)](https://discord.gg/ud6z3qjRvM)

JS library for inter-process communication (IPC) with [GlazeWM](https://github.com/glzr-io/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 (e.g. in an Electron or Tauri application).

## Installation

[ws](https://github.com/websockets/ws) needs to be additionally installed on NodeJS. The built-in [Websocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) API is used on browsers.

Using npm:

```shell
npm i ws
npm i glazewm
```

Using yarn:

```shell
yarn add ws
yarn add glazewm
```

## Example usage

```typescript
import { WmClient } from 'glazewm';

const client = new WmClient();

// Listen for connection events to the IPC server.
client.onConnect(() => console.log('Connected!'));
client.onDisconnect(() => console.log('Disconnected!'));
client.onError(() => console.log('Connection error!'));

// Get monitors, workspaces, windows, and the currently focused container.
const { monitors } = await client.queryMonitors();
const { workspaces } = await client.queryWorkspaces();
const { windows } = await client.queryWindows();
const { focused } = await client.queryFocused();

// Run a WM command.
await client.runCommand('focus --workspace 1');

// Run a WM command with a given subject container. This way we can target
// the container to operate on. If no subject container is specified, it
// defaults to the currently focused container.
await client.runCommand('move --direction left', windows[0].id);

// Listen to a WM event (e.g. whenever the focused container changes).
await client.subscribe(
  WmEventType.FOCUS_CHANGED,
  (event: FocusChangedEvent) => console.log(event),
);

// Listen to multiple WM events.
await client.subscribeMany(
  [WmEventType.WORKSPACE_ACTIVATED, WmEventType.WORKSPACE_DEACTIVATED],
  (event: WorkspaceActivatedEvent | WorkspaceDeactivatedEvent) =>
    console.log(event),
);
```

---
_Source: https://npm.io/package/glazewm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
