How to Manage Google Calendar From Command Line And Display It On Your Desktop

I don’t think I need to do any introduction on Google Calendar. It is one of the most popular web based calendar and if you have a Google account (or a Gmail account), you already have a Google Calendar account.

To add events/appointment to your Google Calendar, the most primitive way is to open your web browser, login to the Google Calendar site and add an event. What about the geekiest (and fastest) way? By the command line, of course.

Gcalcli is a Python application that allows you to access and manage your Google Calendar from a command line. You can use it to retrieve your agenda, event list, and quickly add new events. What’s more, it can also be used as a reminder service to help you remember the things that you need to do.

Gcalcli is included in the Ubuntu repository, which means you can easily install via the Ubuntu Software Center, Synaptic Package Manager, or simply with the command line:

Before we start, we need to create the configuration file. Open a text editor. Paste the following lines:

Replace “yourusername” with your Google account login name, without the gmail.com.

Replace “yourpassword” with your Google login password.

Save the file in your home folder with the filename .gcalclirc (don’t forget the “.” in front of the galclirc and no file extension is required)

To test it, open a terminal and type

gcalcli-agenda

It should show your agenda for the next 5 days.

To get a quick glance of your next 2 weeks agenda

gcalcli-calw

Whole month agenda

gcalcli-calm

You can also set gcalcli to show a reminder popup if the event is within 10 minutes from the current time.

gcalcli-remind

One thing though, there is no automation for the reminder service, so you need to run the command everytime to remind you of your event. A good way to automate it is via crontab or using gnome-schedule

To add an event to Google calendar, use the command

Replace the <event> with a brief description of the time, date and event detail. For example:

To get Google Calendar onto your desktop, we are going to use a combination of gcalcli and conky.

Install conky:

Open a text editor and paste the following text:

Save the file in your Home directory with the filename .conkyrc

Press Alt + F2. Type in “conky” and press Enter.

gcalcli-run-application

Your agenda for the next 4 weeks will now appear on your desktop and it will refresh every 5 minutes.

gcalcli-on-desktop

Need more help on gcalcli? Check out their HowTo wiki.

Try it out and let us know if it works for you.

