Calendari CalDav sincronizzati e gestiti da terminale [Update]

Circa un anno e mezzo fa avevo scritto l’articolo: Calendari CalDav sincronizzati e gestiti da terminale. Questo articolo serve come aggiornamento, dato che sono in parte cambiati i passaggi di installazione e configurazione.
Partitrò quindi direttamente dalle fasi di installazione, saltando il cappello introduttivo.

Installazione

Per i passaggi di installazione prendo, come al solito, a riferimento l’attuale Debian stabile:

[email protected]:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.6 (jessie)
Release:	8.6
Codename:	jessie

Installare pip3:

[email protected]:~# apt install python3-pip

Installare quindi khal (vdirsyncer viene installato come dipendenza):

[email protected]:~# pip3 install khal

Configurazione

Creare le direcotry necessarie:

[email protected]:~$ mkdir -p ~/.vdirsyncer/status ~/.calendars

Editare con il proprio editor di testo preferito il file ~/.vdirsyncer/config; qui sotto vi propongo un file di configurazione di esempio:

[general]
# A folder where vdirsyncer can store some metadata about each pair.
status_path = "~/.vdirsyncer/status/"
 
 
# CALDAV
[pair caldav_calendar]
a = "caldav_calendar_local"
b = "caldav_calendar_remote"
# Edit collections with your caldav calendar name (real name, not friendly name!)
# "personal" and "shared" labels are only examples. Instead, put your real caldav calendar name.
collections = ["personal", "shared"]
 
[storage caldav_calendar_local]
type = "filesystem"
path = "~/.calendars/"
fileext = ".ics"
 
[storage caldav_calendar_remote]
type = "caldav"
url = "https://mysite.caldav/caldav/"
username = "MYUSER"
password = "MYPASSWORD"
# verify_fingerprint and verify are useful only if you connect to self signed https caldav resource
#verify_fingerprint = "XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX"
#verify = false

Ora occorre far “scoprire” i calendari a vdirsyncer:

[email protected]:~$ vdirsyncer discover caldav_calendar
Discovering collections for pair caldav_calendar
caldav_calendar_local:
caldav_calendar_remote:
  - "shared" ("Agenda condivisa")
  - "personal" ("La mia Agenda")
warning: No collection "personal" found for storage caldav_calendar_local.
Should vdirsyncer attempt to create it? [y/N]: y
warning: No collection "shared" found for storage caldav_calendar_local.
Should vdirsyncer attempt to create it? [y/N]: y
Saved for caldav_calendar: collections = ["personal", "shared"]

Dopo l’operazione di discover è finalmente possibile fare un primo sync:

[email protected]:~$ vdirsyncer sync

È ora possibile configurare khal; viene fatto tutto “quasi” in automatico con il comando khal configure:

[email protected]:~$ khal configure
What ordering of year, month, date do you want to use? (You can choose the separator in the next step)
[0] year month day
[1] day month year
[2] month day year
Please choose one of the above options: 1

Now, please choose a separator
[0] -
[1] .
[2] /
Please choose one of the above options: 0
Does this look sensible to you: %d-%m-%Y (today as an example: 16-12-2016)? [y/N]: y

What timeformat do you want to use?
[0] 24 hour clock (recommended)
[1] 12 hour clock
Please choose one of the above options [0]: 0
Does this look sensible to you: %H:%M (current time as an example: 08:31)? [y/N]: y

If you use vdirsyncer to sync with CalDAV servers, we can try to load its config file and add your calendars to khal's config.
Should we try to load vdirsyncer's config? [Y/n]: y
The following collections were found:
  caldav_calendar_local: ~/.calendars/

Do you want to write the config to ~/.config/khal/khal.conf? (Choosing `No` will abort) [y/N]: y
created directory ~/.config/khal
Successfully wrote configuration to ~/.config/khal/khal.conf

Ora potete usare il comando “khal” per visualizzare il calendario e “khal interactive” per modificare gli eventi.

Automazione

Per mantenere tutto sincronizzato consiglio di adottare questo script (da salvare in /usr/bin):

#!/bin/bash
#Script /usr/bin/caldav_sync.sh
#Sicnronizzo i calendari caldav con vdirsync


#Controllo che ci sia una connessione a internet attiva
test_conn=$(nmcli g|grep -c "collegato (solo local)")
if [ $test_conn -eq 0 ]; then
	vdirsyncer sync
fi
exit 0

e quindi di far eseguire lo script da cron, aggiungendo la riga seguente al vostro crontab personale (il comando, da dare col vostro utente, è “crontab -e”):

*/10 * * * *	/usr/bin/caldav_sync.sh

Conky

Infine, se volete avere sempre sott’occhio i vostri appuntamenti, valutate la possibilità di usare questo file di configurazione di conky (riguardo a Conky, vi rimando ad un altro articolo):

# Gap between borders of screen and text
# Same thing as passing -x at command line
gap_x 25
gap_y 25

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
#xftfont Bitstream Vera Sans Mono:size=7
#xftfont Terminus:size=9

# Text alpha when using Xft
xftalpha 0.8

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window yes
#own_window_colour grey
own_window_transparent yes
own_window_argb_visual yes
own_window_argb_value 255
own_window_type normal
own_window_class conky-semi
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use a background image
background yes

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
#minimum_size 300 200

# Maximum width of widget
maximum_width 600

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no
draw_graph_borders yes

# Stippled borders?
#stippled_borders 8

# border margins
#border_margin 4

# border width
#border_width 1

# Default colors and also border colors
default_color white
color2 9fee62 # System is up to date
color3 ff4343 # Red - Number of Updates Available

default_shade_color black
default_outline_color white

# Text alignment, other possible values are commented
alignment top_right

# Subtract file system buffers from used memory?
no_buffers yes

# Set to yes if you want all text to be in uppercase
uppercase no

# Number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# Number of net samples to average
# Set to 1 to disable averaging
#net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Width and thickness of ${hr 2} bar separator
default_bar_size 150 5

# Lua rounded corners requirements
lua_load ~/.conky/draw_bg.lua
lua_draw_hook_pre draw_bg 
imlib_cache_size 0

# Distance of text from edge of widget
border_outer_margin 10

TEXT
${alignc}${font AvantGardeLTMedium:bold:size=12}${color Tan1}AGENDA${font}${color}
${font Andale Mono:size=9}${execi 300 khal calendar}${font}

Buon divertimento!

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *