refactor
This commit is contained in:
parent
616b54cb7f
commit
6b31cc8ef5
30
get_clients.go
Normal file
30
get_clients.go
Normal 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
30
get_workspaces.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user