2025-08-14 12:41:40 +02:00
2025-08-14 14:16:05 +02:00
2025-08-14 14:16:05 +02:00
2025-08-14 14:16:05 +02:00
2025-08-14 12:41:40 +02:00

Go Report Card Actions GitHub License GoDoc

i3ipc - go bindings to control sway (and possibly i3)

This is a go module which you can use to control sway, swayfx and possibly i3wm.

About

i3ipc's interprocess communication (or ipc) is the interface i3wm and sway use to receive commands from client applications such as i3-msg. It also features a publish/subscribe mechanism for notifying interested parties of window manager events.

i3ipc is a go module for controlling the window manager. This project is intended to be useful for general scripting, and for applications that interact with the window manager like status line generators, notification daemons, and window pagers.

For details on how to use the library, see the reference documentation.

Example usage

In this example we retrieve the current focused window:

package main

import (
        "fmt"
        "log"

        "github.com/tlinden/i3ipc"
)

func main() {
        ipc := i3ipc.NewI3ipc()

        err := ipc.Connect()
        if err != nil {
                log.Fatal(err)
        }
        defer ipc.Close()

        tree, err := ipc.GetTree()
        if err != nil {
                log.Fatal(err)
        }

        focused := tree.FindFocused()

        if focused != nil {
                fmt.Printf("focused node: %s\n  id: %d\n  Geometry: %dx%d\n",
                        focused.Name, focused.Id, focused.Geometry.Width,
                        focused.Geometry.Height)
        }
}

Also take a look into the _examples folder for more examples.

You may take a look at the tool swaycycle which is using this module.

Installation

Execute this to add the module to your project:

go get github.com/tlinden/i3ipc

Acknowledgements

A couple of ideas have been taken from the i3ipc python module, although this one is not just a port of it and has been written from scratch.

Getting help

Although I'm happy to hear from i3ipc users in private email, that's the best way for me to forget to do something.

In order to report a bug, unexpected behavior, feature requests or to submit a patch, please open an issue on github: https://github.com/TLINDEN/i3ipc/issues.

This software is licensed under the GNU GENERAL PUBLIC LICENSE version 3.

Authors

T.v.Dein

Project homepage

https://github.com/TLINDEN/i3ipc

Licensed under the GNU GENERAL PUBLIC LICENSE version 3.

Author

T.v.Dein

Description
No description provided
Readme GPL-3.0 104 KiB
Languages
Go 100%