From 0c0602b77360f4c0216d5119c91f2017bf45cd10 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 21 Nov 2019 01:15:07 +0100 Subject: [PATCH] Add action to switch pages Signed-off-by: Knut Ahlers --- cmd/streamdeck/action_page.go | 18 ++++++++++++++++++ cmd/streamdeck/main.go | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cmd/streamdeck/action_page.go diff --git a/cmd/streamdeck/action_page.go b/cmd/streamdeck/action_page.go new file mode 100644 index 0000000..0c9ecfc --- /dev/null +++ b/cmd/streamdeck/action_page.go @@ -0,0 +1,18 @@ +package main + +import "github.com/pkg/errors" + +func init() { + registerAction("page", actionPage{}) +} + +type actionPage struct{} + +func (actionPage) Execute(attributes map[string]interface{}) error { + name, ok := attributes["name"].(string) + if !ok { + return errors.New("No page name supplied") + } + + return errors.Wrap(togglePage(name), "Unable to switch page") +} diff --git a/cmd/streamdeck/main.go b/cmd/streamdeck/main.go index c13ff52..66ae88c 100644 --- a/cmd/streamdeck/main.go +++ b/cmd/streamdeck/main.go @@ -126,7 +126,7 @@ func togglePage(page string) error { func triggerAction(kd keyDefinition) error { if kd.Action.Type != "" { - return errors.Wrap(callAction(kd), "Unable to execute action") + return callAction(kd) } return nil