2019-04-13 00:31:58 +02:00
|
|
|
package sway
|
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
import "encoding/json"
|
2019-04-13 00:31:58 +02:00
|
|
|
|
|
|
|
type Rect struct {
|
2019-04-14 08:13:12 +02:00
|
|
|
X int64 `json:"x,omitempty"`
|
|
|
|
Y int64 `json:"y,omitempty"`
|
|
|
|
Width int64 `json:"width,omitempty"`
|
|
|
|
Height int64 `json:"height,omitempty"`
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type WindowProperties struct {
|
2019-04-14 08:13:12 +02:00
|
|
|
Title string `json:"title,omitempty"`
|
|
|
|
Class string `json:"class,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
Instance string `json:"instance,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
Role string `json:"window_role,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
Type string `json:"window_type,omitempty"`
|
|
|
|
TransientFor *int64 `json:"transient_for,omitempty"`
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
|
|
|
|
2022-02-12 17:07:56 +01:00
|
|
|
type IdleInhibitors struct {
|
|
|
|
Application string `json:"application,omitempty"`
|
|
|
|
User string `json:"user,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Node types
|
|
|
|
type NodeType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
NodeRoot NodeType = "root"
|
|
|
|
NodeOutput NodeType = "output"
|
|
|
|
NodeWorkspace NodeType = "workspace"
|
|
|
|
NodeCon NodeType = "con"
|
|
|
|
NodeFloatingCon NodeType = "floating_con"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Node layouts
|
|
|
|
type Layout string
|
|
|
|
|
|
|
|
const (
|
|
|
|
LayoutOutput Layout = "output"
|
|
|
|
LayoutSplitH Layout = "splith"
|
|
|
|
LayoutSplitV Layout = "splitv"
|
|
|
|
LayoutStacked Layout = "stacked"
|
|
|
|
LayoutTabbed Layout = "tabbed"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Border types
|
|
|
|
type Border string
|
|
|
|
|
|
|
|
const (
|
|
|
|
BorderNormal Border = "normal"
|
|
|
|
BorderNone Border = "none"
|
|
|
|
BorderPixel Border = "pixel"
|
|
|
|
BorderCsd Border = "csd"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Fullscreen modes
|
|
|
|
type FullscreenMode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
FullscreenNone FullscreenMode = 0
|
|
|
|
FullscreenOutput FullscreenMode = 1
|
|
|
|
FullscreenGlobal FullscreenMode = 2
|
|
|
|
)
|
|
|
|
|
|
|
|
// workspace event types
|
|
|
|
type WorkspaceEventChange string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// The workspace is empty and is being destroyed since it is not visible
|
|
|
|
WorkspaceEmpty WorkspaceEventChange = "empty"
|
|
|
|
// The workspace was created
|
|
|
|
WorkspaceInit WorkspaceEventChange = "init"
|
|
|
|
// The workspace was focused. See the old property for the previous focus
|
|
|
|
WorkspaceFocus WorkspaceEventChange = "focus"
|
|
|
|
// The workspace was moved to a different output
|
|
|
|
WorkspaceMove WorkspaceEventChange = "move"
|
|
|
|
// The configuration file has been reloaded
|
|
|
|
WorkspaceReload WorkspaceEventChange = "reload"
|
|
|
|
// The workspace was renamed
|
|
|
|
WorkspaceRename WorkspaceEventChange = "rename"
|
|
|
|
// A view on the workspace has had their urgency hint set or all hints for views on the workspace have been cleared
|
|
|
|
WorkspaceUrgent WorkspaceEventChange = "urgent"
|
|
|
|
)
|
|
|
|
|
|
|
|
// window event types
|
|
|
|
type WindowEventChange string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// The view was closed
|
|
|
|
WindowClose WindowEventChange = "close"
|
|
|
|
// The view has become floating or is no longer floating
|
|
|
|
WindowFloating WindowEventChange = "floating"
|
|
|
|
// The view was focused
|
|
|
|
WindowFocus WindowEventChange = "focus"
|
|
|
|
// The view's fullscreen mode has changed
|
|
|
|
WindowFullscreen WindowEventChange = "fullscreen_mode"
|
|
|
|
// A mark has been added or removed from the view
|
|
|
|
WindowMark WindowEventChange = "mark"
|
|
|
|
// The view has been reparented in the tree
|
|
|
|
WindowMove WindowEventChange = "move"
|
|
|
|
// The view was created
|
|
|
|
WindowNew WindowEventChange = "new"
|
|
|
|
// The view's title has changed
|
|
|
|
WindowTitle WindowEventChange = "title"
|
|
|
|
// The view's urgency hint has changed status
|
|
|
|
WindowUrgent WindowEventChange = "urgent"
|
|
|
|
)
|
|
|
|
|
2019-04-13 00:31:58 +02:00
|
|
|
type Node struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The internal unique ID for this node
|
2019-04-14 08:13:12 +02:00
|
|
|
ID int64 `json:"id,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The name of the node such as the output name or window title.
|
|
|
|
// For the scratchpad, this will be "__i3_scratch" for compatibility with i3.
|
2019-04-14 08:13:12 +02:00
|
|
|
Name string `json:"name,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The node type.
|
|
|
|
// It can be "root", "output", "workspace", "con", or "floating_con"
|
2022-02-12 17:07:56 +01:00
|
|
|
Type NodeType `json:"type,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The border style for the node.
|
|
|
|
// It can be "normal", "none", "pixel", or "csd"
|
2022-02-12 17:07:56 +01:00
|
|
|
Border Border `json:"border,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Number of pixels used for the border width
|
2019-04-14 08:13:12 +02:00
|
|
|
CurrentBorderWidth int64 `json:"current_border_width,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The node's layout.
|
|
|
|
// It can either be "splith", "splitv", "stacked", "tabbed", or "output"
|
2022-02-12 17:07:56 +01:00
|
|
|
Layout Layout `json:"layout,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The node's orientation.
|
|
|
|
// It can be "vertical", "horizontal", or "none"
|
|
|
|
Orientation string `json:"orientation,omitempty"`
|
|
|
|
|
|
|
|
// The percentage of the node's parent that it takes up or null for the root
|
|
|
|
// and other special nodes such as the scratchpad
|
2019-04-14 08:13:12 +02:00
|
|
|
Percent *float64 `json:"percent,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The absolute geometry of the node. The window decorations are excluded
|
|
|
|
// from this, but borders are included.
|
2019-04-14 08:13:12 +02:00
|
|
|
Rect Rect `json:"rect,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The geometry of the contents inside the node. The window decorations are
|
|
|
|
// excluded from this calculation, but borders are included.
|
2019-04-14 08:13:12 +02:00
|
|
|
WindowRect Rect `json:"window_rect,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The geometry of the decorations for the node relative to the parent node
|
2019-04-14 08:13:12 +02:00
|
|
|
DecoRect Rect `json:"deco_rect,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The natural geometry of the contents if it were to size itself
|
2019-04-14 08:13:12 +02:00
|
|
|
Geometry Rect `json:"geometry,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether the node or any of its descendants has the urgent hint set.
|
|
|
|
// Note: This may not exist when compiled without xwayland support
|
2019-04-14 08:13:12 +02:00
|
|
|
Urgent *bool `json:"urgent,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether the node is sticky (shows on all workspaces)
|
|
|
|
Sticky bool `json:"sticky,omitempty"`
|
|
|
|
|
|
|
|
// List of marks assigned to the node
|
2022-02-12 17:07:56 +01:00
|
|
|
Marks []string `json:"marks,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether the node is currently focused by the default seat (seat0)
|
2019-04-14 08:13:12 +02:00
|
|
|
Focused bool `json:"focused,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Array of child node IDs in the current focus order
|
2019-04-14 08:13:12 +02:00
|
|
|
Focus []int64 `json:"focus,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The tiling children nodes for the node
|
2019-04-14 08:13:12 +02:00
|
|
|
Nodes []*Node `json:"nodes,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The floating children nodes for the node
|
2019-04-14 08:13:12 +02:00
|
|
|
FloatingNodes []*Node `json:"floating_nodes,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only workspaces) A string representation of the layout of the workspace
|
|
|
|
// that can be used as an aid in submitting reproduction steps for bug reports
|
2019-04-14 08:13:12 +02:00
|
|
|
Representation *string `json:"representation,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only containers and views) The fullscreen mode of the node.
|
2022-02-12 17:07:56 +01:00
|
|
|
// 0 means none, 1 means full output, and 2 means global fullscreen
|
|
|
|
FullscreenMode FullscreenMode `json:"fullscreen_mode,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only views) For an xdg-shell view, the name of the application, if set.
|
|
|
|
// Otherwise, null
|
2019-04-14 08:13:12 +02:00
|
|
|
AppID *string `json:"app_id,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only views) The PID of the application that owns the view
|
2019-04-14 08:13:12 +02:00
|
|
|
PID *uint32 `json:"pid,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only views) Whether the node is visible
|
|
|
|
Visible *bool `json:"visible,omitempty"`
|
|
|
|
|
|
|
|
// (Only views) The shell of the view, such as "xdg_shell" or "xwayland"
|
|
|
|
Shell *string `json:"shell,omitempty"`
|
|
|
|
|
|
|
|
// (Only views) Whether the view is inhibiting the idle state
|
|
|
|
InhibitIdle *bool `json:"inhibit_idle,omitempty"`
|
|
|
|
|
|
|
|
// (Only views) An object containing the state of the application and user
|
|
|
|
// idle inhibitors. "application" can be "enabled" or "none".
|
|
|
|
// "user" can be "focus", "fullscreen", "open", "visible" or "none".
|
2022-02-12 17:07:56 +01:00
|
|
|
IdleInhibitors IdleInhibitors `json:"idle_inhibitors,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only xwayland views) The X11 window ID for the xwayland view
|
2019-04-14 08:13:12 +02:00
|
|
|
Window *int64 `json:"window,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// (Only xwayland views) An object containing the "title", "class", "instance",
|
|
|
|
// "window_role", "window_type", and "transient_for" for the view
|
2019-04-14 08:13:12 +02:00
|
|
|
WindowProperties *WindowProperties `json:"window_properties,omitempty"`
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// FocusedNode traverses the node tree and returns the focused node
|
2019-04-13 00:31:58 +02:00
|
|
|
func (n *Node) FocusedNode() *Node {
|
2022-02-11 20:11:31 +01:00
|
|
|
focusedNode := n.TraverseNodes(func(n *Node) bool {
|
|
|
|
return n.Focused
|
|
|
|
})
|
|
|
|
return focusedNode
|
|
|
|
}
|
|
|
|
|
|
|
|
// TraverseNodes returns the first Node matching the predicate
|
|
|
|
func (n *Node) TraverseNodes(predicate func(*Node) bool) *Node {
|
2019-04-13 00:31:58 +02:00
|
|
|
queue := []*Node{n}
|
|
|
|
for len(queue) > 0 {
|
|
|
|
n = queue[0]
|
|
|
|
queue = queue[1:]
|
|
|
|
|
|
|
|
if n == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2022-02-11 20:11:31 +01:00
|
|
|
if predicate(n) {
|
2019-04-13 00:31:58 +02:00
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
queue = append(queue, n.Nodes...)
|
|
|
|
queue = append(queue, n.FloatingNodes...)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// WorkspaceEvent is sent whenever a change involving a workspace occurs
|
2019-04-14 08:13:12 +02:00
|
|
|
type WorkspaceEvent struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// The type of change that occurred
|
|
|
|
// The following change types are currently available:
|
|
|
|
// init: the workspace was created
|
|
|
|
// empty: the workspace is empty and is being destroyed since it is not
|
|
|
|
// visible
|
|
|
|
// focus: the workspace was focused. See the old property for the previous
|
|
|
|
// focus
|
|
|
|
// move: the workspace was moved to a different output
|
|
|
|
// rename: the workspace was renamed
|
|
|
|
// urgent: a view on the workspace has had their urgency hint set or all
|
|
|
|
// urgency hints for views on the workspace have been cleared
|
|
|
|
// reload: The configuration file has been reloaded
|
2022-02-12 17:07:56 +01:00
|
|
|
Change WorkspaceEventChange `json:"change,omitempty"`
|
2019-04-15 04:21:31 +02:00
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// An object representing the workspace effected or null for "reload" changes
|
2019-04-15 04:21:31 +02:00
|
|
|
Current *Node `json:"current,omitempty"`
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// For a "focus" change, this is will be an object representing the workspace
|
2019-04-15 04:21:31 +02:00
|
|
|
// being switched from. Otherwise, it is null
|
|
|
|
Old *Node `json:"old,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
}
|
2019-04-13 00:31:58 +02:00
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// WindowEvent is sent whenever a change involving a view occurs
|
2019-04-14 08:13:12 +02:00
|
|
|
type WindowEvent struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// The type of change that occurred
|
|
|
|
//
|
|
|
|
// The following change types are currently available:
|
|
|
|
// new: The view was created
|
|
|
|
// close: The view was closed
|
|
|
|
// focus: The view was focused
|
|
|
|
// title: The view's title has changed
|
|
|
|
// fullscreen_mode: The view's fullscreen mode has changed
|
|
|
|
// move: The view has been reparented in the tree
|
|
|
|
// floating: The view has become floating or is no longer floating
|
|
|
|
// urgent: The view's urgency hint has changed status
|
|
|
|
// mark: A mark has been added or removed from the view
|
2022-02-12 17:07:56 +01:00
|
|
|
Change WindowEventChange `json:"change,omitempty"`
|
2019-04-15 04:21:31 +02:00
|
|
|
|
|
|
|
// An object representing the view effected
|
|
|
|
Container Node `json:"container,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
}
|
2019-04-13 00:31:58 +02:00
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// ShutdownEvent is sent whenever the IPC is shutting down
|
2019-04-14 08:13:12 +02:00
|
|
|
type ShutdownEvent struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// A string containing the reason for the shutdown. Currently, the only
|
2021-09-23 16:20:55 +02:00
|
|
|
// value for change is "exit", which is issued when sway is exiting.
|
2019-04-14 08:13:12 +02:00
|
|
|
Change string `json:"change,omitempty"`
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
type RunCommandReply struct {
|
|
|
|
Success bool `json:"success,omitempty"`
|
|
|
|
Error string `json:"error,omitempty"`
|
|
|
|
}
|
2019-04-13 00:31:58 +02:00
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
type Workspace struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The workspace number or -1 for workspaces that do not start with a number
|
2019-04-14 08:13:12 +02:00
|
|
|
Num int64 `json:"num,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The name of the workspace
|
2019-04-14 08:13:12 +02:00
|
|
|
Name string `json:"name,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether the workspace is currently visible on any output
|
2019-04-14 08:13:12 +02:00
|
|
|
Visible bool `json:"visible,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether the workspace is currently focused by the default seat (seat0)
|
2019-04-14 08:13:12 +02:00
|
|
|
Focused bool `json:"focused,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether a view on the workspace has the urgent flag set
|
2019-04-14 08:13:12 +02:00
|
|
|
Urgent bool `json:"urgent,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The bounds of the workspace. It consists of x, y, width, and height
|
2019-04-14 08:13:12 +02:00
|
|
|
Rect Rect `json:"rect,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The name of the output that the workspace is on
|
2019-04-14 08:13:12 +02:00
|
|
|
Output string `json:"output,omitempty"`
|
|
|
|
}
|
2019-04-13 00:31:58 +02:00
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
type Refresh float64
|
|
|
|
|
|
|
|
func (r *Refresh) UnmarshalJSON(raw []byte) error {
|
|
|
|
var n int64
|
|
|
|
if err := json.Unmarshal(raw, &n); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
*r = Refresh(float64(n) / 1000)
|
|
|
|
return nil
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
type OutputMode struct {
|
|
|
|
Width int64 `json:"width,omitempty"`
|
|
|
|
Height int64 `json:"height,omitempty"`
|
|
|
|
Refresh Refresh `json:"refresh,omitempty"`
|
|
|
|
}
|
2019-04-13 00:31:58 +02:00
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
type Output struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The name of the output. On DRM, this is the connector
|
2019-04-14 08:13:12 +02:00
|
|
|
Name string `json:"name,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The make of the output
|
2019-04-14 08:13:12 +02:00
|
|
|
Make string `json:"make,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The model of the output
|
2019-04-14 08:13:12 +02:00
|
|
|
Model string `json:"model,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The output's serial number as a hexadecimal string
|
2019-04-14 08:13:12 +02:00
|
|
|
Serial string `json:"serial,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether this output is active/enabled
|
2019-04-14 08:13:12 +02:00
|
|
|
Active bool `json:"active,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether this output is on/off (via DPMS)
|
|
|
|
DPMS bool `json:"dpms,omitempty"`
|
|
|
|
|
|
|
|
// For i3 compatibility, this will be false. It does not make sense in Wayland
|
2019-04-14 08:13:12 +02:00
|
|
|
Primary bool `json:"primary,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The scale currently in use on the output or -1 for disabled outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
Scale float64 `json:"scale,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The subpixel hinting current in use on the output.
|
|
|
|
// This can be "rgb", "bgr", "vrgb", "vbgr", or "none"
|
|
|
|
SubpixelHinting string `json:"subpixel_hinting,omitempty"`
|
|
|
|
|
|
|
|
// The transform currently in use for the output. This can be "normal", "90",
|
|
|
|
// "180", "270", "flipped-90", "flipped-180", or "flipped-270"
|
2019-04-14 08:13:12 +02:00
|
|
|
Transform string `json:"transform,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The workspace currently visible on the output or null for disabled outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
CurrentWorkspace string `json:"current_workspace,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// An array of supported mode objects.
|
|
|
|
// Each object contains "width", "height", and "refresh"
|
2019-04-14 08:13:12 +02:00
|
|
|
Modes []OutputMode `json:"modes,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// An object representing the current mode containing "width", "height", and "refresh"
|
2019-04-14 08:13:12 +02:00
|
|
|
CurrentMode OutputMode `json:"current_mode,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The bounds for the output consisting of "x", "y", "width", and "height"
|
2019-04-14 08:13:12 +02:00
|
|
|
Rect Rect `json:"rect,omitempty"`
|
|
|
|
}
|
2019-04-13 00:31:58 +02:00
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
type BarConfigGaps struct {
|
|
|
|
Top int64 `json:"top,omitempty"`
|
|
|
|
Right int64 `json:"right,omitempty"`
|
|
|
|
Bottom int64 `json:"bottom,omitempty"`
|
|
|
|
Left int64 `json:"left,omitempty"`
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// The colors object contains strings which are all #RRGGBBAA representation
|
|
|
|
// of the color
|
2019-04-14 08:13:12 +02:00
|
|
|
type BarConfigColors struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The color to use for the bar background on unfocused outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
Background string `json:"background,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the status line text on unfocused outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
Statusline string `json:"statusline,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the separator text on unfocused outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
Separator string `json:"separator,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the background of the bar on the focused output
|
2019-04-14 08:13:12 +02:00
|
|
|
FocusedBackground string `json:"focused_background,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the status line text on the focused output
|
2019-04-14 08:13:12 +02:00
|
|
|
FocusedStatusline string `json:"focused_statusline,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the separator text on the focused output
|
2019-04-14 08:13:12 +02:00
|
|
|
FocusedSeparator string `json:"focused_separator,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the text of the focused workspace button
|
2019-04-14 08:13:12 +02:00
|
|
|
FocusedWorkspaceText string `json:"focused_workspace_text,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the background of the focused workspace button
|
2019-04-14 08:13:12 +02:00
|
|
|
FocusedWorkspaceBG string `json:"focused_workspace_bg,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the border of the focused workspace button
|
2019-04-14 08:13:12 +02:00
|
|
|
FocusedWorkspaceBorder string `json:"focused_workspace_border,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the text of the workspace buttons for the visible
|
|
|
|
// workspaces on unfocused outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
ActiveWorkspaceText string `json:"active_workspace_text,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the background of the workspace buttons for the
|
|
|
|
// visible workspaces on unfocused outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
ActiveWorkspaceBG string `json:"active_workspace_bg,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the border of the workspace buttons for the visible
|
|
|
|
// workspaces on unfocused outputs
|
2019-04-14 08:13:12 +02:00
|
|
|
ActiveWorkspaceBorder string `json:"active_workspace_border,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the text of the workspace buttons for workspaces
|
|
|
|
// that are not visible
|
2019-04-14 08:13:12 +02:00
|
|
|
InactiveWorkspaceText string `json:"inactive_workspace_text,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the background of the workspace buttons for workspaces
|
|
|
|
// that are not visible
|
2019-04-14 08:13:12 +02:00
|
|
|
InactiveWorkspaceBG string `json:"inactive_workspace_bg,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the border of the workspace buttons for workspaces
|
|
|
|
// that are not visible
|
2019-04-14 08:13:12 +02:00
|
|
|
InactiveWorkspaceBorder string `json:"inactive_workspace_border,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the text of the workspace buttons for workspaces
|
|
|
|
// that contain an urgent view
|
2019-04-14 08:13:12 +02:00
|
|
|
UrgentWorkspaceText string `json:"urgent_workspace_text,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the background of the workspace buttons for workspaces
|
|
|
|
// that contain an urgent view
|
2019-04-14 08:13:12 +02:00
|
|
|
UrgentWorkspaceBG string `json:"urgent_workspace_bg,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the border of the workspace buttons for workspaces
|
|
|
|
// that contain an urgent view
|
2019-04-14 08:13:12 +02:00
|
|
|
UrgentWorkspaceBorder string `json:"urgent_workspace_border,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the text of the binding mode indicator
|
2019-04-14 08:13:12 +02:00
|
|
|
BindingModeText string `json:"binding_mode_text,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the background of the binding mode indicator
|
2019-04-14 08:13:12 +02:00
|
|
|
BindingModeBG string `json:"binding_mode_bg,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The color to use for the border of the binding mode indicator
|
2019-04-14 08:13:12 +02:00
|
|
|
BindingModeBorder string `json:"binding_mode_border,omitempty"`
|
|
|
|
}
|
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// BarConfigUpdateEvent is sent whenever a config for a bar changes. The event
|
|
|
|
// is identical to that of GET_BAR_CONFIG when a bar ID is given as a payload.
|
2019-04-14 08:13:12 +02:00
|
|
|
type BarConfigUpdateEvent = BarConfig
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// Represents the configuration for the bar with the bar ID sent as the payload
|
2019-04-14 08:13:12 +02:00
|
|
|
type BarConfig struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The bar ID
|
2019-04-15 04:21:31 +02:00
|
|
|
ID string `json:"id,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The mode for the bar. It can be "dock", "hide", or "invisible"
|
2019-04-14 08:13:12 +02:00
|
|
|
Mode string `json:"mode,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The bar's position. It can currently either be "bottom" or "top"
|
2019-04-14 08:13:12 +02:00
|
|
|
Position string `json:"position,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The command which should be run to generate the status line
|
2019-04-14 08:13:12 +02:00
|
|
|
StatusCommand string `json:"status_command,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The font to use for the text on the bar
|
2019-04-14 08:13:12 +02:00
|
|
|
Font string `json:"font,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Whether to display the workspace buttons on the bar
|
2019-04-14 08:13:12 +02:00
|
|
|
WorkspaceButtons bool `json:"workspace_buttons,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Minimum width in px for the workspace buttons on the bar
|
|
|
|
WorkspaceMinWidth int64 `json:"workspace_min_width,omitempty"`
|
|
|
|
|
|
|
|
// Whether to display the current binding mode on the bar
|
2019-04-14 08:13:12 +02:00
|
|
|
BindingModeIndicator bool `json:"binding_mode_indicator,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// For i3 compatibility, this will be the boolean value "false".
|
2019-04-14 08:13:12 +02:00
|
|
|
Verbose bool `json:"verbose,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// An object containing the #RRGGBBAA colors to use for the bar.
|
2019-04-14 08:13:12 +02:00
|
|
|
Colors BarConfigColors `json:"colors,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// An object representing the gaps for the bar consisting of "top", "right",
|
|
|
|
// "bottom", and "left".
|
2019-04-14 08:13:12 +02:00
|
|
|
Gaps BarConfigGaps `json:"gaps,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The absolute height to use for the bar or 0 to automatically size based on
|
|
|
|
// the font
|
2019-04-14 08:13:12 +02:00
|
|
|
BarHeight int64 `json:"bar_height,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The vertical padding to use for the status line
|
2019-04-14 08:13:12 +02:00
|
|
|
StatusPadding int64 `json:"status_padding,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The horizontal padding to use for the status line when at the end of an output
|
2019-04-14 08:13:12 +02:00
|
|
|
StatusEdgePadding int64 `json:"status_edge_padding,omitempty"`
|
|
|
|
}
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// Contains version information about the sway process
|
2019-04-14 08:13:12 +02:00
|
|
|
type Version struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The major version of the sway process
|
2019-04-14 08:13:12 +02:00
|
|
|
Major int64 `json:"major,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The minor version of the sway process
|
2019-04-14 08:13:12 +02:00
|
|
|
Minor int64 `json:"minor,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The patch version of the sway process
|
2019-04-14 08:13:12 +02:00
|
|
|
Patch int64 `json:"patch,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// A human readable version string that will likely contain more useful
|
|
|
|
// information such as the git commit short hash and git branch
|
2019-04-14 08:13:12 +02:00
|
|
|
HumanReadable string `json:"human_readable,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The path to the loaded config file
|
2019-04-14 08:13:12 +02:00
|
|
|
LoadedConfigFileName string `json:"loaded_config_file_name,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Config string `json:"config,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TickReply struct {
|
|
|
|
Success bool `json:"success,omitempty"`
|
|
|
|
}
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// The libinput object describes the device configuration for libinput devices.
|
|
|
|
// Only properties that are supported for the device will be added to the object.
|
|
|
|
// In addition to the possible options listed, all string properties may also
|
|
|
|
// be unknown, in the case that a new option is added to libinput.
|
|
|
|
// See sway-input(5) for information on the meaning of the possible values.
|
2019-04-14 08:13:12 +02:00
|
|
|
type LibInput struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// Whether events are being sent by the device.
|
|
|
|
// It can be "enabled", "disabled", or "disabled_on_external_mouse"
|
|
|
|
SendEvents string `json:"send_events,omitempty"`
|
|
|
|
|
|
|
|
// Whether tap to click is enabled. It can be "enabled" or "disabled"
|
|
|
|
Tap string `json:"tap,omitempty"`
|
|
|
|
|
|
|
|
// The finger to button mapping in use. It can be "lmr" or "lrm"
|
|
|
|
TapButtonMap string `json:"tap_button_map,omitempty"`
|
|
|
|
|
|
|
|
// Whether tap-and-drag is enabled. It can be "enabled" or "disabled"
|
|
|
|
TapDrag string `json:"tap_drag,omitempty"`
|
|
|
|
|
|
|
|
// Whether drag-lock is enabled. It can be "enabled" or "disabled"
|
|
|
|
TapDragLock string `json:"tap_drag_lock,omitempty"`
|
|
|
|
|
|
|
|
// The pointer-acceleration in use
|
|
|
|
AccelSpeed float64 `json:"accel_speed,omitempty"`
|
|
|
|
|
|
|
|
// The acceleration profile in use. It can be "none", "flat", or "adaptive"
|
|
|
|
AccelProfile string `json:"accel_profile,omitempty"`
|
|
|
|
|
|
|
|
// Whether natural scrolling is enabled. It can be "enabled" or "disabled"
|
|
|
|
NaturalScroll string `json:"natural_scroll,omitempty"`
|
|
|
|
|
|
|
|
// Whether left-handed mode is enabled. It can be "enabled" or "disabled"
|
|
|
|
LeftHanded string `json:"left_handed,omitempty"`
|
|
|
|
|
|
|
|
// The click method in use. It can be "none", "button_areas", or "clickfinger"
|
|
|
|
ClickMethod string `json:"click_method,omitempty"`
|
|
|
|
|
|
|
|
// Whether middle emulation is enabled. It can be "enabled" or "disabled"
|
|
|
|
MiddleEmulation string `json:"middle_emulation,omitempty"`
|
|
|
|
|
|
|
|
// The scroll method in use.
|
|
|
|
// It can be "none", "two_finger", "edge", or "on_button_down"
|
|
|
|
ScrollMethod string `json:"scroll_method,omitempty"`
|
|
|
|
|
|
|
|
// The scroll button to use when "scroll_method" is "on_button_down".
|
|
|
|
// This will be given as an input event code
|
|
|
|
ScrollButton int64 `json:"scroll_button,omitempty"`
|
|
|
|
|
|
|
|
// Whether disable-while-typing is enabled. It can be "enabled" or "disabled"
|
|
|
|
DWT string `json:"dwt,omitempty"`
|
|
|
|
|
|
|
|
// An array of 6 floats representing the calibration matrix for absolute
|
|
|
|
// devices such as touchscreens
|
|
|
|
CalibrationMatrix [6]float64 `json:"calibration_matrix,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type Input struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The identifier for the input device
|
|
|
|
Identifier string `json:"identifier,omitempty"`
|
|
|
|
|
|
|
|
// The human readable name for the device
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
|
|
|
|
// The vendor code for the input device
|
|
|
|
Vendor int64 `json:"vendor,omitempty"`
|
|
|
|
|
|
|
|
// The product code for the input device
|
|
|
|
Product int64 `json:"product,omitempty"`
|
|
|
|
|
|
|
|
// The device type. Currently this can be "keyboard", "pointer", "touch",
|
|
|
|
// "tablet_tool", "tablet_pad", or "switch"
|
|
|
|
Type string `json:"type,omitempty"`
|
|
|
|
|
|
|
|
// (Only keyboards) The name of the active keyboard layout in use
|
|
|
|
XKBActiveLayoutName *string `json:"xkb_active_layout_name,omitempty"`
|
|
|
|
|
|
|
|
// (Only keyboards) A list a layout names configured for the keyboard
|
|
|
|
XKBLayoutNames []string `json:"xkb_layout_names,omitempty"`
|
|
|
|
|
|
|
|
// (Only keyboards) The index of the active keyboard layout in use
|
|
|
|
XKBActiveLayoutIndex *int64 `json:"xkb_active_layout_index,omitempty"`
|
|
|
|
|
|
|
|
// (Only libinput devices) An object describing the current device settings.
|
|
|
|
LibInput *LibInput `json:"libinput,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type Seat struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// The unique name for the seat
|
2019-04-14 08:13:12 +02:00
|
|
|
Name string `json:"name,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The number of capabilities that the seat has
|
2019-04-14 08:13:12 +02:00
|
|
|
Capabilities int64 `json:"capabilities,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// The id of the node currently focused by the seat or 0 when the seat is
|
|
|
|
// not currently focused by a node (i.e. a surface layer or xwayland
|
|
|
|
// unmanaged has focus)
|
2019-04-14 08:13:12 +02:00
|
|
|
Focus int64 `json:"focus,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// An array of input devices that are attached to the seat.
|
|
|
|
// Currently, this is an array of objects that are identical to those
|
|
|
|
// returned by GET_INPUTS
|
2019-04-14 08:13:12 +02:00
|
|
|
Devices []Input `json:"devices,omitempty"`
|
|
|
|
}
|
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// ModeEvent is sent whenever the binding mode changes
|
2019-04-14 08:13:12 +02:00
|
|
|
type ModeEvent struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// The binding mode that became active
|
|
|
|
Change string `json:"change,omitempty"`
|
|
|
|
|
|
|
|
// Whether the mode should be parsed as pango markup
|
|
|
|
PangoMarkup bool `json:"pango_markup,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type Binding struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// The command associated with the binding
|
|
|
|
Command string `json:"command,omitempty"`
|
|
|
|
|
|
|
|
// An array of strings that correspond to each modifier key for the binding
|
2019-04-14 08:13:12 +02:00
|
|
|
EventStateMask []string `json:"event_state_mask,omitempty"`
|
2019-04-15 04:21:31 +02:00
|
|
|
|
|
|
|
// For keyboard bindcodes, this is the key code for the binding. For mouse
|
|
|
|
// bindings, this is the X11 button number, if there is an equivalent. In
|
|
|
|
// all other cases, this will be 0.
|
|
|
|
InputCode int64 `json:"input_code,omitempty"`
|
|
|
|
|
|
|
|
// For keyboard bindsyms, this is the bindsym for the binding. Otherwise,
|
|
|
|
// this will be null
|
|
|
|
Symbol *string `json:"symbol,omitempty"`
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// The input type that triggered the binding. This is either "keyboard" or
|
|
|
|
// "mouse"
|
2019-04-15 04:21:31 +02:00
|
|
|
InputType string `json:"input_type,omitempty"`
|
2019-04-14 08:13:12 +02:00
|
|
|
}
|
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// BindingEvent is sent whenever a binding is executed
|
2019-04-14 08:13:12 +02:00
|
|
|
type BindingEvent struct {
|
2021-09-23 16:20:55 +02:00
|
|
|
// Currently this will only be "run"
|
2019-04-14 08:13:12 +02:00
|
|
|
Change string `json:"change,omitempty"`
|
2021-09-23 16:20:55 +02:00
|
|
|
|
2019-04-14 08:13:12 +02:00
|
|
|
Binding Binding `json:"binding,omitempty"`
|
|
|
|
}
|
|
|
|
|
2019-04-15 04:21:31 +02:00
|
|
|
// TickEvent is sent when first subscribing to tick events or by a SEND_TICK
|
|
|
|
// message
|
2019-04-14 08:13:12 +02:00
|
|
|
type TickEvent struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// Whether this event was triggered by subscribing to the tick events
|
|
|
|
First bool `json:"first,omitempty"`
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// The payload given with a SEND_TICK message, if any.
|
|
|
|
// Otherwise, an empty string
|
2019-04-14 08:13:12 +02:00
|
|
|
Payload string `json:"payload,omitempty"`
|
|
|
|
}
|
|
|
|
|
2021-09-23 16:20:55 +02:00
|
|
|
// BarStateUpdateEvent is sent when the visibility of a bar changes due to a
|
2019-04-15 04:21:31 +02:00
|
|
|
// modifier being pressed
|
2021-09-23 16:20:55 +02:00
|
|
|
type BarStateUpdateEvent struct {
|
2019-04-15 04:21:31 +02:00
|
|
|
// The bar ID effected
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
|
|
|
|
// Whether the bar should be made visible due to a modifier being pressed
|
|
|
|
VisibleByModifier bool `json:"visible_by_modifier,omitempty"`
|
2019-04-13 00:31:58 +02:00
|
|
|
}
|
2021-09-23 16:20:55 +02:00
|
|
|
|
|
|
|
// Deprecated: BarStatusUpdateEvent is deprecated, use BarStateUpdateEvent instead
|
|
|
|
type BarStatusUpdateEvent = BarStateUpdateEvent
|
|
|
|
|
|
|
|
// InputEvent is sent when something related to the input devices changes.
|
|
|
|
type InputEvent struct {
|
|
|
|
// What has changed
|
|
|
|
//
|
|
|
|
// The following change types are currently available:
|
|
|
|
// added: The input device became available
|
|
|
|
// removed: The input device is no longer available
|
|
|
|
// xkb_keymap: (Keyboards only) The keymap for the keyboard has changed
|
|
|
|
// xkb_layout: (Keyboards only) The effective layout in the keymap
|
|
|
|
// has changed
|
|
|
|
// libinput_config: (libinput device only) A libinput config option for the
|
|
|
|
// device changed
|
|
|
|
Change string `json:"change,omitempty"`
|
|
|
|
|
|
|
|
// An object representing the input that is identical the ones
|
|
|
|
// GET_INPUTS gives
|
|
|
|
Input Input `json:"input,omitempty"`
|
|
|
|
}
|