-
Notifications
You must be signed in to change notification settings - Fork 16
/
workspaces.go
35 lines (30 loc) · 944 Bytes
/
workspaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}