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

wmctrl-wrapper

v1.0.0

Published

A Node.js wrapper for the wmctrl command.

Readme

wmctrl-wrapper

A Node.js wrapper for the wmctrl command, providing a simple and programmatic way to interact with window managers on Linux.

Features

  • List all windows.
  • Switch between desktops.
  • Activate, close, or move windows.
  • Resize and move windows.
  • Set window titles and states (e.g., always on top).
  • Bundled wmctrl binaries for Linux (no need to install wmctrl manually).

Installation

Install the package using npm:

npm install wmctrl-wrapper

Usage

Basic Example

const Wmctrl = require('wmctrl-wrapper');
const wmctrl = new Wmctrl();

// List all windows
wmctrl.listWindows()
  .then(windows => console.log(windows))
  .catch(err => console.error('Error:', err));

// Set a window to always on top
wmctrl.changeWindowState('0x02000003', 'add,above')
  .then(() => console.log('Window set to always on top'))
  .catch(err => console.error('Error:', err));

API

listWindows()

List all windows managed by the window manager.

wmctrl.listWindows()
  .then(windows => console.log(windows))
  .catch(err => console.error('Error:', err));

switchDesktop(desktop)

Switch to the specified desktop.

wmctrl.switchDesktop(1)
  .then(() => console.log('Switched to desktop 1'))
  .catch(err => console.error('Error:', err));

activateWindow(window)

Activate a window by switching to its desktop and raising it.

wmctrl.activateWindow('0x02000003')
  .then(() => console.log('Window activated'))
  .catch(err => console.error('Error:', err));

closeWindow(window)

Close a window gracefully.

wmctrl.closeWindow('0x02000003')
  .then(() => console.log('Window closed'))
  .catch(err => console.error('Error:', err));

moveWindowToDesktop(window, desktop)

Move a window to the specified desktop.

wmctrl.moveWindowToDesktop('0x02000003', 2)
  .then(() => console.log('Window moved to desktop 2'))
  .catch(err => console.error('Error:', err));

resizeMoveWindow(window, mvarg)

Resize and move a window.

wmctrl.resizeMoveWindow('0x02000003', '0,100,100,800,600')
  .then(() => console.log('Window resized and moved'))
  .catch(err => console.error('Error:', err));

changeWindowState(window, starg)

Change the state of a window (e.g., maximize, minimize, always on top).

wmctrl.changeWindowState('0x02000003', 'add,above')
  .then(() => console.log('Window set to always on top'))
  .catch(err => console.error('Error:', err));

setWindowName(window, name)

Set the name (long title) of a window.

wmctrl.setWindowName('0x02000003', 'New Window Name')
  .then(() => console.log('Window name updated'))
  .catch(err => console.error('Error:', err));

setWindowIconName(window, iconName)

Set the icon name (short title) of a window.

wmctrl.setWindowIconName('0x02000003', 'New Icon Name')
  .then(() => console.log('Window icon name updated'))
  .catch(err => console.error('Error:', err));

setWindowTitle(window, name)

Set both the name and icon name of a window.

wmctrl.setWindowTitle('0x02000003', 'New Title')
  .then(() => console.log('Window title updated'))
  .catch(err => console.error('Error:', err));

showDesktop(on)

Activate or deactivate the "showing the desktop" mode.

wmctrl.showDesktop(true)
  .then(() => console.log('Showing desktop'))
  .catch(err => console.error('Error:', err));

changeViewport(x, y)

Change the viewport for the current desktop.

wmctrl.changeViewport(100, 200)
  .then(() => console.log('Viewport changed'))
  .catch(err => console.error('Error:', err));

changeNumberOfDesktops(num)

Change the number of desktops.

wmctrl.changeNumberOfDesktops(4)
  .then(() => console.log('Number of desktops changed'))
  .catch(err => console.error('Error:', err));

changeDesktopGeometry(width, height)

Change the geometry of all desktops.

wmctrl.changeDesktopGeometry(1920, 1080)
  .then(() => console.log('Desktop geometry changed'))
  .catch(err => console.error('Error:', err));

Bundled Binaries

This package includes precompiled wmctrl binaries for Linux. If your platform is not supported, you can install wmctrl manually and the wrapper will use the system-installed binary.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a pull request.