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