fix command runner
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Simon Vieille 2022-08-28 20:56:31 +02:00
parent ab4d7c98fa
commit f384772e81
Signed by: deblan
GPG key ID: 579388D585F70417
2 changed files with 25 additions and 4 deletions

View file

@ -5,12 +5,21 @@ import (
r "gitnet.fr/deblan/i3-blocks-go/rendering" r "gitnet.fr/deblan/i3-blocks-go/rendering"
"os" "os"
"os/exec" "os/exec"
"sync"
) )
func runCmd(wg *sync.WaitGroup, value string) {
defer wg.Done()
command := exec.Command("tmux", "new", "-d", value)
command.Run()
}
func main() { func main() {
var wg sync.WaitGroup
if os.Getenv("BLOCK_BUTTON") == "1" { if os.Getenv("BLOCK_BUTTON") == "1" {
command := exec.Command("bash", "-c", os.Args[5]) wg.Add(1)
command.Run() go runCmd(&wg, os.Args[5])
} }
options := r.NewBlockOptions() options := r.NewBlockOptions()
@ -20,6 +29,6 @@ func main() {
}) })
block := r.Block(os.Args[1], options) block := r.Block(os.Args[1], options)
fmt.Println(block) fmt.Println(block)
wg.Wait()
} }

View file

@ -6,14 +6,26 @@ import (
"github.com/itchyny/timefmt-go" "github.com/itchyny/timefmt-go"
r "gitnet.fr/deblan/i3-blocks-go/rendering" r "gitnet.fr/deblan/i3-blocks-go/rendering"
"os" "os"
"os/exec"
"sync"
"time" "time"
) )
func runCalendar(wg *sync.WaitGroup) {
defer wg.Done()
command := exec.Command("tmux", "new", "-d", "gnome-calendar")
command.Run()
}
func main() { func main() {
argFormat := os.Args[1] argFormat := os.Args[1]
now := time.Now() now := time.Now()
var wg sync.WaitGroup
if os.Getenv("BLOCK_BUTTON") == "1" { if os.Getenv("BLOCK_BUTTON") == "1" {
wg.Add(1)
go runCalendar(&wg)
} }
symbol := r.Emoji(emoji.Calendar) symbol := r.Emoji(emoji.Calendar)
@ -26,6 +38,6 @@ func main() {
}) })
block := r.Block("date", options) block := r.Block("date", options)
fmt.Println(block) fmt.Println(block)
wg.Wait()
} }