go-i3/outputs.go
2023-10-22 16:19:10 +02:00

29 lines
708 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}