Simon Vieille
c30f1958d6
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
44 lines
803 B
Go
44 lines
803 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/enescakir/emoji"
|
|
"github.com/itchyny/timefmt-go"
|
|
r "gitnet.fr/deblan/i3-blocks-go/rendering"
|
|
"os"
|
|
"os/exec"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
func runCalendar(wg *sync.WaitGroup) {
|
|
defer wg.Done()
|
|
command := exec.Command("tmux", "new", "-d", "gnome-calendar")
|
|
command.Run()
|
|
}
|
|
|
|
func main() {
|
|
argFormat := os.Args[1]
|
|
now := time.Now()
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
if os.Getenv("BLOCK_BUTTON") == "1" {
|
|
wg.Add(1)
|
|
go runCalendar(&wg)
|
|
}
|
|
|
|
symbol := r.Emoji(emoji.Calendar)
|
|
date := timefmt.Format(now, argFormat)
|
|
|
|
options := r.NewBlockOptions()
|
|
options.FullText = r.TextWithRightPadding(fmt.Sprintf("%s %s", symbol, date), r.FB{
|
|
Foreground: r.Color("white"),
|
|
Background: r.Color("black4"),
|
|
})
|
|
|
|
block := r.Block("date", options)
|
|
fmt.Println(block)
|
|
wg.Wait()
|
|
}
|