mirror of
https://github.com/Luzifer/streamdeck.git
synced 2024-12-20 09:41:19 +00:00
Add action to switch pages
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f2244140ae
commit
0c0602b773
2 changed files with 19 additions and 1 deletions
18
cmd/streamdeck/action_page.go
Normal file
18
cmd/streamdeck/action_page.go
Normal file
|
@ -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")
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue