package hypr import ( "fmt" "io" "strings" ) func (i *Client) Dispatch(cmd string) (io.ReadCloser, error) { return readSocketRaw(i.SocketPath(), strings.NewReader(fmt.Sprintf("dispatch %s", cmd))) } func (i *Client) DispatchExpectOK(cmd string) error { str, err := readSocketString(i.SocketPath(), strings.NewReader(fmt.Sprintf("dispatch %s", cmd))) if err != nil { return err } if strings.ToLower(strings.TrimSpace(str)) != "ok" { return fmt.Errorf("dispatcher '%s' returned an error: %s", cmd, str) } return nil }