diff --git a/get_workspaces.go b/get_workspaces.go index 00be2dd..8864f17 100644 --- a/get_workspaces.go +++ b/get_workspaces.go @@ -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 +}