i think it works okay

main
simonkellet 2 years ago
parent 67dc1775b2
commit 449d7a1ff9
  1. 20
      assets/weather.json
  2. 3
      main.go
  3. 2
      run.go
  4. 14
      tasks.json

@ -0,0 +1,20 @@
{
"Tasks":
[
{
"taskname": "Cat",
"taskdesc": "cat lol",
"interval": 1000,
"cmd": "" ,
"icon": "./assets/catlol.jpg"
},
{
"taskname": "",
"taskdesc": "",
"interval": 36,
"cmd": "we",
"icon": ""
}
]
}

@ -8,13 +8,14 @@ import (
func main() {
var configFlag string
flag.StringVar(&configFlag, "c", "", "path to tasks.json")
flag.StringVar(&configFlag, "c", "", "path to .json file")
flag.Parse()
fmt.Printf("Reading JSON file: %s\n", configFlag)
config, err := LoadConfig(configFlag)
if err != nil {
fmt.Fprintf(os.Stderr, "Cannot load config file: %s\n\t%s\n", configFlag, err)
os.Exit(1)
}
TaskRun(*config)
}

@ -17,6 +17,7 @@ func TaskRun(c Config) {
for i := range c.Tasks {
title := c.Tasks[i].TaskName
interval := c.Tasks[i].Interval
asset := c.Tasks[i].Icon
var desc string
// check if desc is empty and use the cmd output, if not just get the desc
@ -25,7 +26,6 @@ func TaskRun(c Config) {
} else {
desc = c.Tasks[i].TaskDesc
}
asset := c.Tasks[i].Icon
//run the commands with go func()!
wg.Add(1)

@ -4,7 +4,7 @@
{
"taskname": "Example ls | wc -l Task",
"taskdesc": "",
"interval": 6,
"interval": 60,
"cmd": "ls /home/simon/ | wc -l" ,
"icon": ""
},
@ -12,7 +12,7 @@
{
"taskname": "Example with no cmd",
"taskdesc": "Still Place holder",
"interval": 8,
"interval": 80,
"cmd": "",
"icon": ""
},
@ -20,9 +20,17 @@
{
"taskname": "Example image task",
"taskdesc": "cat lol",
"interval": 10,
"interval": 100,
"cmd": "" ,
"icon": "./assets/catlol.jpg"
},
{
"taskname": "",
"taskdesc": "",
"interval": 3600,
"cmd": "we",
"icon": ""
}
]
}

Loading…
Cancel
Save