lyswm

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 10 Imported by: 0 modules, 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 lyswm is the lys-wm IPC client: one JSON request line per connection on $LYS_WM_SOCKET, answered by one response line, and the watch stream of event lines (lys-wm's docs/ipc.md).

Index

Constants

View Source
const SocketEnv = "LYS_WM_SOCKET"

SocketEnv is the variable lys-wm exports its socket path in.

Variables

View Source
var (
	SubmapState = State[string]{EventSubmap, func(e event) *string { return e.Submap }}
	LayoutState = State[Layout]{EventLayout, func(e event) *Layout { return e.Layout }}
	LocksState  = State[Locks]{EventLocks, func(e event) *Locks { return e.Locks }}
	// ReducedMotionState is whether animations.reduced_motion is in force.
	ReducedMotionState = State[bool]{EventReducedMotion, func(e event) *bool { return e.Motion }}
)

The followable states.

View Source
var ErrNotRunning = errors.New("lys-wm: " + SocketEnv + " is not set")

ErrNotRunning is a request made while no lys-wm socket is advertised.

Functions

func Dispatch

func Dispatch(action string) error

Dispatch runs one action, as a bind would.

func FollowReducedMotion added in v0.3.1

func FollowReducedMotion(set func(bool), gone func()) (stop func(), err error)

FollowReducedMotion calls set with lys-wm's reduced motion now and at every change, and gone when the stream ends, by the returned stop or because lys-wm went away. It does nothing without a lys-wm session.

func IsRunning

func IsRunning() bool

IsRunning reports whether a lys-wm socket is advertised.

func SocketPath

func SocketPath() string

SocketPath reads the advertised socket; empty when lys-wm is not running.

Types

type EventKind

type EventKind string

EventKind names one watch event.

const (
	EventDispatch      EventKind = "dispatch"
	EventOutput        EventKind = "output"
	EventWorkspace     EventKind = "workspace"
	EventFocusedOutput EventKind = "focusedoutput"
	EventOpen          EventKind = "open"
	EventClose         EventKind = "close"
	EventMove          EventKind = "move"
	EventTitle         EventKind = "title"
	EventIcon          EventKind = "icon"
	EventUrgent        EventKind = "urgent"
	EventMinimized     EventKind = "minimized"
	EventUnresponsive  EventKind = "unresponsive"
	EventFocus         EventKind = "focus"
	EventSubmap        EventKind = "submap"
	EventLayout        EventKind = "layout"
	EventLocks         EventKind = "locks"
	EventReducedMotion EventKind = "reducedmotion"
)

The watch events.

type Layout

type Layout struct {
	Index uint32 `json:"index"`
	Name  string `json:"name"`
}

Layout is the active keyboard layout group.

type Locks

type Locks struct {
	Caps   bool `json:"caps"`
	Num    bool `json:"num"`
	Scroll bool `json:"scroll"`
}

Locks is the lock keys' state as the keymap's LEDs show it.

type Output

type Output struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Rect        Rect    `json:"rect"`
	Scale       float64 `json:"scale"`
	Workspace   int     `json:"workspace"`
	Focused     bool    `json:"focused"`
	Powered     bool    `json:"powered"`
}

Output is one entry of the outputs result.

func Outputs

func Outputs() ([]Output, error)

Outputs lists the outputs.

type Rect

type Rect struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

Rect is a rectangle in logical pixels of the output layout.

type RejectedError

type RejectedError struct {
	Request string
	Message string
}

RejectedError is a request lys-wm answered with an error.

func (*RejectedError) Error

func (e *RejectedError) Error() string

type State

type State[T any] struct {
	// contains filtered or unexported fields
}

State is one piece of lys-wm state a client can follow: the request that answers it and the event that reports its changes.

type StateWatcher

type StateWatcher[T any] struct {
	*Watcher
	// contains filtered or unexported fields
}

StateWatcher follows one State: seeded from its request once the stream is open, so an event sent in between wins, then updated by its event, and ticking after each one.

func WatchState

func WatchState[T any](s State[T]) (*StateWatcher[T], error)

WatchState opens the event stream for one State.

func (*StateWatcher[T]) Value

func (s *StateWatcher[T]) Value() T

Value is the state as last seeded or reported.

type Watcher

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

Watcher follows the watch stream and ticks after each event of the kinds it was asked for.

func Watch

func Watch(kinds ...EventKind) (*Watcher, error)

Watch opens the event stream. It ticks on the given kinds, or on every event when none is given; Ticks closes when the stream ends.

func WatchTitles added in v0.3.3

func WatchTitles(hidden func(window uint64) bool, before func(), kinds ...EventKind) (*Watcher, error)

WatchTitles is Watch on the given kinds and the title events, but for those of the windows hidden reports; before runs ahead of every tick, while the event that caused it has not been read back yet.

func (*Watcher) Close

func (w *Watcher) Close()

Close ends the stream.

func (*Watcher) Ticks

func (w *Watcher) Ticks() <-chan struct{}

Ticks fires after each followed event; it closes when the stream ends.

type Window

type Window struct {
	ID         uint64 `json:"id"`
	AppID      string `json:"app_id"`
	Title      string `json:"title"`
	Workspace  int    `json:"workspace"`
	Output     string `json:"output"`
	Rect       Rect   `json:"rect"`
	Floating   bool   `json:"floating"`
	Fullscreen bool   `json:"fullscreen"`
	Minimized  bool   `json:"minimized"`
	Urgent     bool   `json:"urgent"`
	Focused    bool   `json:"focused"`
}

Window is one mapped window.

func ActiveWindow

func ActiveWindow() (Window, bool, error)

ActiveWindow is the focused window; false when none has focus.

func Windows

func Windows() ([]Window, error)

Windows lists the mapped windows, oldest first.

type Workspace

type Workspace struct {
	ID      int    `json:"id"`
	Output  string `json:"output"`
	Windows int    `json:"windows"`
	Visible bool   `json:"visible"`
	Focused bool   `json:"focused"`
}

Workspace is one open workspace.

func Workspaces

func Workspaces() ([]Workspace, error)

Workspaces lists the open workspaces in ID order.

Directories

Path Synopsis
Package lyswmtest is a fake lys-wm on a private IPC socket, advertised through lyswm.SocketEnv for the test's duration.
Package lyswmtest is a fake lys-wm on a private IPC socket, advertised through lyswm.SocketEnv for the test's duration.

Jump to

Keyboard shortcuts

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