I’ve been using Awesome for quite some time - more than 4 years already, and from time to time I needed a simple calendar widget - without any integrations, styles and dependencies, as simple as possible. I tried few but didn’t like them. And only today I finally decided to try to make such calendar widget for Awesome. It turned out that it’s quite simple. Here is how it looks like:
Default Awesome configuration already has time and current date widget based on textbox (~line 150 of the rc.lua):
The idea of calendar widget is to reuse
mytextclock and add naughty notification with calendar to it when mouse button clicks on it.
Let’s find out how to print calendar. Ubuntu distribution of linux has handy unitlity
cal which prints calendar for the current month with current day highlighted:
Note that highlighting is done with some unprintable characters.
After I played a bit with
cal I came up with following command:
ncal- is a bit improved version of
cal. Here it is used because strangely in
calit’s not possible to make Monday first day of week, however it’s possbile in
ncalprints transposed calendar, so it’s needed to be printed in
cal’s way, which is done by providing
-Mmakes Monday first day of week.
-3prints three months (previous, current and next) instead of one.
sedis needed for current date highlighting - it wraps current date in + and - signs, which will be handled after in lua.
And now we just connect button click signal to
mytextclock and call naughty notification with the ouput of a command above - just add the following snippet right after mytextclock declaration in rc.lua and restart Awesome: