在 Linux 终端管理你的日历
iCal 日历 终端

> 
> KDE 很适合在 Linux 上进行基于终端的日程安排。konsolekalendar 命令让你从终端查看和管理 iCal 日历。
> 
> 
> 


![](/data/attachment/album/202204/18/161418rsp7x2evo6zl766v.jpg "Calendar close up snapshot")


我是一个 [KDE 用户](https://opensource.com/article/17/5/7-cool-kde-tweaks-will-improve-your-life)，多年来我一直在 Plasma 桌面上进行着看似无尽的探索。如果你在公开场合问我，我可能会声称自己对我每天使用的桌面了如指掌。但实际上，我只是刚刚触及到表面而已。似乎每天我都能学到一个新的 KDE 技巧，让我的生活变得更轻松或更有趣，我最新的发现是 `konsolekalendar` 命令，它让你从终端查看和管理 iCal 日历。


### Akonadi


Akonadi 项目是一个底层 KDE 框架，帮助 Plasma 桌面跟踪所有的个人信息管理器（PIM）数据。它主要是为开发者服务的，包括很多可以让程序员用来创建应用的库，通过这些程序你可以访问你的联系人、笔记、电子邮件、日历等等。Akonadi 中包括一些终端命令，比如 `akonadictl` 可以启动和停止 Akonadi 服务，但它们大多是为了排除故障。然而，`konsolekalendar` 是一个面向用户的命令，可以让你完全访问 Kontact 套件的所有数据，包括 KMail、Notes 和日历。


如果你正在运行 KDE 的 Plasma 桌面，那么你已经安装了 Kontact 套件。


![Kontact UI](/data/attachment/album/202204/18/161429yz84an34z95cu3il.jpg "Kontact UI")


你也安装好了 Akonadi 和它的工具，所以你所需要的基于终端的日历完成了!


### 从终端查看你的日历


由于 [NextCloud](https://opensource.com/article/21/1/nextcloud-productivity) 和 [Radicale](https://radicale.org/v3.html) 等项目的存在，你可以托管自己的 iCal 日历服务，或者你可能已经在流行的供应商（例如，Google）那里拥有一个 iCal 账户。当你使用 Kontact 管理日历时，你订阅了一个日历对象（用 Akonadi 的术语说是一个“<ruby> 集合 <rt>  collection </rt></ruby>”）。当你对你的本地日历进行更新时，这些变化会被送回你的 iCal 服务器以同步你的日历服务器和客户端。


无论你是否使用过 Kontact 的日历功能，你在 Kontact 中都有一些默认的日历对象。你有一个叫**个人日历**和**生日和纪念日**的日历对象。


以下是如何显示当天的日历（默认为**个人日历**）：



```
$ konsolekalendar
Date:   Saturday, January 15, 2022
        10:00 AM - 11:00 AM
Summary: Covid booster shot
UID: 8d8a1e38-c88c-4d84-99e5-23...
----------------------------------
Date:   Saturday, January 15, 2022
        12:00 PM - 01:00 PM
Summary: Lunch
UID: 7aa89a...
----------------------------------
Date:   Saturday, January 15, 2022
        01:00 PM - 04:45 PM
Summary: Afternoon coding
UID: 9cde38b...
----------------------------------
Date:   Saturday, January 15, 2022
        06:00 PM - 10:00 PM
Summary: Planescape game
UID: c73f7e98-722f-48a2-8006-66...
----------------------------------

```

### 添加一个事件


要查看你订阅的所有日历，请使用 `--list-calendars` 选项：



```
$ konsolekalendar --list-calendars
----------------------------------
3  - (Read only) Birthdays & Anniversaries
11 - Personal Calendar
60 - (Read only) Open Invitations
61 - (Read only) Declined Invitations
66 - Dnd
67 - Work
68 - Museum

```

左边的数字是日历的 ID。要添加一个事件到一个特定的日历，请使用 `--calendar` 选项，然后是日历 ID：



```
$ konsolekalendar --add --calendar 66 \
--date 2022-01-16 \
--time 20:00 --end-time 23:59 \
--summary "Another game" \
--description "Remember to bring dice" \
Success: "Another game" inserted

```

### 删除一个事件


你也可以删除事件。每个事件都有一个唯一的 ID（UID），在每个事件列表的底部提供：



```
$ konsolekalendar --list
Date:   Saturday, January 15, 2022
        06:00 PM - 10:00 PM
Summary: Planescape game
UID: c73f7e98-722f-48a2-8006-66aa8ddcf789

```

要删除一个事件，请使用 `--delete` 选项，同时使用 `--uid` 选项：



```
$ konsolekalendar --delete \
--uid c73f7e98-722f-48a2-8006-66aa8ddcf789

```

### 终端中的 Akonadi


你用 `konsolekalendar` 所做的一切都会立即在 Akonadi 中执行，并在 Kontact 中得到同样快的反映。使用一个并不意味着你必须放弃另一个。由于它们共享 Akonadi 后端，两者查看和编辑相同的数据。`konsolekalendar` 命令是一项正在进行的工作。未来的计划包括与 Kontact 的笔记和日记部分的整合，而且还有很多比本文所涉及的更多的选项。如果你在使用 KDE 桌面，试试 `konsolekalendar`，体验一下终端的 PIM！




---


via: <https://opensource.com/article/22/2/manage-calendar-linux-konsolekalender-kde>


作者：[Seth Kenlon](https://opensource.com/users/seth) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
I'm a [KDE user](https://opensource.com/article/17/5/7-cool-kde-tweaks-will-improve-your-life), and for years I've been on a seemingly endless journey of discovery with the Plasma Desktop. If you were to ask me in public, I'd probably claim to know everything there is to know about the desktop I use every day of my life. But in truth, I've actually only just scratched the surface. It seems every day I learn a new KDE trick that either makes my life easier or just more fun, and my latest discovery is the `konsolekalendar`

command, which lets you view and manage an iCal calendar from the terminal.


## Akonadi

The Akonadi project is a low-level KDE Framework that helps the Plasma Desktop keep track of all the Personal Information Manager (PIM) data. It's mostly for developers and includes lots of libraries that allow a programmer to create applications through which you can access your contacts, notes, emails, calendar, and so on. Some terminal commands are included in Akonadi, such as `akonadictl`

to start and stop the Akonadi service, but they're mostly for troubleshooting. However, `konsolekalendar`

is a user-facing command that provides you full access to all the data in the Kontact suite, including KMail, Notes, and the Calendar.

If you're running KDE's Plasma Desktop, then you already have the Kontact suite installed.

![Kontact UI Kontact UI](https://opensource.com/sites/default/files/uploads/kontact.jpg)

(Seth Kenlon, CC BY-SA 4.0)

You also already have Akonadi and its tools installed, so everything you need for terminal-based calendaring is in place!

## View your calendar from the terminal

You can host your own iCal calendaring service thanks to projects like [NextCloud](https://opensource.com/article/21/1/nextcloud-productivity) and [Radicale](https://radicale.org/v3.html), or you may already have an iCal account with popular providers (for instance, Google). When you use Kontact for calendaring, you subscribe to a calendar object (a "collection" in Akonadi's terminology). When you make updates to your local calendar, the changes get sent back to your iCal server to synchronize your calendar server and client.

Whether or not you've used the calendaring part of Kontact yet, you have some default calendar objects in Kontact. You have one called **Personal Calendar** and **Birthdays & Anniversaries**.

Here's how to display the current day's calendar (**Personal Calendar** by default):

```
$ konsolekalendar
Date: Saturday, January 15, 2022
10:00 AM - 11:00 AM
Summary: Covid booster shot
UID: 8d8a1e38-c88c-4d84-99e5-23...
----------------------------------
Date: Saturday, January 15, 2022
12:00 PM - 01:00 PM
Summary: Lunch
UID: 7aa89a...
----------------------------------
Date: Saturday, January 15, 2022
01:00 PM - 04:45 PM
Summary: Afternoon coding
UID: 9cde38b...
----------------------------------
Date: Saturday, January 15, 2022
06:00 PM - 10:00 PM
Summary: Planescape game
UID: c73f7e98-722f-48a2-8006-66...
----------------------------------
```


## Add an event

To see all calendars you've subscribed to, use the `--list-calendars`

option:

```
$ konsolekalendar --list-calendars
----------------------------------
3 - (Read only) Birthdays & Anniversaries
11 - Personal Calendar
60 - (Read only) Open Invitations
61 - (Read only) Declined Invitations
66 - Dnd
67 - Work
68 - Museum
```


The numbers on the left are calendar IDs. To add an event to a specific calendar, use the `--calendar`

option, followed by the calendar ID:

```
$ konsolekalendar --add --calendar 66 \
--date 2022-01-16 \
--time 20:00 --end-time 23:59 \
--summary "Another game" \
--description "Remember to bring dice" \
Success: "Another game" inserted
```


## Delete an event

You can also remove events. Each event has a unique ID (UID), provided at the bottom of each event listing:

```
$ konsolekalendar --list
Date: Saturday, January 15, 2022
06:00 PM - 10:00 PM
Summary: Planescape game
UID: c73f7e98-722f-48a2-8006-66aa8ddcf789
```


To delete an event, use the `--delete`

option along with the `--uid`

option:

```
$ konsolekalendar --delete \
--uid c73f7e98-722f-48a2-8006-66aa8ddcf789
```


## Akonadi in the terminal

Everything you do with `konsolekalendar`

is immediately performed in Akonadi and is reflected just as quickly in Kontact itself. Using one doesn't mean you have to give up the other. Thanks to their shared Akonadi backend, the two view and edit the same data. The `konsolekalendar`

command is a work in progress. Future plans include integration with the Notes and Journal parts of Kontact, and there are many more options available than this article covered. If you're using the KDE desktop, try `konsolekalendar`

and experience a PIM for your terminal!

## 2 Comments