niri

package
v0.3.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package niri is the niri IPC client (wayle-niri): newline-delimited JSON requests and replies over $NIRI_SOCKET in niri-ipc's serde shapes, workspace and window snapshots, actions, and the event stream on a second socket.

Index

Constants

View Source
const SocketEnv = "NIRI_SOCKET"

SocketEnv is niri_ipc::socket::SOCKET_PATH_ENV.

Variables

View Source
var ErrNotRunning = errors.New("niri: NIRI_SOCKET is not set")

ErrNotRunning is Error::NiriNotRunning: $NIRI_SOCKET is unset.

Functions

func IsRunning

func IsRunning() bool

IsRunning reports whether a niri socket is advertised.

func SocketPath

func SocketPath() string

SocketPath reads $NIRI_SOCKET; empty when niri is not running.

func Subscribe

func Subscribe() (<-chan struct{}, func(), error)

Subscribe opens the event-stream socket, sends Request::EventStream, checks the Handled ack, and ticks once per event line; each tick is the cue to re-query. The channel closes when the stream ends; stop closes the socket.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is the persistent command socket; niri answers requests in order, so one write + one reply line runs under the mutex.

func Connect

func Connect() (*Conn, error)

Connect dials $NIRI_SOCKET.

func (*Conn) Action

func (c *Conn) Action(ctx context.Context, name string, payload any) error

Action dispatches one niri_ipc::Action, given as its serde form: the variant name and its (struct) payload.

func (*Conn) Close

func (c *Conn) Close() error

Close drops the connection.

func (*Conn) FocusWorkspaceDown

func (c *Conn) FocusWorkspaceDown(ctx context.Context) error

FocusWorkspaceDown is Action::FocusWorkspaceDown (focus:next).

func (*Conn) FocusWorkspaceID

func (c *Conn) FocusWorkspaceID(ctx context.Context, id uint64) error

FocusWorkspaceID is Action::FocusWorkspace with a WorkspaceReferenceArg::Id reference.

func (*Conn) FocusWorkspacePrevious

func (c *Conn) FocusWorkspacePrevious(ctx context.Context) error

FocusWorkspacePrevious is Action::FocusWorkspacePrevious (focus:last).

func (*Conn) FocusWorkspaceUp

func (c *Conn) FocusWorkspaceUp(ctx context.Context) error

FocusWorkspaceUp is Action::FocusWorkspaceUp (focus:previous).

func (*Conn) KeyboardLayouts

func (c *Conn) KeyboardLayouts() (KeyboardLayouts, error)

KeyboardLayouts is Request::KeyboardLayouts.

func (*Conn) Windows

func (c *Conn) Windows() ([]Window, error)

Windows is Request::Windows.

func (*Conn) Workspaces

func (c *Conn) Workspaces() ([]Workspace, error)

Workspaces is Request::Workspaces.

type KeyboardLayouts

type KeyboardLayouts struct {
	Names      []string `json:"names"`
	CurrentIdx uint8    `json:"current_idx"`
}

KeyboardLayouts is niri_ipc::KeyboardLayouts: the configured layout names and the active one's index.

func (KeyboardLayouts) Current

func (k KeyboardLayouts) Current() (string, bool)

Current is the active layout's name; false when the index points past the names.

type RejectedError

type RejectedError struct{ Message string }

RejectedError is Error::NiriRejected: niri replied Err(message).

func (*RejectedError) Error

func (e *RejectedError) Error() string

type Timestamp added in v0.3.2

type Timestamp struct {
	Secs  int64 `json:"secs"`
	Nanos int32 `json:"nanos"`
}

Timestamp is niri_ipc::Timestamp, time since boot.

func (Timestamp) Nanoseconds added in v0.3.2

func (t Timestamp) Nanoseconds() int64

Nanoseconds is the timestamp as one count.

type Window

type Window struct {
	ID             uint64       `json:"id"`
	Title          *string      `json:"title"`
	AppID          *string      `json:"app_id"`
	PID            *int32       `json:"pid"`
	WorkspaceID    *uint64      `json:"workspace_id"`
	IsFocused      bool         `json:"is_focused"`
	IsFloating     bool         `json:"is_floating"`
	IsUrgent       bool         `json:"is_urgent"`
	Layout         WindowLayout `json:"layout"`
	FocusTimestamp *Timestamp   `json:"focus_timestamp"`
}

Window is niri_ipc::Window.

type WindowLayout

type WindowLayout struct {
	// PosInScrollingLayout is the 1-based (column, tile) position;
	// nil for floating windows.
	PosInScrollingLayout *[2]int `json:"pos_in_scrolling_layout"`
}

WindowLayout is the subset of niri_ipc::WindowLayout the bar reads.

type Workspace

type Workspace struct {
	ID             uint64  `json:"id"`
	Idx            uint8   `json:"idx"`
	Name           *string `json:"name"`
	Output         *string `json:"output"`
	IsUrgent       bool    `json:"is_urgent"`
	IsActive       bool    `json:"is_active"`
	IsFocused      bool    `json:"is_focused"`
	ActiveWindowID *uint64 `json:"active_window_id"`
}

Workspace is niri_ipc::Workspace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL