-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using RunCommand you can execute any binary on a system with whatever arguments. Commands are constrained to running for up to 1sec. Commands will be looked up in path, unless an absolute path is given. This does not execute a shell and so cannot directly execute shell scripts. For that, you can call it with `sh -c`.
- Loading branch information
Showing
4 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os/exec" | ||
"time" | ||
) | ||
|
||
// RunCommand runs a command, not a shell, governed by the | ||
// passed in context. | ||
// | ||
// Commands are given 1s to complete. | ||
func RunCommand(ctx context.Context, name string, args ...string) (string, error) { | ||
cctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) | ||
defer cancel() | ||
|
||
cmd := exec.CommandContext(cctx, name, args...) | ||
output, err := cmd.CombinedOutput() | ||
return string(output), err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let mixer = "MIXER_ID"; | ||
let fader = "A"; | ||
let oldState = status.Old.Mixers[mixer].FaderStatus[fader].MuteState; | ||
let newState = status.New.Mixers[mixer].FaderStatus[fader].MuteState; | ||
oldState != newState ? RunCommand("notify-send", "-a", "gopherxlr", "-e", "state changed", "toggle") : nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters