

Discover more from hrbrmstr's Daily Drop
“Travel mode” is coming to a close for your friendly neighborhood hrbrmstr, but he is still in the thick of it, so we're still in “light mode” for these WPEs. So, today, instead of starting something fresh, we're going to “modernize” a resource we covered this week.
ttimer Spit & Polish
We introduced ttimer this week as a tool you can use to manage basic timers with notifications from the CLI. It's a tiny Golang package that does what it says on the tin, but it has some issues.
You will want to fork it from here and clone your fork to your local system.
For starters, the notification module it uses is on life support, so we should really have it use a different one.
And, the way it handles command line arguments and displaying usage leaves much to be desired for modern tooling.
So, we're going to swap in a new notification module and lay the foundation for improving the usage idiom.
Beeep Beeep
We'll be using beeep as the notification replacement module.
Sending a notification is as simple as:
err := beeep.Notify("Title", "Message body", "")
if err != nil {
panic(err)
}
The third parameter is meant to be a path to a static image resource, but we're trying to keep this simple. Embedding resources and using a virtual filesystem path to make that work with beeep
is beyond the scope of this WPE (unless you want to poke at that on your own). So, just keep it blank to use the system default, or reference a file on your system.
If you look at agent/agent.go
start at line ~63, this is where the calls to the outdated notification library are located. Refer to the beeep
docs and see if you can sub out the proper calls. You can reference my fork if you need some hints.
Arrrgh!!
The OG ttimer
has an internal method for dealing with command line arguments. It works, but it's not ideal. There is no support for long/short args, and it won't display usage (it just points back to the repo).
In my fork, I used go-arg to handle this better.
Again, keep the docs up and try to go it on your own before referring to my fork for the basic solve. I left out some extended help examples and the case when there are no arguments specified.
What's Up, Man?
Intrepid readers with a tad more time on their hands might also be up for referring to another older Drop and use the linked resources to create a proper Unix manual page for the utility. This may also require creating a Makefile
or Justfile
to help folks install the manual page.
FIN
Even if you aren't proficient in Golang, this could be a fun exercise to go through, especially if you lean a bit on our code-specific LLM GPT overlords for some assistance (e.g., keep GH Copilot or Cody up whilst hacking away on the WPE). ☮️