i3-blocks-go/blocks/app/main.go

35 lines
578 B
Go
Raw Normal View History

2022-08-28 15:36:24 +02:00
package main
import (
"fmt"
r "gitnet.fr/deblan/i3-blocks-go/rendering"
"os"
"os/exec"
2022-08-28 20:56:31 +02:00
"sync"
2022-08-28 15:36:24 +02:00
)
2022-08-28 20:56:31 +02:00
func runCmd(wg *sync.WaitGroup, value string) {
defer wg.Done()
command := exec.Command("tmux", "new", "-d", value)
command.Run()
}
2022-08-28 15:36:24 +02:00
func main() {
2022-08-28 20:56:31 +02:00
var wg sync.WaitGroup
2022-08-28 15:36:24 +02:00
if os.Getenv("BLOCK_BUTTON") == "1" {
2022-08-28 20:56:31 +02:00
wg.Add(1)
go runCmd(&wg, os.Args[5])
2022-08-28 15:36:24 +02:00
}
options := r.NewBlockOptions()
options.FullText = r.TextWithPadding(os.Args[2], r.FB{
Background: os.Args[3],
Foreground: os.Args[4],
})
block := r.Block(os.Args[1], options)
fmt.Println(block)
2022-08-28 20:56:31 +02:00
wg.Wait()
2022-08-28 15:36:24 +02:00
}