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 ¶
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 }} )
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 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" EventUnresponsive EventKind = "unresponsive" EventFocus EventKind = "focus" EventSubmap EventKind = "submap" EventLayout EventKind = "layout" EventLocks EventKind = "locks" )
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.
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"`
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.