Documentation
¶
Overview ¶
Package niri is the niri IPC client: newline-delimited JSON requests and replies over $NIRI_SOCKET in niri-ipc's JSON shapes, workspace and window snapshots, actions, and the event stream on a second socket.
Index ¶
- Constants
- Variables
- func IsRunning() bool
- func SocketPath() string
- func Subscribe() (<-chan struct{}, func(), error)
- type Conn
- func (c *Conn) Action(ctx context.Context, name string, payload any) error
- func (c *Conn) Close() error
- func (c *Conn) FocusWorkspaceDown(ctx context.Context) error
- func (c *Conn) FocusWorkspaceID(ctx context.Context, id uint64) error
- func (c *Conn) FocusWorkspacePrevious(ctx context.Context) error
- func (c *Conn) FocusWorkspaceUp(ctx context.Context) error
- func (c *Conn) KeyboardLayouts() (KeyboardLayouts, error)
- func (c *Conn) Windows() ([]Window, error)
- func (c *Conn) Workspaces() ([]Workspace, error)
- type KeyboardLayouts
- type RejectedError
- type Timestamp
- type Window
- type WindowLayout
- type Workspace
Constants ¶
const SocketEnv = "NIRI_SOCKET"
SocketEnv is niri_ipc::socket::SOCKET_PATH_ENV.
Variables ¶
var ErrNotRunning = errors.New("niri: NIRI_SOCKET is not set")
ErrNotRunning is the error when $NIRI_SOCKET is unset.
Functions ¶
func SocketPath ¶
func SocketPath() string
SocketPath reads $NIRI_SOCKET; empty when niri is not running.
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 (*Conn) Action ¶
Action dispatches one niri_ipc::Action, given as its JSON form: the variant name and its (struct) payload.
func (*Conn) FocusWorkspaceDown ¶
FocusWorkspaceDown is Action::FocusWorkspaceDown (focus:next).
func (*Conn) FocusWorkspaceID ¶
FocusWorkspaceID is Action::FocusWorkspace with a WorkspaceReferenceArg::Id reference.
func (*Conn) FocusWorkspacePrevious ¶
FocusWorkspacePrevious is Action::FocusWorkspacePrevious (focus:last).
func (*Conn) FocusWorkspaceUp ¶
FocusWorkspaceUp is Action::FocusWorkspaceUp (focus:previous).
func (*Conn) KeyboardLayouts ¶
func (c *Conn) KeyboardLayouts() (KeyboardLayouts, error)
KeyboardLayouts is Request::KeyboardLayouts.
func (*Conn) Workspaces ¶
Workspaces is Request::Workspaces.
type KeyboardLayouts ¶
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 niri replying Err(message).
func (*RejectedError) Error ¶
func (e *RejectedError) Error() string
type Timestamp ¶
Timestamp is niri_ipc::Timestamp, time since boot.
func (Timestamp) Nanoseconds ¶
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.