Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glazewm

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glazewm

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

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
80
increased by29.03%
Maintainers
1
Weekly downloads
 
Created
Source

GlazeWM-js · PRs Welcome License Discord invite

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();

// 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, active workspaces, and windows.
const monitors = await client.getMonitors();
const workspaces = await client.getWorkspaces();
const windows = await client.getWindows();

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

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

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

// Listen to multiple WM events.
await client.subscribeMany(
  [GwmEventType.WORSPACE_ACTIVATED, GwmEventType.WORSPACE_DEACTIVATED],
  (event: WorkspaceActivatedEvent | WorkspaceDeactivatedEvent) =>
    console.log(event),
);

Keywords

FAQs

Package last updated on 14 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc