mirror of
https://codeberg.org/scip/swayipc.git
synced 2026-08-23 22:34:20 +02:00
30 lines
631 B
Go
30 lines
631 B
Go
package swayipc
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// Seat stores information about a seat containing input devices
|
|
type Seat struct {
|
|
Name string `json:"name"`
|
|
Capabilities int `json:"capabilities"`
|
|
Focus int `json:"focus"`
|
|
Devices []*Input `json:"devices"`
|
|
}
|
|
|
|
// GetSeats returns input seats
|
|
func (ipc *SwayIPC) GetSeats() ([]*Seat, error) {
|
|
payload, err := ipc.get(MsgGetSeats)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
seats := []*Seat{}
|
|
if err := json.Unmarshal(payload.Payload, &seats); err != nil {
|
|
return nil, fmt.Errorf("failed to unmarshal json: %w", err)
|
|
}
|
|
|
|
return seats, nil
|
|
}
|