Skip to content

Commit

Permalink
Merge pull request #2 from Megum1n/add-activeworkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
labi-le committed Jan 2, 2024
2 parents 1de6e15 + f339626 commit 4561c5a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ func (c *ipc) Workspaces() ([]Workspace, error) {
return workspaces, c.wrapreq("workspaces", &workspaces, Args{})
}

func (c *ipc) ActiveWorkspace() (Workspace, error) {
var workspace Workspace
return workspace, c.wrapreq("activeworkspace", &workspace, Args{})
}

func (c *ipc) Monitors() ([]Monitor, error) {
var monitors []Monitor
return monitors, c.wrapreq("monitors", &monitors, Args{})
Expand Down
4 changes: 4 additions & 0 deletions ipc_dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func (d DummyIPC) Workspaces() ([]Workspace, error) {
return []Workspace{}, nil
}

func (d DummyIPC) ActiveWorkspace() (Workspace, error) {
return Workspace{}, nil
}

func (d DummyIPC) Monitors() ([]Monitor, error) {
return []Monitor{}, nil
}
Expand Down
11 changes: 11 additions & 0 deletions ipc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ func Test_ipc_Workspaces(t *testing.T) {
}
}

func Test_ipc_ActiveWorkspaces(t *testing.T) {
got, err := ipctest.ActiveWorkspace()
if err != nil {
t.Error(err)
}

if reflect.DeepEqual(got, Workspace{}) {
t.Errorf("got empty struct")
}
}

func Test_ipc_Monitors(t *testing.T) {
got, err := ipctest.Monitors()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions ipc_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type IPC interface {
Receive() ([]ReceivedData, error)
Dispatch(args Args) ([]byte, error)
Workspaces() ([]Workspace, error)
ActiveWorkspace() (Workspace, error)
Monitors() ([]Monitor, error)
Clients() ([]Client, error)
ActiveWindow() (Window, error)
Expand Down

0 comments on commit 4561c5a

Please sign in to comment.