Calcurse Notifications

Reading Time: 3 minutes | Published: 2020-05-13 | Last Edited: 2023-03-19

Calcurse CLI Notifications 100 Days to Offload

I recently started using calcurse for my calendar and one of its limitations is good notification support in the generally accepted meaning of the word. The developer has a different opinion and that’s perfectly alright but traditional notifications are a feature I heavily rely on and calcurse doesn’t handle handle them very well; it leaves the user to figure something out on their own. Inspired by one individual’s issue, I did just that.

A quick glance at man calcurse reveals this section:

-n, --next
    Print the first appointment within the next 24 hours. The
    printed time is the number of hours and minutes left before
    this appointment.

The output of running calcurse -n, for me and at the moment, looks like this:

$ calcurse -n
next appointment:
   [17:25] DnD on Mumble

It’s all well and good but not really something you’d want in a notification; it needs to be filtered down so it only shows the name of the event, DnD on Mumble. To do this, I turned to the man pages of standard CLI utilities tail and cut. tail allows us to filter the output to only the last line1 with tail -1. cut is a little more complicated but will allow us to remove the first few columns of text. cut -d ' ' -f 5- is the next snippet in this one-liner. -d ' ' tells cut to use a single space as the delimiter, -f specifies the fields to keep, and -5 says to use all fields starting with the 5th because there are a few spaces preceding the content we want. Chain all of this mess together with pipes and we get:

calcurse -n | tail -1 | cut -d ' ' -f 5-

Great. Now we need to actually get a notification containing the resulting string. This can be achieved by storing it in a variable then using it with notify-send. You likely already have notify-send installed if you’re using Linux but, if you don’t, I would recommend looking around to see what’s default and using that instead.

CONT="$(calcurse -n | tail -1 | cut -d ' ' -f 5- -)" && notify-send "Calcurse Event" "$CONT"

Now we’re actually getting somewhere. With my setup, the notification looks like this: It’s a screenshot of my desktop with a notification
in the top right corner. The title is “Calcurse Event” and the text
below is “DnD on Mumble”. Surrounding the text is a solid border. Its
position and the border are all that designate it as a notification: the
background and text colour match the rest of my desktop which is themed
with the base16-unikitty-dark scheme

It’s certainly passable and sufficient for some but I’d like an icon so I can see what the notification is for out of the corner of my eye and decide whether or not to glance over. Thankfully, notify-send has this built in with the -i flag.

-i, --icon=ICON[,ICON...]
    Specifies an icon filename or stock icon to display.

Now it’s just a matter of figuring out what icon to use. You can certainly pass the path of whatever image you want to it, such as ~/Pictures/calendar-icon.png, but I want something that fits in with the rest of my icons. These are found in:


I use Suru++ Dark and the icon I’m using can be found at:


It’s different for Adwaita and all the rest though; you’ll have to do some digging. It’s also worth noting that, if you don’t have this theme installed on another device, the icon won’t show up.

After all that, here’s my notification command and a screenshot.

CONT="$(calcurse -n | tail -1 | cut -d ' ' -f 5-)" && notify-send -i /usr/share/icons/Suru++-Dark/apps/32@2x/calendar.svg "Calcurse Event" "$CONT"

This is a screenshot like the last one but with an attractive icon to
the left of the text

This was posted as part of #100DaysToOffload, an awesome idea from Kev Quirk. If you want to participate, just write something every day for 100 days and post a link on social media with the hashtag!

  1. The opposite of tail is head and allows for exactly the same thing in reverse: head -1 will return the first line of whatever input it’s given. ↩︎

This is a self-hosted Commento server that integrates with Akismet for spam filtration. Comments that make it through are still subject to moderator (me) approval before they're displayed publicly.