gojeh: Pomodoro widget for Polybar
I’ve started learning Go, and so far, I like it. Goroutines and channels are great, and I appreciate how OOP in Go is mostly limited to types and methods with type receivers.
I recently found an opportunity to use it in an everyday project. I’ve been wanting a Pomodoro timer widget for Polybar and I discovered polypomo. It’s a Python script that does exactly that but I thought it’s a good project for showcasing Go’s concurrency model: it needs to run a timer loop, print status updates to stdout, and handle control messages from external sources through a UNIX socket—all at the same time.
The result is Gojeh, which means “tomato” in Persian:

The source code is on GitHub, and you can install it with:
go install github.com/mil-ad/golestan/gojeh@latest
Running it directly in the terminal prints the current timer status. You can use netcat (nc) to send control messages to the socket from another terminal (e.g. to start/pause, change mode, and add/remove time):
echo "toggle" | nc -U /tmp/gojeh.sock
Note: The GNU version of nc doesn’t come with the -U flag and therefore lacks Unix socket support. You’ll need the OpenBSD version of nc (often in the openbsd-netcat package).
However, Gojeh is meant to be used as a Polybar module. My config looks like this:
[module/gojeh]
type = custom/script
exec = ~/.local/share/go/bin/gojeh
tail = true
interval = 1
click-left = echo "toggle" | nc -U /tmp/gojeh.sock
click-right = echo "next" | nc -U /tmp/gojeh.sock
scroll-up = echo "more_time" | nc -U /tmp/gojeh.sock
scroll-down = echo "less_time" | nc -U /tmp/gojeh.sock