From 702a1050d839fdffb2437c90a47740262f1ac6c3 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 23 Jul 2024 19:22:26 +0100 Subject: [PATCH] request: implement Animations --- request.go | 8 ++++++++ request_test.go | 6 +++++- request_types.go | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/request.go b/request.go index 6f6b67e..116518b 100644 --- a/request.go +++ b/request.go @@ -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 { diff --git a/request_test.go b/request_test.go index 3846d3c..d1702e2 100644 --- a/request_test.go +++ b/request_test.go @@ -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") @@ -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{}) } diff --git a/request_types.go b/request_types.go index eee206c..d9270fc 100644 --- a/request_types.go +++ b/request_types.go @@ -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"`