go-i3/outputs.go

29 lines
708 B
Go
Raw Normal View History

2023-10-22 16:19:10 +02:00
package i3
import "encoding/json"
// Output describes an i3 output.
//
// See https://i3wm.org/docs/ipc.html#_outputs_reply for more details.
type Output struct {
Name string `json:"name"`
Active bool `json:"active"`
Primary bool `json:"primary"`
CurrentWorkspace string `json:"current_workspace"`
Rect Rect `json:"rect"`
}
// GetOutputs returns i3s current outputs.
//
// GetOutputs is supported in i3 ≥ v4.0 (2011-07-31).
func GetOutputs() ([]Output, error) {
reply, err := roundTrip(messageTypeGetOutputs, nil)
if err != nil {
return nil, err
}
var outputs []Output
err = json.Unmarshal(reply.Payload, &outputs)
return outputs, err
}