Coder Social home page Coder Social logo

node-i3wm's Introduction

i3 window manager + Node.js

This Node.js package allows to talk with i3 window manager using IPC interface.

No dependencies, no unecessary abstractions. Just simple, modern API.

Source code is only one file with clear comments and references to excellent i3wm docs.

Install

npm install i3wm

Examples

Connect to i3

const i3wm = require('i3wm')

i3wm.Client.connect().then(client => {
  console.log('Conneceted')
})

// or

const client = await i3wm.Client.connect()

You can also use custom binary by passing additional options to connect. For example: connect({ bin: 'sway' }).

Subscribe to events

client.subscribe('window', 'workspace')

client.on('window', msg => {
  if (msg.change === 'focus') {
    console.log('Jumping around')
  }
})

Messages

// Subscribe, payload is serialized
await client.message('subscribe', ['window'])

// Get tree of all windows and workspaces
const tree = await client.message('get_tree')

// send multiple commands in one go
const [r1, r2] = await client.message('run_command', 'workspace 0; mark m')

Possible messages can be found in source code and man i3-msg.

Commands

Use command() to send a command and get unwraped reply.

// Mark current window with 'm'
await client.command('mark m')

// command() throws on incorrect input
client.command('BLAH')
  .catch(err => console.log('Incorrect: ': err.input))

Disconnect

i3wm.Client.disconnect(client)

node-i3wm's People

Contributors

nounderline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.