How to integrate Google Calendar in Linux desktop

Google Calendar is one of the most popular web applications. One can access or sync Google Calendar across multiple devices either via web interface or with native apps. In Linux, there are several ways to access Google Calendar natively, such as by using email client plugins (e.g., Evolution or Thunderbird) or calendar apps (e.g., Sunbird or Rainlendar). These solutions, however, typically involve installing unnecessarily bulky software which you will probably not need.

If all you want is to access and get reminded by Google Calendar natively on Linux, then you can consider Google Calendar command line interface (or gcalcli), which is much more light-weight. Even better for Linux desktop, you can use gcalcli together with Conky, to integrate Google Calendar into your desktop theme transparently.

In this tutorial, I will demonstrate how to integrate Google Calendar into Linux desktop, by using gcalcli and Conky.

Install gcalcli on Linux

Before installing gcalcli, verify that you are using Python 2, as gcalcli is not compatible with Python 3.

To install gcalcli on Debian, Ubuntu or Linux Mint, use the following commands.

$ sudo apt-get install git python-pip python-gdata python-dateutil python-gflags python-vobject python-parsedatetime
$ sudo pip install google-api-python-client
$ sudo pip install apiclient urllib3
$ git clone https://github.com/insanum/gcalcli.git
$ cd gcalcli
$ sudo python setup.py install

Note: gcalcli is included in the standard repository of Ubuntu or Linux mint. However, that version is not updated with the latest features and bug fixes. So I recommend building gcalcli from the source, as documented above.

To install gcalcli on Fedora, CentOS or RHEL, run the following.

$ sudo yum install git python-pip python-gdata python-dateutil python-gflags python-vobject
$ sudo pip install google-api-python-client
$ sudo pip install apiclient urllib3
$ git clone https://github.com/insanum/gcalcli.git
$ cd gcalcli
$ sudo python setup.py install

Google Authentication for gcalcli

To be able to access Google Calendar with gcalcli, you need to go through OAuth2 authention with your Google account, in order to grant gcalcli permission to access your Google Calendar.

The first time you run gcalcl, OAuth2 authentication will automatically be initiated. Thus run the following command to start.

$ gcalcli agenda

The command will print out a URL as shown below.

At the same time, it will pop up a web browser window, and direct you to the URL. If a web browser window fails to open for any reason, you can copy and paste the URL into a web browser window manually.

If you are not logged in to your Google account, you will be asked to log in. After logging in, you will see the following message, asking you to allow gcalcl to manage your Google Calendar. Click on "Accept" button.

Enable Google Calendar API

After authentication, the next step is to enable API access for Google Calendar. gcalcli accesses your Google Calendar via Google Calendar API. In order to use Google Calendar API, however, you need to explicitly enable the API under your Google account.

First go to: https://cloud.google.com/console. Click on "API Project" under project list.

Go to "APIs & auth" --> "APIs" to see a list of Google APIs. Click on toggle button for "Calendar API" to enable the API.

Now go to "APIs & auth" --> "Registered apps" to register gcalcli app. Click on "Register app" button on the top.

Fill in the app name (e.g., "My Gcalcli"), and choose "Native" as a platform. Click on "Register" button to finalize.

This will create and show OAuth client ID and secret as follows. Make a note of this information. You can ignore the warning saying that "You have not set up your product name".


The result of OAuth authentication will be saved in ~/.gcalcli_oauth text file.

Access Google Calendar from the Command Line with gcalcli

You are almost ready to access Google Calendar with gcalcli.

Create a gcalcli configuration file in your home directory as follows. Put OAuth client ID and secret that you obtained before, in the following format.

$ vi ~/.gcalclirc
--client_id='XXXXXXXXXX.apps.googleusercontent.com'
--client_secret='YYYYYYYYYYYYYYYY'

At this point, you should be able to run gcalcli from the command line.

Try the following two commands, which will print a list of your Google Calendars, and an agenda for the next 5 days, respectively.

$ gcalcli list
$ gcalcli agenda

Integrate gcalcli with Conky

The final step is to integrate the output of gcalcli into your desktop theme. For that, you need Conky, which is a very powerful tool that can display a wide range of information directly on desktop theme.

