36 lines
944 B
Go
36 lines
944 B
Go
package i3
|
||
|
||
import "encoding/json"
|
||
|
||
// WorkspaceID is an i3-internal ID for the node, which can be used to identify
|
||
// workspaces within the IPC interface.
|
||
type WorkspaceID int64
|
||
|
||
// Workspace describes an i3 workspace.
|
||
//
|
||
// See https://i3wm.org/docs/ipc.html#_workspaces_reply for more details.
|
||
type Workspace struct {
|
||
ID WorkspaceID `json:"id"`
|
||
Num int64 `json:"num"`
|
||
Name string `json:"name"`
|
||
Visible bool `json:"visible"`
|
||
Focused bool `json:"focused"`
|
||
Urgent bool `json:"urgent"`
|
||
Rect Rect `json:"rect"`
|
||
Output string `json:"output"`
|
||
}
|
||
|
||
// GetWorkspaces returns i3’s current workspaces.
|
||
//
|
||
// GetWorkspaces is supported in i3 ≥ v4.0 (2011-07-31).
|
||
func GetWorkspaces() ([]Workspace, error) {
|
||
reply, err := roundTrip(messageTypeGetWorkspaces, nil)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
var ws []Workspace
|
||
err = json.Unmarshal(reply.Payload, &ws)
|
||
return ws, err
|
||
}
|