hypr/get_clients.go
2024-02-09 20:30:19 +01:00

31 lines
477 B
Go

package hypr
import (
"encoding/json"
"os/exec"
)
func GetWindows() ([]*Window, error) {
cmd := exec.Command("hyprctl", "-j", "clients")
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err
}
if err := cmd.Start(); err != nil {
return nil, err
}
windows := make([]*Window, 0, 5)
if err := json.NewDecoder(stdout).Decode(&windows); err != nil {
return nil, err
}
if err := cmd.Wait(); err != nil {
return nil, err
}
return windows, nil
}