added environment variable to pass arguments to the specified script
This commit is contained in:
parent
6768f6c2e9
commit
3fc77c5b73
5 changed files with 7 additions and 2 deletions
1
.vscode/launch.json
vendored
1
.vscode/launch.json
vendored
|
@ -15,6 +15,7 @@
|
|||
"SLIDESHOW_PALETTE_ALGORITHM": "",
|
||||
"SLIDESHOW_PALETTE_COLORS": "",
|
||||
"SLIDESHOW_SCRIPT": "",
|
||||
"SLIDESHOW_SCRIPT_ARGS": "",
|
||||
"SLIDESHOW_SCRIPT_ASYNC": "",
|
||||
"SLIDESHOW_SCRIPT_STAGE": "",
|
||||
"SLIDESHOW_LOGLEVEL": "debug",
|
||||
|
|
|
@ -19,7 +19,8 @@ configuration is entirely done via environment variables.
|
|||
| SLIDESHOW_PALETTE | | path to a file where the color palette will be stored |
|
||||
| SLIDESHOW_PALETTE_ALGORITHM | "wsm" | the algorithm used to generate the color palette |
|
||||
| SLIDESHOW_PALETTE_COLORS | 16 | the amount of colors generated |
|
||||
| SLIDESHOW_SCRIPT | | path to a script to execute after each loop |
|
||||
| SLIDESHOW_SCRIPT | | path to a script to execute each loop |
|
||||
| SLIDESHOW_SCRIPT_ARGS | | arguments to pass to the script |
|
||||
| SLIDESHOW_SCRIPT_ASYNC | false | run the script asynchronously (in a goroutine) |
|
||||
| SLIDESHOW_SCRIPT_STAGE | | the stage at which the script is executed |
|
||||
| SLIDESHOW_LOGLEVEL | "info" | the log level |
|
||||
|
|
|
@ -17,6 +17,7 @@ var PaletteFile string
|
|||
var PaletteAlgorithm string
|
||||
var PaletteColors int
|
||||
var Script string
|
||||
var ScriptArgs []string
|
||||
var ScriptAsync bool
|
||||
var ScriptStage string
|
||||
|
||||
|
@ -58,6 +59,7 @@ func Initialize() {
|
|||
}
|
||||
PaletteColors = tmpInt
|
||||
Script = os.Getenv("SLIDESHOW_SCRIPT")
|
||||
ScriptArgs = strings.Split(os.Getenv("SLIDESHOW_SCRIPT_ARGS"), " ")
|
||||
ScriptAsync, _ = strconv.ParseBool(os.Getenv("SLIDESHOW_SCRIPT_ASYNC"))
|
||||
ScriptStage = strings.ToLower(os.Getenv("SLIDESHOW_SCRIPT_STAGE"))
|
||||
checkScript()
|
||||
|
|
|
@ -98,7 +98,7 @@ func runScript(running bool) {
|
|||
if !config.IsScriptSet() {
|
||||
return
|
||||
}
|
||||
cmd := exec.Command(config.Script)
|
||||
cmd := exec.Command(config.Script, config.ScriptArgs...)
|
||||
error := cmd.Run()
|
||||
if error != nil {
|
||||
loggo.Error("encountered an error executing the script '"+config.Script+"'", error.Error())
|
||||
|
|
|
@ -12,6 +12,7 @@ Environment="SLIDESHOW_PALETTE=/tmp/.slideshow.palette"
|
|||
Environment="SLIDESHOW_PALETTE_ALGORITHM="
|
||||
Environment="SLIDESHOW_PALETTE_COLORS="
|
||||
Environment="SLIDESHOW_SCRIPT="
|
||||
Environment="SLIDESHOW_SCRIPT_ARGS="
|
||||
Environment="SLIDESHOW_SCRIPT_ASYNC="
|
||||
Environment="SLIDESHOW_SCRIPT_STAGE="
|
||||
Environment="SLIDESHOW_LOGLEVEL=debug"
|
||||
|
|
Loading…
Reference in a new issue