npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-hyprctl

v1.0.1

Published

A TypeScript/Node.js wrapper for [hyprctl](https://wiki.hyprland.org/Configuring/Using-hyprctl/), the command-line utility for controlling the Hyprland Wayland compositor.

Readme

node-hyprctl

A TypeScript/Node.js wrapper for hyprctl, the command-line utility for controlling the Hyprland Wayland compositor.

Installation

npm install node-hyprctl

Features

  • 🎯 Type-safe - Full TypeScript support with comprehensive type definitions
  • 🚀 Easy to use - Simple, intuitive API mirroring hyprctl commands
  • 📡 Event listening - Real-time event monitoring via Hyprland's socket
  • 🔄 Auto JSON parsing - Automatic JSON parsing for all supported commands

Requirements

  • Node.js (ESM support required)
  • Hyprland compositor running on your system
  • hyprctl command available in PATH

Usage

Basic Example

import Hyprctl from 'node-hyprctl'

// Get active window
const activeWindow = Hyprctl.activewindow()
console.log(`Active window: ${activeWindow.title}`)

// Get all clients (windows)
const clients = Hyprctl.clients()
console.log(`Total windows: ${clients.length}`)

// Get active workspace
const workspace = Hyprctl.activeworkspace()
console.log(`Current workspace: ${workspace.name}`)

// Dispatch commands
Hyprctl.dispatch('workspace', '1')
Hyprctl.dispatch('movetoworkspace', '2')

Event Listening

Listen to Hyprland events in real-time:

import Hyprctl from 'node-hyprctl'

const client = Hyprctl.listen()
client.on('activewindow', (activeWindow) => {
    console.log('Active window changed to:', activeWindow)
})

client.on('event', (event) => {
    console.log('Event received:', event)
})

API Reference

Window Management

activewindow(): Window

Get the currently active window.

const window = Hyprctl.activewindow()
console.log(window.title, window.class)

clients(): Array<Window>

Get all windows/clients.

const windows = Hyprctl.clients()
windows.forEach(w => console.log(w.title))

Workspace Management

activeworkspace(): Workspace

Get the currently active workspace.

workspaces(): Array<Workspace>

Get all workspaces.

workspacerules(): Array<WorkspaceRule>

Get all workspace rules.

Monitors

monitors(): Array<Monitor>

Get all monitors and their properties.

const monitors = Hyprctl.monitors()
monitors.forEach(m => {
  console.log(`${m.name}: ${m.width}x${m.height}@${m.refreshRate}Hz`)
})

System Information

version(): Version

Get Hyprland version information.

systeminfo(): string

Get detailed system information.

instances(): Array<Instance>

Get all running Hyprland instances.

Configuration

binds(): Array<Bind>

Get all keybindings.

animations(): [Array<Animation>, Array<AnimationBezier>]

Get animation settings and bezier curves.

configerrors(): Array<string>

Get configuration errors.

getoption(option: string): string

Get a specific configuration option value.

keyword(name: string, value: string): any

Set a configuration keyword dynamically.

Hyprctl.keyword('general:gaps_in', '5')

Devices

devices(): Device

Get all input devices (keyboards, mice, tablets, etc.).

cursorpos(): CursorPos

Get current cursor position.

const pos = Hyprctl.cursorpos()
console.log(`Cursor at: ${pos.x}, ${pos.y}`)

Dispatchers

dispatch(eventName: string, ...params: string[]): any | string

Execute hyprctl dispatch commands.

// Switch workspace
Hyprctl.dispatch('workspace', '1')

// Move window to workspace
Hyprctl.dispatch('movetoworkspace', '2')

// Toggle floating
Hyprctl.dispatch('togglefloating')

// Execute command
Hyprctl.dispatch('exec', 'kitty')

// Focus window
Hyprctl.dispatch('focuswindow', 'class:firefox')

Notifications

notify(options: { icon?: string, timeout?: number, color?: string, message: string }): string

Display a notification.

Hyprctl.notify({
  message: 'Hello from node-hyprctl!',
  timeout: 3000,
  color: 'rgb(ff6b6b)'
})

dismissnotify(amount?: number): string

Dismiss notifications.

Layers

layers(): Layers

Get layer information.

layouts(): Array<string>

Get available layouts.

Shortcuts

globalshortcuts(): Array<Shortcut>

Get global shortcuts.

Utilities

reload(config_only?: boolean): string

Reload Hyprland configuration.

Hyprctl.reload()        // Full reload
Hyprctl.reload(true)    // Config only

kill()

Kill the active window (use with cursor to select).

setcursor(theme: string, size: number): string

Set cursor theme and size.

switchxkblayout(device: string, cmd: string): string

Switch keyboard layout.

splash(): string

Get the current splash text.

rollinglog(): Array<string>

Get rolling log entries.

Event Listener

listen(instance_signature?: string): EventEmitter

Start listening to Hyprland events. Returns an EventEmitter that emits various Hyprland events.

const emitter = Hyprctl.listen()

TypeScript Types

The library exports comprehensive TypeScript types:

import type { 
  Window, 
  Workspace, 
  Monitor, 
  Animation,
  Bind,
  Device,
  Instance,
  Version,
  // ... and more
} from 'node-hyprctl'

Examples

Get window under cursor and close it

import Hyprctl from 'node-hyprctl'

// get cursor position
const cursorPosition = Hyprctl.cursorpos()
// get current workspace
const currentWorkspace = Hyprctl.activeworkspace()
// get all windows
const allWindows = Hyprctl.clients()

// loop through all windows to find which one is under the cursor and on the current workspace
const windowUnderCursor = allWindows.find(win => {
    const [x, y] = win.at
    const [w, h] = win.size
    return  cursorPosition.x >= x && 
            cursorPosition.x <= x + w && 
            cursorPosition.y >= y && 
            cursorPosition.y <= y + h &&
            win.workspace.id == currentWorkspace.id
})

// if no window found under cursor, exit
if(!windowUnderCursor) {
    console.log('No window found under cursor')
    process.exit(0)
}

// close the window found under cursor
Hyprctl.dispatch('closewindow', `address:${windowUnderCursor.address}`)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

ISC

Author

Dimitri Gigot

Repository

https://github.com/dimitri-gigot/node-hyprctl

Related