package main import ( "fmt" "os" "os/exec" "github.com/gen2brain/beeep" ) // Run will take the config file and for each task, run a go routine func TaskRun(c Config) { for i := range c.Tasks { title := c.Tasks[i].TaskName desc := c.Tasks[i].TaskDesc err := beeep.Notify(title, desc, "") if err != nil { fmt.Fprintf(os.Stderr, "ERROR: could not display \"%s\":\n\t%s\n", title, err) } } } // TaskCMD will take the config struct and run all the "CMD" fields with "bash -c [command]" and return the output func TaskCMD(c Config) (output string) { for i := range c.Tasks { command := c.Tasks[i].CMD if command == " " { fmt.Printf("INFO: Task %s has the cmd section empty. Will just return...\n", c.Tasks[i].TaskName) return } out, err := exec.Command("bash", "-c", command).Output() if err != nil { fmt.Fprintf(os.Stderr, "ERROR: could not run command \"%s\":\n\t%s\n", command, err) } //fmt.Printf("Output:\n%s\n", out) return string(out) } return }