i3-blocks-go/blocks/date/main.go

44 lines
803 B
Go
Raw Normal View History

2022-08-28 14:59:15 +02:00
package main
import (
"fmt"
"github.com/enescakir/emoji"
"github.com/itchyny/timefmt-go"
r "gitnet.fr/deblan/i3-blocks-go/rendering"
"os"
2022-08-28 20:56:31 +02:00
"os/exec"
"sync"
2022-08-28 14:59:15 +02:00
"time"
)
2022-08-28 20:56:31 +02:00
func runCalendar(wg *sync.WaitGroup) {
defer wg.Done()
command := exec.Command("tmux", "new", "-d", "gnome-calendar")
command.Run()
}
2022-08-28 14:59:15 +02:00
func main() {
argFormat := os.Args[1]
now := time.Now()
2022-08-28 20:56:31 +02:00
var wg sync.WaitGroup
2022-08-28 14:59:15 +02:00
if os.Getenv("BLOCK_BUTTON") == "1" {
2022-08-28 20:56:31 +02:00
wg.Add(1)
go runCalendar(&wg)
2022-08-28 14:59:15 +02:00
}
symbol := r.Emoji(emoji.Calendar)
date := timefmt.Format(now, argFormat)
options := r.NewBlockOptions()
2022-08-28 22:22:22 +02:00
options.FullText = r.TextWithRightPadding(fmt.Sprintf("%s %s", symbol, date), r.FB{
2022-08-28 14:59:15 +02:00
Foreground: r.Color("white"),
Background: r.Color("black4"),
})
block := r.Block("date", options)
fmt.Println(block)
2022-08-28 20:56:31 +02:00
wg.Wait()
2022-08-28 14:59:15 +02:00
}