hyprland

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 11 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 hyprland speaks Hyprland's IPC: the command socket for queries and dispatches, and the event socket for the live stream. The wire formats match crates/wayle-hyprland: one request per connection on the command socket, answered up to an EOT byte (0x04), and newline-terminated "event>>payload" lines on the event socket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeAddress

func NormalizeAddress(address string) string

NormalizeAddress is Address::new: window addresses arrive with a 0x prefix from j/clients and without one in events; both compare equal once stripped.

func Paths

func Paths() (command, events string, err error)

Paths resolves the IPC socket paths for the running Hyprland instance. Both HYPRLAND_INSTANCE_SIGNATURE and XDG_RUNTIME_DIR must be set; without them Hyprland is not running as far as lys-shell is concerned.

Types

type Client

type Client struct {
	Address   string `json:"address"`
	Class     string `json:"class"`
	Title     string `json:"title"`
	Workspace struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"workspace"`
	Monitor  int  `json:"monitor"`
	Floating bool `json:"floating"`
	// At and Size are the window's global logical position and size.
	At   [2]int `json:"at"`
	Size [2]int `json:"size"`
	// Mapped and Hidden say whether the window is on screen at all.
	Mapped bool `json:"mapped"`
	Hidden bool `json:"hidden"`
	// FocusHistoryID is the window's place in the focus history, 0 the
	// most recently focused.
	FocusHistoryID int `json:"focusHistoryID"`
}

Client is the subset of j/clients the shell consumes.

type Connection

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

Connection is a live handle to one Hyprland instance.

func Connect

func Connect() (*Connection, error)

Connect resolves the sockets for the running instance. No connection is opened yet: requests are one-connection-per-request, and events subscribe through Events.

func ConnectTo

func ConnectTo(commandPath, eventPath string) *Connection

ConnectTo builds a connection to explicit socket paths — the test seam and the way for embedders that already resolved the paths.

func (*Connection) ActiveWindow

func (c *Connection) ActiveWindow() (Client, bool, error)

ActiveWindow is j/activewindow: the focused window, false when none is (Hyprland answers {} while a layer surface or nothing has focus).

func (*Connection) ActiveWorkspace

func (c *Connection) ActiveWorkspace() (Workspace, error)

ActiveWorkspace is j/activeworkspace: the focused monitor's workspace.

func (*Connection) Clients

func (c *Connection) Clients() ([]Client, error)

Clients lists the instance's windows (j/clients), addresses normalized.

func (*Connection) Command

func (c *Connection) Command(request string) (string, error)

Command sends one request and returns the reply up to the EOT byte.

func (*Connection) Devices

func (c *Connection) Devices() (Devices, error)

Devices queries the compositor's input devices (j/devices).

func (*Connection) Dispatch

func (c *Connection) Dispatch(command string) (string, error)

Dispatch runs a dispatcher command ("workspace 3") and returns the compositor's ack.

func (*Connection) Events

func (c *Connection) Events(ctx context.Context) (<-chan Event, error)

Events subscribes to the event socket and returns a stream of parsed events. The returned channel closes when the context is canceled or the compositor closes the socket. Lines that fail to parse are dropped, matching the Rust shell's warn-and-drop.

func (*Connection) Monitors

func (c *Connection) Monitors() ([]Monitor, error)

Monitors lists the instance's monitors (j/monitors).

func (*Connection) WorkspaceRules

func (c *Connection) WorkspaceRules() ([]WorkspaceRule, error)

WorkspaceRules lists the configured workspace rules (j/workspacerules).

func (*Connection) Workspaces

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

Workspaces lists the instance's workspaces (j/workspaces).

type Devices

type Devices struct {
	Keyboards []KeyboardDevice `json:"keyboards"`
}

Devices is j/devices: the compositor's input devices.

type Event

type Event struct {
	Kind EventKind
	// Name is the workspace or monitor name the event carries.
	Name string
	// ID is the numeric workspace/monitor id on v2 events (-1 when the
	// event carries no id).
	ID int
	// Class and Title carry the activewindow event's window data.
	Class string
	Title string
	// Address is the normalized window address of the window events
	// (urgent, activewindowv2, windowtitlev2, openwindow, closewindow,
	// movewindow/v2).
	Address string
	// Payload is the raw data after the ">>" separator.
	Payload string
}

Event is one parsed line from the event socket. Fields not named by the event kind stay at their zero values.

func ParseEvent

func ParseEvent(line string) (Event, bool)

ParseEvent splits one socket2 line into an Event. Lines without the ">>" separator fail the parse — the Rust shell warns and drops those, and so does the caller here (ok=false).

type EventKind

type EventKind string

EventKind identifies a parsed event-stream line: the wire kind as sent after the ">>" separator's left side. The named constants cover the events the shell switches on; anything else parses with its raw kind preserved, so new compositor events are never lost.

const (
	EventWorkspace      EventKind = "workspace"
	EventWorkspaceV2    EventKind = "workspacev2"
	EventFocusedMon     EventKind = "focusedmon"
	EventFocusedMonV2   EventKind = "focusedmonv2"
	EventCreateWorkspc  EventKind = "createworkspace"
	EventCreateWspcV2   EventKind = "createworkspacev2"
	EventDestroyWorkspc EventKind = "destroyworkspace"
	EventDestroyWspcV2  EventKind = "destroyworkspacev2"
	EventMoveWorkspace  EventKind = "moveworkspace"
	EventOpenWindow     EventKind = "openwindow"
	EventCloseWindow    EventKind = "closewindow"
	EventMoveWindow     EventKind = "movewindow"
	EventMoveWindowV2   EventKind = "movewindowv2"
	EventFullscreen     EventKind = "fullscreen"
	EventUrgent         EventKind = "urgent"
	EventActiveWindow   EventKind = "activewindow"
	EventActiveWindowV2 EventKind = "activewindowv2"
	EventSubmap         EventKind = "submap"

	EventMoveWorkspaceV2  EventKind = "moveworkspacev2"
	EventRenameWorkspace  EventKind = "renameworkspace"
	EventActiveSpecialV2  EventKind = "activespecialv2"
	EventMonitorAddedV2   EventKind = "monitoraddedv2"
	EventMonitorRemovedV2 EventKind = "monitorremovedv2"
	EventWindowTitleV2    EventKind = "windowtitlev2"
	EventConfigReloaded   EventKind = "configreloaded"
)

The events the shell consumes. Everything else parses to KindOther with the raw payload kept, so new compositor events are never lost.

type KeyboardDevice

type KeyboardDevice struct {
	Address      string `json:"address"`
	Name         string `json:"name"`
	Rules        string `json:"rules"`
	Model        string `json:"model"`
	Layout       string `json:"layout"`
	Variant      string `json:"variant"`
	ActiveKeymap string `json:"active_keymap"`
	Main         bool   `json:"main"`
}

KeyboardDevice is one entry of j/devices' keyboards array.

type Monitor

type Monitor struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	// ActiveWS is the workspace shown on the monitor.
	ActiveWS struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	} `json:"activeWorkspace"`
	// SpecialWS is the special workspace shown over it, ID 0 for none.
	SpecialWS struct {
		ID int `json:"id"`
	} `json:"specialWorkspace"`
	// Focused is the compositor's keyboard focus.
	Focused bool `json:"focused"`
}

Monitor is the subset of j/monitors the shell consumes.

type Workspace

type Workspace struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Monitor     string `json:"monitor"`
	MonitorID   int    `json:"monitorID"`
	Windows     int    `json:"windows"`
	Fullscreen  bool   `json:"hasfullscreen"`
	Persistent  bool   `json:"ispersistent"`
	LastWindow  string `json:"lastwindow"`
	LastTitle   string `json:"lastwindowtitle"`
	TiledLayout string `json:"tiled_layout"`
}

Workspace is one entry of j/workspaces.

type WorkspaceRule

type WorkspaceRule struct {
	WorkspaceString string  `json:"workspaceString"`
	Monitor         *string `json:"monitor"`
}

WorkspaceRule is one entry of j/workspacerules.

Jump to

Keyboard shortcuts

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