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
- Variables
- func Dispatch(action string) error
- func FollowReducedMotion(set func(bool), gone func()) (stop func(), err error)
- func IsRunning() bool
- func SocketPath() string
- func ToplevelIdentifier(id uint64) string
- type EventKind
- type Layout
- type Locks
- type Output
- type Rect
- type RejectedError
- type State
- type StateWatcher
- type Watcher
- type Window
- type Workspace
Constants ¶
const SocketEnv = "LYS_WM_SOCKET"
SocketEnv is the variable lys-wm exports its socket path in.
Variables ¶
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.
var ErrNotRunning = errors.New("lys-wm: " + SocketEnv + " is not set")
ErrNotRunning is a request made while no lys-wm socket is advertised.
Functions ¶
func FollowReducedMotion ¶ added in v0.3.1
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 SocketPath ¶
func SocketPath() string
SocketPath reads the advertised socket; empty when lys-wm is not running.
func ToplevelIdentifier ¶ added in v0.3.10
ToplevelIdentifier is the ext-foreign-toplevel-list identifier lys-wm gives the window with IPC id id.
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 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.
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 ¶
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 ¶
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 ¶
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.
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 ¶
ActiveWindow is the focused window; false when none has focus.