GetActiveWorkspace implemented
This commit is contained in:
parent
704f069cb6
commit
1fcd0f5cde
@ -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