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 = i3wmClient // or const client = await i3wmClient
You can also use custom binary by passing additional options to connect
. For example: connect({ bin: 'sway' })
.
Subscribe to events
client client
Messages
// Subscribe, payload is serializedawait client // Get tree of all windows and workspacesconst tree = await client // send multiple commands in one goconst r1 r2 = await client
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() throws on incorrect inputclient
Disconnect
i3wmClient