Skip to content

Commit

Permalink
request: implement Animations
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jul 23, 2024
1 parent 2ddda72 commit 702a105
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ func (c *RequestClient) ActiveWorkspace() (w Workspace, err error) {
return w, unmarshalResponse(response, &w)
}

func (c *RequestClient) Animations() (a [][]Animation, err error) {
response, err := c.doRequest("animations")
if err != nil {
return a, err
}
return a, unmarshalResponse(response, &a)
}

func (c *RequestClient) Binds() (b []Bind, err error) {
response, err := c.doRequest("binds")
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testCommand[T any](t *testing.T, command func() (T, error), emptyValue any)
checkEnvironment(t)
got, err := command()
if err != nil {
t.Error(err)
t.Fatal(err)
}
if reflect.TypeOf(got) != reflect.TypeOf(emptyValue) {
t.Error("got wrong type")
Expand Down Expand Up @@ -145,6 +145,10 @@ func TestActiveWorkspace(t *testing.T) {
testCommand(t, c.ActiveWorkspace, Workspace{})
}

func TestAnimations(t *testing.T) {
testCommand(t, c.Animations, [][]Animation{})
}

func TestBinds(t *testing.T) {
testCommand(t, c.Binds, []Bind{})
}
Expand Down
9 changes: 9 additions & 0 deletions request_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ type RequestClient struct {
// Try to keep struct fields in the same order as the output for `hyprctl -j`
// for sanity.

type Animation struct {
Name string `json:"name"`
Overridden bool `json:"overridden"`
Bezier string `json:"bezier"`
Enabled bool `json:"enabled"`
Speed float64 `json:"speed"`
Style string `json:"style"`
}

type Bind struct {
Locked bool `json:"locked"`
Mouse bool `json:"mouse"`
Expand Down

0 comments on commit 702a105

Please sign in to comment.