GetActiveWorkspace implemented

This commit is contained in:
milarin 2024-01-05 23:14:56 +01:00
parent 704f069cb6
commit 1fcd0f5cde

View File

@ -28,3 +28,27 @@ func GetWorkspaces() ([]*Workspace, error) {
return workspaces, nil 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
}