48 comments

  1. Sweet!
    I'm fairly new to Linux though, so I have a few questions:

    – Is there any way I can set the column width in conky? I find it hard to read my events when the text is as compressed at it is now. Also, since I have a lot written down in my calendar, many of the events fall below the screen.

    – Is there anyway to make conky work with calenders that are imported from another account? They show up when I launch gcalcli from the command line, but not in conky.

    – Is it really safe to write down your email password in a file just like that? Is there anything that can be done to protect it, like encrypt it or something?

    Thanks for the tutorial!
    Joel

  2. – Is there any way I can set the column width in conky? I find it hard to read my events when the text is as compressed at it is now. Also, since I have a lot written down in my calendar, many of the events fall below the screen.

    Ans: You can use the “–width=20” parameter to change the character count in each column. Example: gcalcli –nc –width=20 –cals=owner calw 4

    – Is there anyway to make conky work with calenders that are imported from another account? They show up when I launch gcalcli from the command line, but not in conky.

    Ans: The parameter in the conky “–cals=owner” shows only the main calendar. you can omit out this parameter to get it to display all calendars.

    – Is it really safe to write down your email password in a file just like that? Is there anything that can be done to protect it, like encrypt it or something?

    Ans: Pidgin also stores your password in a text file. So if you are fine with that, you should be fine with this too. If you are running this on your personal computer, it should be fine. If you are on a shared computer, this is not advisable.

  3. Thank you!
    Both your tips works great, however I came up with four more things:

    1. The lines separating the columns do not align straight for some reason. Instead of looking like this:
    l
    l
    l
    l

    They are broken between some of the days, like this:
    l
    l
    l
    l

    2. Is there anyway to show my tasks in the calendar? I guess that might be a hard one since I can't get it to work in thunderbird either.

    3. Can I get the week to start with Monday instead of Sunday?

    4. Is there any way to omit the time on events that I have marked as “all day events” in my gmail calendar? Right now they show up as starting at 12am which is just distracting.

    That would be all!

  4. Hmmm, some spaces were left out… The first question should read (using dots instead of spaces):

    1. The lines separating the columns do not align straight for some reason. Instead of looking like this:
    ..l
    ..l
    ..l
    ..l

    They are broken between some of the days, like this:
    ..l
    …..l
    …l
    .l

  5. Everything is fine, but when I run 'conky'(both from Alt+f2 and terminal), calender is not coming up on the Desktop.

  6. The command line works fine (gcalcli calm) etc but when I do Alt-F2 and type conky I get a window on my desktop with running proceses, CPU usage, uptime etc. Any thoughts about getting the calendar to come up instead please?

    Great Tip, thank you for posting it.

  7. I just get “failed to authenticate with google calendar”
    My user does not have .gmail.com after it and the password is right.
    any ideas?
    Cheers

  8. I had this, deleted the file I had created and retried, worked fine then, but I know the user name and password were correct the first time. Funky.

  9. gcalcli works fine in terminal layout good. but conky just creates a mess.
    Running terminal reveals “window type overide” as i can't paste all messages from conky (the disqus interface is horrible) that may or may indicate the problem.
    Any suggestions?

  10. What variables control the position of the conky display when using two monitors? Currently, with your example config it is centered between the two, and thus split. I found two monitor related variables here: http://conky.sourceforge.net/variables.html but can't figure out how to use them to only display the calendar on the right monitor.

  11. I think conky is not reading your new .conkyrc file. Did you put it in the right place?
    I get the same, but that's because I'm using the default .conckyrc file

  12. See if conky is working at all… try running “conky -o”. If that doesn't work try restoring your .conkyrc file to the default and run “conky -b -o”
    Are you running compiz?

  13. Are you replacing all those lines before “TEXT” with only these 7 lines? Could you post your whole .conkyrc file?

  14. That's right. I found that own_window gave problems with transparency, that double_buffer took over the desktop without own_window & that the other conky defaults gave acceptable results. Although I increased the update_interval to stop the single buffer flicker.

    I also added in a few other conky functions that I thought were cool.

    Screenshot here
    http://www.facebook.com/photo.php?pid=4760178&i

    My file is now:
    (xxx replaces my calendar names)

    alignment br
    draw_shades yes
    use_xft yes
    xftfont DejaVu Sans Mono:size=10
    gap_x -90
    gap_y 10
    update_interval 10
    text_buffer_size 8096

    TEXT
    $hr
    ${execi 900 gcalcli –nc –cal 'xxx' –cal xxx –cal 'xxx' agenda}
    $hr
    ${color grey}Uptime:$color $uptime
    ${color grey}Processes:$color $processes ${color grey}Running:$color $running_processes
    ${color grey}Name PID CPU% MEM%
    ${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
    ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
    ${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
    ${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}

  15. For me, it worked the first time. If you can't get it to authenticate, delete the file and recreate the file. It should work the second time.

  16. You need to copy/paste the code to a text editor and save it as .conkyrc in your home folder. if you didn't save to the home folder, it will read from the default conky config file, which result in the cpu usage etc.

  17. That's cool. Thanks for sharing. There is countless way to configure conky and I am glad that you have found one that work great for you.

  18. OK, here's how I got it working:
    I started with vayira's minimal configuration and started adding other lines from the config given on this page. I found out that vayira's config works just as fine as adding other stuff, so I just changed the position and color.
    I did have to go to /etc/X11/xorg.conf
    and add
    Load “dbe”
    after
    Section “Module”

    One thing that I found out is that corky conflicts with compiz pretty bad: when I change from desktop to desktop I loose my backgrounds (I have a different one on each desktop and I get an ugly compiz background), the animations when minimizing/maximizing a window stay on the screen… there are other other side effects to be found.

    I'm not willing to exchange compiz for gCal on my desktop… anyone knows how to work around this problem?

  19. I like how you display your agenda :)

    I finally got it working, but I have a problem… please see my post above (or below?) and hopefully you can help!

  20. I'm using ubuntu 9.10 with gnome, compiz (with lots of effects) & eight desktops with one background for all. No probs like the ones you describe.

  21. Somehow I got it running… I don't think anything, I just changed the .conkyrc to the default and back to what I had before.
    I did have to use own_window. I also used double_buffer to stop the flickering.
    I do get the same background under conky's text for all backgrounds because conky uses pseudo-transparency, which I don't mind too much, the only thing that I wish I could remove is conky from the taskbar. I only get it in the taskbar if I set
    own_window_type to normal, if I use desktop or override I get problems with the X/compiz.

  22. There could be a problem for those who use hosted account.
    I tried changing the domain name but still I think it is required to modify more things specially in google api clientLogin where accountType parameter should be “HOSTED”…

    Is there any future plans to allow hosted users to use it

  23. for hosted accounts,
    try changing it to the following to test it:

    self.gcal.ClientLogin(
    username='useremail@DOMAINNAME',
    password=self.password,
    service='cl',
    source=__author__+'-'+__program__+'-'+__version__,
    account_type='HOSTED')

    That worked for me.

  24. I keep getting the same error, user/pass is correct and even tried adding @gmail.com to be sure. Deleted and recreated the file, still no go :(

  25. Could clarify on which file I need to manipulate and what parameters need to be filled in on that script?

    • It’s possible you’re just not using a fixed-width font. Using the font monospace (the font my terminal uses) made mine line up nicely. To use monospace write ${font monospace} before ${execi gcalcli…}. And in case you were wondering, ${font} changes the font to the default, which is useful if you’re using conky to display other things.

  26. Unfortunately I can't make it work.

    .conkyrc

    TEXT
    hi there

    It is rendered on my desktop
    In a command line if I type gcalcli –nc –cals=owner calw 4, I see the result.

    However with that
    ${execi 300 gcalcli –nc –cals=owner calw 4

    I can't see anything

  27. There is something wrong with the following line:

    update_interval 1.0

    If I don't put it in the .conkryrc, it works fine but without transparency though. I suppose that the command “own_window_transparent yes” is ignored.

  28. I found out in the documentation of conky that

    execi: Same as exec but with specific interval. Interval can't be less than update_interval in configuration.

    This means that it is incorrect to type update_interval 1.0. It is strange that it worked for the others. I suppose that it is not needed.

  29. Hi,

    I would like to know if you know about how to append Google Task with conky. I don’t see any googletask based from command line.

  30. How do I remove this? I installed it no problems but I can’t work out how to get it off my desktop!
    Thanks in advance!

    • To get it off your desktop, just kill conky: “killall conky”
      To remove gcalcli, “sudo apt-get autoremove gcalcli”

Comments are closed.

Sponsored Stories