GetActiveWorkspace implemented
This commit is contained in:
parent
e4272f8478
commit
b779e88150
@ -28,3 +28,27 @@ func GetWorkspaces() ([]*Workspace, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user