Documentation
¶
Overview ¶
Package sway is the sway/i3 IPC client: the i3 wire protocol over $SWAYSOCK, workspace snapshots, an event subscription, and layout commands.
Index ¶
- func FocusCommand(ws Workspace) string
- func IsRunning() bool
- func KeyboardLayout(inputs []Input) string
- func Quote(name string) string
- func SocketPath() string
- func Subscribe() (<-chan struct{}, func(), error)
- func SubscribeTo(events ...string) (<-chan struct{}, func(), error)
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) FocusBackAndForth(ctx context.Context) error
- func (c *Conn) FocusNextOnOutput(ctx context.Context) error
- func (c *Conn) FocusPrevOnOutput(ctx context.Context) error
- func (c *Conn) FocusWorkspace(ctx context.Context, ws Workspace) error
- func (c *Conn) Inputs() ([]Input, error)
- func (c *Conn) RunCommand(ctx context.Context, command string) error
- func (c *Conn) Tree() ([]byte, error)
- func (c *Conn) Windows() ([]Window, error)
- func (c *Conn) Workspaces() ([]Workspace, error)
- type Input
- type Window
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FocusCommand ¶
FocusCommand is focus_command for a workspace the snapshot knows: by number when it has one, else by quoted name.
func KeyboardLayout ¶
KeyboardLayout is refresh_keyboard_layout: the active layout of the first keyboard reporting one; "" when none does.
func Quote ¶
Quote is service.rs's quote: a double-quoted workspace name with embedded backslashes and quotes escaped.
func SocketPath ¶
func SocketPath() string
SocketPath reads $SWAYSOCK; empty when sway is not running.
func Subscribe ¶
func Subscribe() (<-chan struct{}, func(), error)
Subscribe connects a second socket, subscribes to the workspace and window streams, and ticks per event; each tick is the cue to re-query. The channel closes when the stream ends; stop closes the socket.
func SubscribeTo ¶
SubscribeTo is Subscribe over the named event streams.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is one IPC connection. Requests serialize; events read on their own connection.
func (*Conn) FocusBackAndForth ¶
FocusBackAndForth is focus:last.
func (*Conn) FocusNextOnOutput ¶
FocusNextOnOutput is focus:next.
func (*Conn) FocusPrevOnOutput ¶
FocusPrevOnOutput is focus:previous.
func (*Conn) FocusWorkspace ¶
FocusWorkspace focuses one workspace (focus:this).
func (*Conn) RunCommand ¶
RunCommand executes one sway command; the first error in the reply wins.
func (*Conn) Tree ¶
Tree returns the raw GET_TREE reply, for callers that walk fields Windows does not model (the launcher's window mode).
func (*Conn) Windows ¶
Windows walks GET_TREE into its leaf windows, tiling before floating per container, in tree order.
func (*Conn) Workspaces ¶
Workspaces lists the workspaces.
type Input ¶
type Input struct {
Type string `json:"type"`
XkbActiveLayoutName *string `json:"xkb_active_layout_name"`
}
Input is one GET_INPUTS entry (types.rs's InputReply), the fields the keyboard layout reads.
type Window ¶
type Window struct {
ID int64
Title string
HasTitle bool
AppID string
HasAppID bool
WorkspaceID int64
// HasWorkspace is false for windows outside any workspace (the
// scratchpad's __i3 container still counts as a workspace node).
HasWorkspace bool
Focused bool
Floating bool
Urgent bool
// Visible says the window is on screen; Rect is its container's
// global logical rectangle.
Visible bool
Rect image.Rectangle
}
Window is one leaf window of the container tree (core/window.rs's snapshot), tagged with the enclosing workspace's id.