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() { func main() {
var configFlag string var configFlag string
flag.StringVar(&configFlag, "c", "", "path to tasks.json") flag.StringVar(&configFlag, "c", "", "path to .json file")
flag.Parse() flag.Parse()
fmt.Printf("Reading JSON file: %s\n", configFlag) fmt.Printf("Reading JSON file: %s\n", configFlag)
config, err := LoadConfig(configFlag) config, err := LoadConfig(configFlag)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Cannot load config file: %s\n\t%s\n", configFlag, err) fmt.Fprintf(os.Stderr, "Cannot load config file: %s\n\t%s\n", configFlag, err)
os.Exit(1)
} }
TaskRun(*config) TaskRun(*config)
} }

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

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

Loading…
Cancel
Save