Documentation
¶
Index ¶
- Constants
- func ConnectToSocket() (net.Conn, error)
- func FindFocusedNodes(tree []Node, ch chan Node)
- func GetLargestWindowID(n []Node) int64
- func GetSocketPath() (string, error)
- func IsSwayAvailable() bool
- type ChangeEvent
- type Container
- type CurrentMode
- type DecoRect
- type Event
- type FloatingNodes
- type Geometry
- type Input
- type Modes
- type Node
- type Output
- type Rect
- type Seat
- type SwayConnection
- func (sc *SwayConnection) FindParent(id int64) Node
- func (sc *SwayConnection) GetActiveOutput() (*Output, error)
- func (sc *SwayConnection) GetFocusedWorkspace() (*Workspace, error)
- func (sc *SwayConnection) GetFocusedWorkspaceWindows() ([]Node, error)
- func (sc *SwayConnection) GetInputs() ([]Input, error)
- func (sc *SwayConnection) GetOutputs() ([]*Output, error)
- func (sc *SwayConnection) GetSeats() ([]Seat, error)
- func (sc *SwayConnection) GetTree() (*Tree, error)
- func (sc *SwayConnection) GetWorkspaces() ([]*Workspace, error)
- func (sc *SwayConnection) RunSwayCommand(cmd string) ([]byte, error)
- func (sc *SwayConnection) SendCommand(command int, s string) ([]byte, error)
- func (sc *SwayConnection) Subscribe() *subscription
- func (sc *SwayConnection) SubscribeListener(ch chan *Event)
- type Tree
- type WindowProperties
- type WindowRect
- type Workspace
Constants ¶
const ( // Magic string for the IPC API. MAGICK string = "i3-ipc" // The length of the i3 message "header" is 14 bytes: 6 for the _Magic // string, 4 for the length of the payload (int32 in native byte order) and // another 4 for the message type (also int32 in NBO). HEADERLEN = 14 IPC_GET_WORKSPACES = 1 IPC_SUBSCRIBE = 2 IPC_GET_OUTPUTS = 3 IPC_GET_TREE = 4 IPC_GET_MARKS = 5 IPC_GET_BAR_CONFIG = 6 IPC_GET_VERSION = 7 IPC_GET_BINDING_MODES = 8 IPC_GET_CONFIG = 9 IPC_SEND_TICK = 10 IPC_SYNC = 11 // Sway-specific command types IPC_GET_INPUTS = 100 IPC_GET_SEATS = 101 )
Variables ¶
This section is empty.
Functions ¶
func ConnectToSocket ¶
ConnectToSocket connects to the Sway socket
func FindFocusedNodes ¶
FindFocusedNodes finds the all focused nodes and send it to the channel
func GetLargestWindowID ¶
GetLargestWindow returns largest window ID
func GetSocketPath ¶
GetSocketPath returns socket path of the running Sway
func IsSwayAvailable ¶
func IsSwayAvailable() bool
IsSwayAvailable exported wrapper under the checkSway()
Types ¶
type ChangeEvent ¶
type ChangeEvent string
type Container ¶
type Container struct {
ID int `json:"id"`
Name string `json:"name"`
Rect Rect `json:"rect"`
Focused bool `json:"focused"`
Focus []interface{} `json:"focus"`
Border string `json:"border"`
CurrentBorderWidth int `json:"current_border_width"`
Layout string `json:"layout"`
Orientation string `json:"orientation"`
Percent float64 `json:"percent"`
WindowRect WindowRect `json:"window_rect"`
DecoRect DecoRect `json:"deco_rect"`
Geometry Geometry `json:"geometry"`
Window int `json:"window"`
Urgent bool `json:"urgent"`
FloatingNodes []FloatingNodes `json:"floating_nodes"`
Sticky bool `json:"sticky"`
Type string `json:"type"`
FullscreenMode int `json:"fullscreen_mode"`
Pid int `json:"pid"`
AppID interface{} `json:"app_id"`
Visible bool `json:"visible"`
Marks []interface{} `json:"marks"`
WindowProperties WindowProperties `json:"window_properties"`
Nodes []Node `json:"nodes"`
}
Container represents the Sway container
type CurrentMode ¶
type Event ¶
type Event struct {
Change ChangeEvent `json:"change"`
Container Container `json:"container"`
}
Event represents a Sway event
type FloatingNodes ¶
type FloatingNodes struct {
ID int `json:"id"`
Name string `json:"name"`
Rect Rect `json:"rect"`
Focused bool `json:"focused"`
Focus []interface{} `json:"focus"`
Border string `json:"border"`
CurrentBorderWidth int `json:"current_border_width"`
Layout string `json:"layout"`
Orientation string `json:"orientation"`
Percent float64 `json:"percent"`
WindowRect WindowRect `json:"window_rect"`
DecoRect DecoRect `json:"deco_rect"`
Geometry Geometry `json:"geometry"`
Window int `json:"window"`
Urgent bool `json:"urgent"`
FloatingNodes []FloatingNodes `json:"floating_nodes"`
Sticky bool `json:"sticky"`
Type string `json:"type"`
FullscreenMode int `json:"fullscreen_mode"`
Pid int `json:"pid"`
AppID interface{} `json:"app_id"`
Visible bool `json:"visible"`
Marks []interface{} `json:"marks"`
WindowProperties WindowProperties `json:"window_properties"`
Nodes []Node `json:"nodes"`
}
type Input ¶
type Input struct {
Identifier string `json:"identifier"`
Name string `json:"name"`
Vendor int64 `json:"vendor"`
Product int64 `json:"product"`
Type string `json:"type"`
XkbLayoutNames []string `json:"xkb_layout_names,omitempty"`
XkbActiveLayoutIndex int8 `json:"xkb_active_layout_index"`
XkbActiveLayoutName string `json:"xkb_active_layout_name"`
LibInput map[string]interface{} `json:"libinput"`
}
type Node ¶
type Node struct {
ID int64 `json:"id"`
Name string `json:"name"`
Rect Rect `json:"rect"`
Focused bool `json:"focused"`
Focus []int `json:"focus"`
Border string `json:"border"`
CurrentBorderWidth int `json:"current_border_width"`
Layout string `json:"layout"`
Orientation string `json:"orientation"`
Percent float64 `json:"percent"`
WindowRect WindowRect `json:"window_rect"`
DecoRect DecoRect `json:"deco_rect"`
Geometry Geometry `json:"geometry"`
Window interface{} `json:"window"`
Urgent bool `json:"urgent"`
FloatingNodes []Node `json:"floating_nodes"`
Sticky bool `json:"sticky"`
Type string `json:"type"`
Nodes []Node `json:"nodes"`
Active bool `json:"active,omitempty"`
Primary bool `json:"primary,omitempty"`
Visible bool `json:"visible,omitempty"`
Pid int `json:"pid"`
Make string `json:"make,omitempty"`
Model string `json:"model,omitempty"`
Serial string `json:"serial,omitempty"`
Scale float64 `json:"scale,omitempty"`
Transform string `json:"transform,omitempty"`
CurrentWorkspace string `json:"current_workspace,omitempty"`
Modes []Modes `json:"modes,omitempty"`
CurrentMode CurrentMode `json:"current_mode,omitempty"`
Representation string `json:"representation,omitempty"`
WindowProperties WindowProperties `json:"window_properties"`
AppID interface{} `json:"app_id"`
}
func GetAllFloatingWindows ¶
GetAllFloatingWindows returns all the floating windows including scratchpads
type Output ¶
type Output struct {
ID int `json:"id,omitempty"`
Name string `json:"name"`
Rect Rect `json:"rect"`
Focus []int `json:"focus,omitempty"`
Border string `json:"border,omitempty"`
CurrentBorderWidth int `json:"current_border_width,omitempty"`
Layout string `json:"layout,omitempty"`
Orientation string `json:"orientation,omitempty"`
Percent float64 `json:"percent"`
WindowRect WindowRect `json:"window_rect,omitempty"`
DecoRect DecoRect `json:"deco_rect,omitempty"`
Geometry Geometry `json:"geometry,omitempty"`
Window interface{} `json:"window,omitempty"`
Urgent bool `json:"urgent,omitempty"`
FloatingNodes []interface{} `json:"floating_nodes,omitempty"`
Sticky bool `json:"sticky,omitempty"`
Type string `json:"type"`
Active bool `json:"active"`
DPMS bool `json:"dpms"`
Primary bool `json:"primary"`
Make string `json:"make"`
Model string `json:"model"`
Serial string `json:"serial"`
Scale float64 `json:"scale,omitempty"`
Transform string `json:"transform,omitempty"`
CurrentWorkspace string `json:"current_workspace"`
Modes []Modes `json:"modes"`
CurrentMode CurrentMode `json:"current_mode,omitempty"`
Focused bool `json:"focused,omitempty"`
}
Output represents structure that we getting from `get_outputs'
type SwayConnection ¶
func NewSwayConnection ¶
func NewSwayConnection() (*SwayConnection, error)
NewSwayConnection initializes an new Sway connection through unix socket
func (*SwayConnection) FindParent ¶
func (sc *SwayConnection) FindParent(id int64) Node
FindParent returns the parent node of the provided node ID
func (*SwayConnection) GetActiveOutput ¶
func (sc *SwayConnection) GetActiveOutput() (*Output, error)
GetActiveOutput returns the currently active and focused output
func (*SwayConnection) GetFocusedWorkspace ¶
func (sc *SwayConnection) GetFocusedWorkspace() (*Workspace, error)
GetFocusedWorkspace returns focused workspace name
func (*SwayConnection) GetFocusedWorkspaceWindows ¶
func (sc *SwayConnection) GetFocusedWorkspaceWindows() ([]Node, error)
GetFocusedWorkspaceWindows returns all the windows from the focused workspace
func (*SwayConnection) GetInputs ¶
func (sc *SwayConnection) GetInputs() ([]Input, error)
GetInputs returns all available LibInput devices
func (*SwayConnection) GetOutputs ¶
func (sc *SwayConnection) GetOutputs() ([]*Output, error)
GetOutputs returns all outputs
func (*SwayConnection) GetSeats ¶
func (sc *SwayConnection) GetSeats() ([]Seat, error)
GetSeats returns all available seats
func (*SwayConnection) GetTree ¶
func (sc *SwayConnection) GetTree() (*Tree, error)
GetTree calls get_tree through a unix socket and return the Tree
func (*SwayConnection) GetWorkspaces ¶
func (sc *SwayConnection) GetWorkspaces() ([]*Workspace, error)
GetWorkspaces returns all active workspaces
func (*SwayConnection) RunSwayCommand ¶
func (sc *SwayConnection) RunSwayCommand(cmd string) ([]byte, error)
RunSwayCommand returns STDOUT or STDERR of the swaymsg
func (*SwayConnection) SendCommand ¶
func (sc *SwayConnection) SendCommand(command int, s string) ([]byte, error)
SendCommand sends command to the Sway unix socket
func (*SwayConnection) Subscribe ¶
func (sc *SwayConnection) Subscribe() *subscription
Subscribe to the sway events
func (*SwayConnection) SubscribeListener ¶
func (sc *SwayConnection) SubscribeListener(ch chan *Event)
SubscribeListener DEPRECATED listens events from the Sway
type Tree ¶
type Tree struct {
ID int `json:"id"`
Name string `json:"name"`
Rect Rect `json:"rect"`
Focused bool `json:"focused"`
Focus []int `json:"focus"`
Border string `json:"border"`
CurrentBorderWidth int `json:"current_border_width"`
Layout string `json:"layout"`
Orientation string `json:"orientation"`
Percent float64 `json:"percent"`
WindowRect WindowRect `json:"window_rect"`
DecoRect DecoRect `json:"deco_rect"`
Geometry Geometry `json:"geometry"`
Window interface{} `json:"window"`
Urgent bool `json:"urgent"`
FloatingNodes []Node `json:"floating_nodes"`
Sticky bool `json:"sticky"`
Type string `json:"type"`
Nodes []Node `json:"nodes"`
}
Tree is a structure that we getting from `get_tree'
type WindowProperties ¶
type WindowRect ¶
type Workspace ¶
type Workspace struct {
ID int64 `json:"id"`
Name string `json:"name"`
Rect Rect `json:"rect"`
Focus []int `json:"focus"`
Border string `json:"border"`
CurrentBorderWidth int `json:"current_border_width"`
Layout string `json:"layout"`
Orientation string `json:"orientation"`
Percent interface{} `json:"percent"`
WindowRect WindowRect `json:"window_rect"`
DecoRect DecoRect `json:"deco_rect"`
Geometry Geometry `json:"geometry"`
Window interface{} `json:"window"`
Urgent bool `json:"urgent"`
FloatingNodes []interface{} `json:"floating_nodes"`
Sticky bool `json:"sticky"`
Num int `json:"num"`
Output string `json:"output"`
Type string `json:"type"`
Representation string `json:"representation"`
Focused bool `json:"focused"`
Visible bool `json:"visible"`
}
Workspace represents a workspace