This commit is contained in:
milarin 2024-01-05 18:42:16 +01:00 committed by Milarin
parent 616b54cb7f
commit 6b31cc8ef5
2 changed files with 60 additions and 0 deletions

30
get_clients.go Normal file
View File

@ -0,0 +1,30 @@
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
}

30
get_workspaces.go Normal file
View File

@ -0,0 +1,30 @@
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
}