parent
f85131b80a
commit
3e0b10a8f5
@ -1,3 +1,12 @@ |
|||||||
module go-taskrem |
module go-taskrem |
||||||
|
|
||||||
go 1.19 |
go 1.19 |
||||||
|
|
||||||
|
require ( |
||||||
|
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 // indirect |
||||||
|
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect |
||||||
|
github.com/godbus/dbus/v5 v5.1.0 // indirect |
||||||
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect |
||||||
|
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect |
||||||
|
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect |
||||||
|
) |
||||||
|
@ -0,0 +1,13 @@ |
|||||||
|
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 h1:jFEK/SA/7E8lg9T33+y8D4Z0I782+bbiEjmyyklRzRQ= |
||||||
|
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw= |
||||||
|
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE= |
||||||
|
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= |
||||||
|
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= |
||||||
|
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= |
||||||
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= |
||||||
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= |
||||||
|
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk= |
||||||
|
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= |
||||||
|
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||||
|
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 h1:ohgcoMbSofXygzo6AD2I1kz3BFmW1QArPYTtwEM3UXc= |
||||||
|
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
@ -1,11 +1,42 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import "fmt" |
import ( |
||||||
|
"fmt" |
||||||
|
"os" |
||||||
|
"os/exec" |
||||||
|
|
||||||
|
"github.com/gen2brain/beeep" |
||||||
|
) |
||||||
|
|
||||||
// Run will take the config file and for each task, run a go routine
|
// Run will take the config file and for each task, run a go routine
|
||||||
func TaskRun(c Config) { |
func TaskRun(c Config) { |
||||||
for i, v := range c.Tasks { |
for i := range c.Tasks { |
||||||
fmt.Printf("%d, %s", i, v) |
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 |
||||||
|
} |
||||||
|
Loading…
Reference in new issue