[SOLVED] Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
newlyminted7
Level 5
Level 5
Posts: 537
Joined: Sat Jan 02, 2021 4:44 pm

[SOLVED] Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Post by newlyminted7 »

Is there any way to query my Evolution calendar using the command line? I'm looking for a way to view the next few upcoming events from my calendar on the command line. I've searched around online to no avail. Does anyone know if this is possible?
Last edited by newlyminted7 on Wed Jun 23, 2021 3:51 pm, edited 1 time in total.
User avatar
xenopeek
Level 25
Level 25
Posts: 25607
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Post by xenopeek »

Interesting question. I don't normally use Evolution for calendar but added two events and tried to find where Evolution stores them. Looks that the calendar is stored in the file ~/.local/share/evolution/calendar/system/calendar.ics. I planned an event BLUEFOG tomorrow 10am and BROWNBOAR same time the day after. Just some random names unique enough so that I could have a good chance to find in which file they were stored. Here's the contents of the ~/.local/share/evolution/calendar/system/calendar.ics file after adding these two events:

Code: Select all

BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Ximian//NONSGML Evolution Calendar//EN
VERSION:2.0
X-EVOLUTION-DATA-REVISION:2021-06-14T06:08:24.953542Z(4)
BEGIN:VEVENT
UID:34c939803474460d56dae58f15497ea0b0957d1b
DTSTAMP:20210614T060432Z
DTSTART:20210615T100000Z
DTEND:20210615T103000Z
SEQUENCE:3
SUMMARY:BLUEFOG
TRANSP:OPAQUE
CLASS:PUBLIC
CREATED:20210614T060647Z
LAST-MODIFIED:20210614T060726Z
END:VEVENT
BEGIN:VEVENT
UID:d817c93986b2115aa621878c19d6fadc4a5346ee
DTSTAMP:20210614T060432Z
DTSTART:20210616T100000Z
DTEND:20210616T103000Z
SEQUENCE:2
SUMMARY:BROWNBOAR
TRANSP:OPAQUE
CLASS:PUBLIC
CREATED:20210614T060824Z
LAST-MODIFIED:20210614T060824Z
END:VEVENT
END:VCALENDAR
Perhaps there is some command line tool out there to query .ics files? If that's in your tool box it should be doable to write a script to do that yourself in an afternoon or two? I found this topic https://stackoverflow.com/questions/340 ... ing-python discussing how to do that and the vobject library mentioned there (python3-vobject package) is installable on Linux Mint. I think with a Python script and this vobject library you don't need to write your own .ics file processing code but just script with the vobject library to query the .ics file for what you're interested in.

I found several other topics discussing scripting processing .ics files like https://stackoverflow.com/questions/373 ... -with-bash but that's rather hacky compared to the above. And I found this Perl script https://waynemorrison.com/software/vcal which can query a .ics file but it assumes one event per file while Evolution stores all events in one file so this script is not useful for Evolution data files.

In my search I did find https://github.com/tobixen/calendar-cli which is ready made what you want I think but it doesn't work with .ics files but with online CalDAV servers. If your Evolution calendar is synced with a calendar linked to your email account (like Gmail or FastMail) that could be just what you want.
Image
User avatar
AndyMH
Level 17
Level 17
Posts: 7390
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Post by AndyMH »

I have a conky that displays events for the next week. I pull the events directly from my email server with wget, although it would probably be quicker to parse the local evolution ics files. Note - I'm pulling the events from the server and not the local file because the local ics file is probably only the local calendar - it's a while since I did this.

Don't think a bash script is appropriate, parsing the ics file(s) is not straightforward, so better with another language. I used pascal simply because it's the language I'm most familiar with, python might be a better choice. The program pulls the events from the server, parses them (do they fall within the next week, is it a single event or recurring, if recurring what frequency - days, weeks, years?, adjust time for GMT/BST) and writes out the conky script. It is not something you can knock off in an afternoon.
Screenshot from 2021-06-14 11-02-57.png
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 4 x Thinkpad T430 Cinnamon 20.1, 2 x i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
newlyminted7
Level 5
Level 5
Posts: 537
Joined: Sat Jan 02, 2021 4:44 pm

Re: Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Post by newlyminted7 »

Thank you both, that's great information. I like that Conky layout, Andy, I will probably emulate it somewhat for my calendar events display.
And I looked at those links, Xenopeek, thank you very much. I'm trying out the iCalendar python library (https://icalendar.readthedocs.io/en/latest/api.html). I've got something about halfway done, and maybe I'll post it when it's finished. It's just a python script that queries the local .ics files, and I'll call that from Conky every hour or so. We'll see how it goes.
User avatar
AndyMH
Level 17
Level 17
Posts: 7390
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Post by AndyMH »

For info, this is the conky config file that is auto-generated by my pascal program:

Code: Select all

-- This file is computer generated, do not edit
conky.config = {
  background = true,
  use_xft = true,
  xftalpha =  6.00000000000000000022E-0001,
  update_interval = 300,
  total_run_times = 0,
  own_window = true,
  own_window_class = 'Conky',
  own_window_argb_visual = true,
  own_window_argb_value = 156,
  own_window_type = 'normal',
  own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
  own_window_colour = '3B3838',
  double_buffer = true,
  minimum_width = 380,
  minimum_height = 150,
  maximum_width = 960,
  border_inner_margin = 5,
  draw_shades = false,
  draw_outline = false,
  draw_borders = false,
  alignment = 'bottom_middle',
  no_buffers = true,
  uppercase = false,
  override_utf8_locale = false,
  font = 'Chandas Regular:size=10',
  default_color = 'white',
  color1 = 'CCFFCC',
  color2 = 'yellow',
}
-- end of conky config settings

conky.text = [[
${font Chandas Regular:bold:size=10}${color1}Diary ${hr 2}${font}
${color}${voffset 5}16${goto 28}Jun${goto 57}Wed${goto 95}Boiler service${goto 360}1015
${color}${voffset 5}17${goto 28}Jun${goto 57}Thu${goto 95}---${goto 360}
${color}${voffset 5}18${goto 28}Jun${goto 57}Fri${goto 95}---${goto 360}
${color}${voffset 5}${color2}19${goto 28}Jun${goto 57}Sat${goto 95}---${goto 360}
${color}${voffset 5}${color2}20${goto 28}Jun${goto 57}Sun${goto 95}Green bins${goto 360}
${color}${voffset 5}21${goto 28}Jun${goto 57}Mon${goto 95}---${goto 360}
${color}${voffset 5}22${goto 28}Jun${goto 57}Tue${goto 95}Blue bin${goto 360}
]];
note the syntax is the new conky format. conky.config is static, does not change, conky.text changes depending on what events fall in the next week. I have it running once a day on startup.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 4 x Thinkpad T430 Cinnamon 20.1, 2 x i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
newlyminted7
Level 5
Level 5
Posts: 537
Joined: Sat Jan 02, 2021 4:44 pm

Re: Command line interface to Evolution Data Server (to see upcoming Calendar events)?

Post by newlyminted7 »

Awesome, thanks AndyMH.
Post Reply