2024-02-09 20:24:48 +01:00
|
|
|
package hypr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2024-02-19 10:02:33 +01:00
|
|
|
func (c *Client) Dispatch(cmd string) (io.ReadCloser, error) {
|
|
|
|
return readSocketRaw(c.SocketPath(), strings.NewReader(fmt.Sprintf("dispatch %s", cmd)))
|
2024-02-09 20:24:48 +01:00
|
|
|
}
|
|
|
|
|
2024-02-19 10:02:33 +01:00
|
|
|
func (c *Client) DispatchExpectOK(cmd string) error {
|
|
|
|
str, err := readSocketString(c.SocketPath(), strings.NewReader(fmt.Sprintf("dispatch %s", cmd)))
|
2024-02-09 20:24:48 +01:00
|
|
|
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
|
|
|
|
}
|