11.03.2009 23:09

Desktop calendars

PyLendar screenshot I need a calendar app/widget on my desktop. KDE and GNOME users get one as a part of their environment. But if you use neither you are screwed as I recently found out. There are only two options, rainlendar and osmo. The first is broken with newer GTK versions for 6 months now and it's not free software (that could be a showstopper for some I imagine). Other is terribly limited by GTK, not all buttons/toolbars can be removed, it's huge by default and can't be scaled to some reasonable size and so on. Both of them are packed with functionality; notes, agenda, todo, alarms, birthdays... but I don't need that, I just want a simple calendar display with basic functions (like switching months and highlighting days), and there just isn't any.

At first I decided to keep it simple and used xmessage:

$ cal -m | xmessage -file -
Then I combined it with some lua code so I can select the month:
function calendar_select(offset)
    local datespec = os.date("*t")
    datespec = datespec.year * 12 + datespec.month - 1 + offset
    datespec = (datespec % 12 + 1) .. " " .. math.floor(datespec / 12)
    awful.util.spawn("cal -m " .. datespec .. " | xmessage -file -")

-- Then you can call (i.e. on mouse scrolls)
calendar_select(0)  -- for current month
calendar_select(1)  -- for next month
calendar_select(-1) -- for prev. month... and so on
But it was just too simple, I wanted the current day highlighted, at least. In the end I wrote my own, coded in python and pygtk. I call it PyLendar, it has only two (optional)buttons; Agenda - that calls org-mode agenda (which manages my tasks and projects), and Close that closes it (it also has a default timeout so it can close automatically). After a few days I decided to keep track of non-working days so I implemented that too along with locales. Non-working days are marked bold, and their names are shown in tooltips for the current month. I also implemented month selection on start-up so I can keep using my lua function from awesome, click or a mouse-scroll on my date widget will spawn pylendar in the top right corner of the screen.

Written by anrxc | Permalink | Filed under desktop, code