First install Conky on your Linux system.

Then, create a following script somewhere in your home directory (e.g., ~/bin).

$ vi ~/bin/gcal.sh
#!/bin/sh

gcalcli --conky calw 2 |
    sed -e 's/^[(0\x71^[(B/?/g' \
        -e 's/^[(0\x78^[(B/?/g' \
        -e 's/^[(0\x6A^[(B/?/g' \
        -e 's/^[(0\x6B^[(B/?/g' \
        -e 's/^[(0\x6C^[(B/?/g' \
        -e 's/^[(0\x6D^[(B/?/g' \
        -e 's/^[(0\x6E^[(B/?/g' \
        -e 's/^[(0\x74^[(B/?/g' \
        -e 's/^[(0\x75^[(B/?/g' \
        -e 's/^[(0\x76^[(B/?/g' \
        -e 's/^[(0\x77^[(B/?/g'
$ chmod +x ~/bin/gcal.sh

Important Note: '^[' in the above script must be the actual ESCAPE key (i.e. press Ctrl-V ESC in vi editor).

This script translates VT100 escape sequences to Unicode box drawing characters. This is a needed workaround because Conky does not support ASCII line art used by gcalcli.

Finally, create a Conky configuration file in your home directory as follows.

$ vi ~/.conkyrc
alignment top_right
maximum_width 630
minimum_size 330 10
gap_x 25
gap_y 50

own_window yes
own_window_type conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_transparent yes
own_window_argb_visual yes
own_window_argb_value 0

update_interval 300
background no

border_width 1
default_color cornflowerblue
default_outline_color white
default_shade_color white
double_buffer no
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
max_port_monitor_connections 64
max_specials 512
max_user_text 16384
text_buffer_size 8096
no_buffers yes
out_to_console no
uppercase no
use_xft yes
xftfont Bitstream Vera Sans Mono:size=10

TEXT
*** Google Calendar Agenda ***
${execpi 300 gcalcli --conky agenda}
${execpi 300 ~/bin/gcal.sh}

This Conky configuration will display an agenda and two weeks' worth of schedules of your Google Calendar, directly in your desktop theme. The displayed info is updated every 5 minutes.

Now you can activate Conky by running the following.

$ conky

You should see Google Calendar in the right side of your Linux desktop as follows.

Once you verify that Google Calendar shows up correctly, you can set Conky to auto-start every time you log in to your desktop.

Set up Google Calendar Reminder

gcalcli can also send a reminder for any upcoming schedule in your Google Calendar. It uses notify-send command to send desktop notifications. For Google Calendar reminder, you can set up a cron job like the following.

$ crontab -l
*/10 * * * * /usr/local/bin/gcalcli remind

E2E(端到端)测试是一种软件测试方法,用于模拟实际用户工作流程,以确保系统在各个层面的交互和功能都能正常运行。在Microsar中,集成E2E测试需要以下步骤: 1. 定义测试场景:根据系统的需求和功能,定义需要测试的场景,包括用户交互、系统响应和数据传输等方面。 2. 编写测试用例:根据定义的测试场景,编写相应的测试用例,包括输入数据、预期输出和测试步骤等内容。 3. 配置测试环境:搭建适合进行E2E测试的环境,包括硬件设施、网络连接和数据模拟等。 4. 开发测试脚本:根据定义的测试用例,使用适合的测试工具或编程语言,开发E2E测试脚本,以模拟实际用户操作并验证系统功能。 5. 运行测试:在搭建好的测试环境中,运行开发好的测试脚本,观察系统的响应和输出结果,以验证系统在端到端的交互和功能是否正常。 6. 分析测试结果:根据测试运行的结果,分析系统在不同场景下的表现,发现并解决潜在的问题和缺陷。 7. 集成到开发流程:将E2E测试集成到Microsar的开发流程中,例如自动化测试框架或持续集成工具中,以确保每次代码修改都能够通过端到端的测试验证。 通过以上步骤,可以有效地将E2E测试集成到Microsar中,提高系统的质量和稳定性,确保系统在不同层面的交互和功能都能够正常运行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值