mirror of
https://github.com/Luzifer/streamdeck.git
synced 2024-12-20 17:51:21 +00:00
Fix actin exec env support, add display exec env support
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
205d8110d0
commit
5282f7304e
2 changed files with 30 additions and 3 deletions
|
@ -31,9 +31,18 @@ func (actionExec) Execute(attributes map[string]interface{}) error {
|
||||||
|
|
||||||
processEnv := env.ListToMap(os.Environ())
|
processEnv := env.ListToMap(os.Environ())
|
||||||
|
|
||||||
if e, ok := attributes["env"].(map[string]string); ok {
|
if e, ok := attributes["env"].(map[interface{}]interface{}); ok {
|
||||||
for k, v := range e {
|
for k, v := range e {
|
||||||
processEnv[k] = v
|
key, ok := k.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
value, ok := v.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
processEnv[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Luzifer/go_helpers/v2/env"
|
||||||
"github.com/golang/freetype"
|
"github.com/golang/freetype"
|
||||||
"github.com/golang/freetype/truetype"
|
"github.com/golang/freetype/truetype"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -58,8 +59,25 @@ func (d displayElementExec) Display(ctx context.Context, idx int, attributes map
|
||||||
// Execute command and parse it
|
// Execute command and parse it
|
||||||
var buf = new(bytes.Buffer)
|
var buf = new(bytes.Buffer)
|
||||||
|
|
||||||
|
processEnv := env.ListToMap(os.Environ())
|
||||||
|
|
||||||
|
if e, ok := attributes["env"].(map[interface{}]interface{}); ok {
|
||||||
|
for k, v := range e {
|
||||||
|
key, ok := k.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
value, ok := v.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
processEnv[key] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
command := exec.Command(args[0], args[1:]...)
|
command := exec.Command(args[0], args[1:]...)
|
||||||
command.Env = os.Environ()
|
command.Env = env.MapToList(processEnv)
|
||||||
command.Stdout = buf
|
command.Stdout = buf
|
||||||
|
|
||||||
if err := command.Run(); err != nil {
|
if err := command.Run(); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue