Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5d793926b | ||
|
|
40a94bd001 |
@@ -18,7 +18,7 @@ It is i3bar text generator.
|
||||
|
||||
## How to build it
|
||||
|
||||
This appliction was tested to compile with go v1.24.
|
||||
This application was tested to compile with go v1.24.
|
||||
|
||||
All you need is go lang compiler and gnu make utility. Invoke
|
||||
|
||||
|
||||
41
internal/lib/runcommand.go
Normal file
41
internal/lib/runcommand.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
// RunCommands gets list of commands runs them sequentally and conacatenates their output.
|
||||
func (c *MyConfig) RunCommand() {
|
||||
var (
|
||||
InitialDelay = 100 * time.Millisecond
|
||||
LoopIterationDelay = time.Duration(c.CmdRun.Delay) * time.Second
|
||||
Delay = InitialDelay
|
||||
ticker = time.NewTicker(Delay)
|
||||
)
|
||||
|
||||
for range ticker.C {
|
||||
if Delay == InitialDelay {
|
||||
Delay = LoopIterationDelay
|
||||
ticker.Reset(Delay)
|
||||
}
|
||||
|
||||
var (
|
||||
outputString string
|
||||
command = []string{c.CmdRun.Cmd}
|
||||
)
|
||||
|
||||
if len(c.CmdRun.Args) > 0 {
|
||||
command = append(command, c.CmdRun.Args...)
|
||||
}
|
||||
|
||||
outputString += RunProcess(command)
|
||||
|
||||
log.Println(c.Values.RunCommandOutput)
|
||||
|
||||
if c.Values.RunCommandOutput != outputString {
|
||||
c.Values.RunCommandOutput = outputString
|
||||
c.Channels.UpdateReady <- true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user