{"id":8888,"date":"2010-10-08T10:05:04","date_gmt":"2010-10-08T10:05:04","guid":{"rendered":"http:\/\/scienceblogs.com\/gregladen\/2010\/10\/08\/using-google-calendar-from-the\/"},"modified":"2010-10-08T10:05:04","modified_gmt":"2010-10-08T10:05:04","slug":"using-google-calendar-from-the","status":"publish","type":"post","link":"https:\/\/gregladen.com\/blog\/2010\/10\/08\/using-google-calendar-from-the\/","title":{"rendered":"Using Google Calendar from the Linux Command Line"},"content":{"rendered":"<p>Computer-based calendars are very useful, and the Google Calendar is probably one of the more widely used personal calendars other than scheduling programs such as MS Outlook and Groupwise (both of which are broken).  But, webby gooey applications can be rather bothersome because they tend to take up a lot of screen real estate and other resources, and on smaller screens such as a laptop can be rendered virtually useless by all that added functionality built into the web browser itself as well as the calendar page.  It is quite possible that on your laptop, your Google Calendar may look something like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/scienceblogs.com\/gregladen\/wp-content\/blogs.dir\/472\/files\/2012\/04\/i-db80841539964342991966740f989f08-01-gcalcli.jpg?w=604\" alt=\"i-db80841539964342991966740f989f08-01-gcalcli.jpg\" data-recalc-dims=\"1\" \/><\/p>\n<p>Not very useful.<br \/>\n<!--more--><\/p>\n<div style=\"text-align: center;\"><em>~ This post is one of a series on the topic of Command Line Interface applications in Linux. <a href=\"http:\/\/scienceblogs.com\/gregladen\/command_line_interface_cli\/\"> Click here to see a list of all of the related posts.<\/a>~<\/em><\/div>\n<p>It is a little easier if you use Google Calendar&#8217;s &#8220;agenda view&#8221; which simply lists, in chronological order, the upcoming appointments, so days on which you have nothing scheduled do not take up space.  Like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/scienceblogs.com\/gregladen\/wp-content\/blogs.dir\/472\/files\/2012\/04\/i-2835438fcb35ba824f9bbf28ab03a215-02_gcalcli.jpg?w=604\" alt=\"i-2835438fcb35ba824f9bbf28ab03a215-02_gcalcli.jpg\" data-recalc-dims=\"1\" \/><\/p>\n<p>But that still kind of sucks, since the vast majority of information on that screen has little to do with the information you are looking for.  As long as a command line interface is available, which it is, wouldn&#8217;t it be nice to have a quick and dirty command that you could type in to retrieve your calendar, perhaps manipulate it, and even get a simple text-based agenda view that one can actually see?<\/p>\n<p>There is, and it&#8217;s called gcalcli.  When I type &#8220;gcalcli&#8221; into a command line with the argument &#8220;agenda&#8221;, I get this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/scienceblogs.com\/gregladen\/wp-content\/blogs.dir\/472\/files\/2012\/04\/i-96d93409adbe61ac802b5ba8011bd75d-03_gcal.cli.jpg?w=604\" alt=\"i-96d93409adbe61ac802b5ba8011bd75d-03_gcal.cli.jpg\" data-recalc-dims=\"1\" \/><\/p>\n<p>With relatively little configuration, gcalcli knows where to go and get my calendar information.  The program has lots of options, most of which are used to select among the various calendars you have access to or to configure the output. When I typed in:<\/p>\n<p><code>gcalcli list<\/code><\/p>\n<p>the program outputs a list of four calendars that I have access to.  I knew about the first two of them already.  The third is a calendar called &#8220;US Holidays&#8221; which I imagine comes along with Google Calendar.  The fourth is that of an organization I belong to, though I had forgotten about the calendar.<\/p>\n<p>One option tells the &#8220;agenda&#8221; command to include all the details within the calendar and not just the date\/time and name of event.  The calendars can be searched (but for whole words only).  Another command outputs a week&#8217;s calendar in a nice formatted arrangement:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/scienceblogs.com\/gregladen\/wp-content\/blogs.dir\/472\/files\/2012\/04\/i-1b13e74a1dbc623f24e567e2f4ad3390-04_gcalcli.jpg?w=604\" alt=\"i-1b13e74a1dbc623f24e567e2f4ad3390-04_gcalcli.jpg\" data-recalc-dims=\"1\" \/><\/p>\n<p>And, yet another outputs an entire month. Unfortunately, when I tried that I got an error and some gobbly-code.<\/p>\n<p>It is possible to add single appointments using the command &#8220;quick&#8221;:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/scienceblogs.com\/gregladen\/wp-content\/blogs.dir\/472\/files\/2012\/04\/i-109c6079e38979f55bb77632994a9b43-05_gcalcli.jpg?w=604\" alt=\"i-109c6079e38979f55bb77632994a9b43-05_gcalcli.jpg\" data-recalc-dims=\"1\" \/><\/p>\n<p>There is also a way to execute a command if an event is to occur within a certain amount of time.  This might be run on start up of a particular terminal or integrated with a chron job, to develop your own personal way of annoying yourself into getting your stuff done.<\/p>\n<p>There are lots of other options.  You can read more about it <a href=\"http:\/\/code.google.com\/p\/gcalcli\/\">here<\/a>, and if you are using Debian\/Ubuntu, you can install the software in synaptic (search for gcalcli) or by simply typing the magic words:<\/p>\n<p><code>sudo apt-get install gcalcli<\/code><\/p>\n<p>This application firmly sits in the Class II cli App category, which I&#8217;ve discussed before.  This is where you want a GUI version and a cli version of the same app, in this case, accessing the same database.  Different circumstances demand different approaches.  Learning two or three commands with gcalcli will augment your Google Calendar experience and make you look really cool at the coffee shop.  But there will still be times when the web-based GUI interface makes the most sense.<\/p>\n<p>Furthermore, and I&#8217;m sure you already know this, you can easily define and save an alias for &#8220;gcalcli agenda&#8221; (or any other combination of frequently used commands and options) so you would type only, say &#8220;agenda&#8221; or &#8220;appointments&#8221; or whatever to get the output you need on a regular basis.<\/p>\n<p>Here&#8217;s another little trick in case you want to totally geek out.  If you are using alpine for your email (I&#8217;ll discuss this great app later) you can type in ctrl-_ and call emacs as your secondary editor.  From within emacs, select some irrelevant text (that step may not be necessary) and type ctrl-u to cause the output of the next command to replace that text.  Then type shift-alt-| (the vertical bar thingie), which allows you to enter a shell command.  Then, type in<\/p>\n<p><code>gcalcli --nc agenda<\/code><\/p>\n<p>The &#8211;nc strips the output of its color coding control codes, which are messy when they are not spewed onto a terminal.  The selected text will be replaced with your agenda in nice, text form.  Save, exit, and you&#8217;re back in alpine with your email to your significant other who just asked you &#8220;Are you available Wednesday night to go pick up the new car seat?&#8221; or whatever.<\/p>\n<p>Obviously once you&#8217;ve done that a few times and perhaps refined the exact procedure, you&#8217;d make these commands into a macro so little more than a stern look and the flip of a single finger will insert your current agenda into whatever email you are currently writing.  How cool is that?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Computer-based calendars are very useful, and the Google Calendar is probably one of the more widely used personal calendars other than scheduling programs such as MS Outlook and Groupwise (both of which are broken). But, webby gooey applications can be rather bothersome because they tend to take up a lot of screen real estate and &hellip; <a href=\"https:\/\/gregladen.com\/blog\/2010\/10\/08\/using-google-calendar-from-the\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using Google Calendar from the Linux Command Line<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[4583,4278,67,866],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p5fhV1-2jm","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/posts\/8888"}],"collection":[{"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/comments?post=8888"}],"version-history":[{"count":0,"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/posts\/8888\/revisions"}],"wp:attachment":[{"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/media?parent=8888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/categories?post=8888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregladen.com\/blog\/wp-json\/wp\/v2\/tags?post=8888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}