Command-Line Cloud: gcalcli
If you follow my columns in Linux Journal, you probably are aware that I'm a big fan of the command line. When it comes to getting things done efficiently, most of the time the command line can't be beat. This has led me to integrating services like instant messaging and Twitter into BitlBee so I can use them with my command-line IRC client Irssi (both written up in previous LJ issues).
You probably also are aware that unlike some other Linux Journal writers out there (I'm looking at you Bill Childers), I'm a bit more skeptical of cloud services. That said, in this day and age, it seems you can't escape cloud services, so what's a guy like me to do? Well, I've just figured out how to use cloud services from the comfort of my green-on-black terminal. So, I figured it might be interesting to write a few articles describing how you can access various cloud services from the command line.
The first cloud service I thought I'd cover also is one of the most prevalent: Google Calendar. Although a lot of calendaring options exist, in a corporate environment, you often are talking about either Exchange (usually larger, older-school companies) or Google Apps (usually smaller startups). Google Calendar can be pretty convenient as a shared calendar, particularly if you are issued an Android device at work. Plus, like with all major cloud services, you can collaborate and share your data with other people (like the NSA). My main problem with Google Calendar always has been having to open up a browser every time I want to view my calendar. Although I'm sure some people are logged in to the Gmail Web interface all day and get meeting notifications that way, I'm not. Because I'm usually glued to my terminal window, I often don't see those reminders. After missing a few meetings, I decided I needed to find some way to put meeting notifications inside my terminal.
The CLI to Google Calendar that worked for me was gcalcli. It provides a command-line interface to view your calendar in various formats and also lets you add events—all from the command line.
gcalcli itself was not packaged for my distribution, so installation took me a few extra steps. First, I cloned the project's git repository into a local directory named src that I use to keep track of source code (feel free to replace this with the directory you use for the same purpose). Then, I created a symlink to the included script so I could start identifying what Python libraries I'd need:
$ cd ~/src/ $ git clone https://github.com/insanum/gcalcli.git $ sudo ln -s ~/src/gcalcli/gcalcli /usr/local/bin/gcalcli
At this point, I tried to launch the application but noticed I was missing a few required Python libraries, such as gflags, dateutil, httplib2 and google-api-python-client. The first three had Debian packages, so I was able to install them with:
$ sudo apt-get install python-gflags python-dateutil ↪python-httplib2
The final Python library wasn't packaged in Debian. For better or worse, it seems just about every modern scripting language has its own implementation of Perl's CPAN, so I fell back to using Python's pip (which I first had to install):
$ sudo apt-get install python-pip $ sudo pip install --upgrade google-api-python-client
With all of the libraries in place, you are ready to set up gcalcli to use your Google account. The first time gcalcli is run, it will set up your account, but if you are not running it from your local machine, you will want to add an extra argument the first time you launch it so it can provide you with a URL to load locally to authorize gcalcli:
$ gcalcli agenda --noauth_local_webserver
Once it's set up, you can see your current calendar agenda with the
agenda command (the events have been changed to protect the innocent):
$ gcalcli agenda Mon Jul 15 9:15am Space out and stare at screen 10:00am Meeting with the Bobs 11:00am Remodel Cubical Wall 11:45am Lunch at Flinger's 1:00pm Meeting with Michael
I've found the
agenda output to be the most useful for
seeing what's on my plate
for the day; however, you also can use
calm to output ASCII-art-style weekly and monthly calendars, respectively (Figure 1).
Figure 1. gcalcli Screenshot from the Official Project Page
Kyle Rankin is VP of engineering operations at Final, Inc., the author of many books including Linux Hardening in Hostile Networks, DevOps Troubleshooting and The Official Ubuntu Server Book, and a columnist for Linux Journal. Follow him @kylerankin
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide
|Natalie Rusk's Scratch Coding Cards (No Starch Press)||Feb 17, 2017|
|Own Your DNS Data||Feb 16, 2017|
|IGEL Universal Desktop Converter||Feb 15, 2017|
|Simple Server Hardening||Feb 14, 2017|
|Server Technology's HDOT Alt-Phase Switched POPS PDU||Feb 13, 2017|
|Bash Shell Script: Building a Better March Madness Bracket||Feb 09, 2017|
- Own Your DNS Data
- Simple Server Hardening
- Linux Makes Wi-Fi Happen in New York City
- Understanding Firewalld in Multi-Zone Configurations
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- From vs. to + for Microsoft and Linux
- Bash Shell Script: Building a Better March Madness Bracket
- IGEL Universal Desktop Converter
- Returning Values from Bash Functions
- The Weather Outside Is Frightful (Or Is It?)