diff --git a/execute_command.go b/execute_command.go deleted file mode 100644 index 1f3e938..0000000 --- a/execute_command.go +++ /dev/null @@ -1,21 +0,0 @@ -package hypr - -import ( - "fmt" - "net" - "os" -) - -func Execute(cmd string) error { - conn, err := net.Dial("unix", os.ExpandEnv("/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock")) - if err != nil { - return err - } - defer conn.Close() - - if _, err := fmt.Fprintln(conn, cmd); err != nil { - return err - } - - return nil -} diff --git a/get_clients.go b/get_clients.go deleted file mode 100644 index f67f756..0000000 --- a/get_clients.go +++ /dev/null @@ -1,36 +0,0 @@ -package hypr - -import ( - "encoding/json" - "os/exec" - - "git.milar.in/milarin/slices" -) - -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 - } - - windows = slices.Filter(windows, func(w *Window) bool { - return w.PID != -1 - }) - - return windows, nil -} diff --git a/get_events.go b/get_events.go deleted file mode 100644 index 12df28a..0000000 --- a/get_events.go +++ /dev/null @@ -1,46 +0,0 @@ -package hypr - -import ( - "bufio" - "context" - "net" - "os" - "strings" - - "git.milar.in/milarin/channel" - "git.milar.in/milarin/slices" -) - -func GetEventChannel(ctx context.Context, types ...EventType) (<-chan Event, error) { - conn, err := net.Dial("unix", os.ExpandEnv("/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock")) - if err != nil { - return nil, err - } - - out := make(chan Event, 10) - - go func() { - defer conn.Close() - <-ctx.Done() - }() - - go func() { - defer close(out) - defer conn.Close() - - sc := bufio.NewScanner(conn) - for sc.Scan() { - out <- parseEvent(sc.Text()) - } - }() - - if len(types) == 0 { - return out, nil - } - - typeMap := slices.ToStructMap(slices.Map(types, strings.ToLower)) - return channel.Filter(out, func(e Event) bool { - _, ok := typeMap[e.Type] - return ok - }), nil -} diff --git a/get_workspaces.go b/get_workspaces.go deleted file mode 100644 index 8864f17..0000000 --- a/get_workspaces.go +++ /dev/null @@ -1,54 +0,0 @@ -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 -}