Improve calendars by adding a merged calendar

The sync.sh script is responsible for getting all data from the
different sources, and synchronizes them. In addition, it crates two
merged calendars and synchronizes them as well.
This commit is contained in:
Jean-Claude 2023-04-20 16:41:11 +02:00
parent 197ba0ad68
commit fb080a369c
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
3 changed files with 101 additions and 30 deletions

View File

@ -2,38 +2,52 @@
# Available colors: black, white, brown, yellow, dark gray, dark green, dark blue, light gray, light green, light blue, dark magenta, dark cyan, dark red, light magenta, light cyan, light red
# Personal
[[Personal]]
path = /home/jeanclaude/.local/share/calendar/personal
path = /home/jeanclaude/.local/share/calendar/regular/personal_main
type = calendar
color = yellow
[[Timetable]]
path = /home/jeanclaude/.local/share/calendar/timetable
type = calendar
color = dark blue
[[Studies]]
path = /home/jeanclaude/.local/share/calendar/studies
type = calendar
color = light blue
[[TheAlt]]
path = /home/jeanclaude/.local/share/calendar/thealt
path = /home/jeanclaude/.local/share/calendar/regular/personal_thealt
type = calendar
color = light cyan
[[Gwendolin]]
path = /home/jeanclaude/.local/share/calendar/gwendolin
type = calendar
color = light magenta
# [[PersonalMerged]]
# path = /home/jeanclaude/.local/share/calendar/merged/personal
# type = calendar
# color = dark red
# Studies
[[Studies]]
path = /home/jeanclaude/.local/share/calendar/regular/studies_main
type = calendar
color = light green
[[Timetable]]
path = /home/jeanclaude/.local/share/calendar/regular/studies_timetable
type = calendar
color = light green
# [[StudiesMerged]]
# path = /home/jeanclaude/.local/share/calendar/merged/studies
# type = calendar
# color = dark red
# Shared
[[Paaractivities]]
path = /home/jeanclaude/.local/share/calendar/regular/paar_activities
type = calendar
color = yellow
# Others
[[Others]]
path = /home/jeanclaude/.local/share/calendar/others
path = /home/jeanclaude/.local/share/calendar/regular/others
type = calendar
color = dark magenta
[[Birthdays]]
path = /home/jeanclaude/.local/share/calendar/contact_birthdays
path = /home/jeanclaude/.local/share/calendar/regular/contact_birthdays
type = calendar
color = dark red
readonly = true

View File

@ -2,28 +2,53 @@
status_path = "~/.local/share/vdirsyncer/status/"
# Calendar
## Normal
[pair calendars]
## Normal: Sync general calendars and merged calendars to remote
[pair calendars_to_remote]
a = "calendars_local"
b = "calendars_nc_remote"
collections = ["from a", "from b"]
conflict_resolution = ["command", "nvim", "-d"]
collections = [
["personal_main", "personal_main", "personal"],
["personal_thealt", "personal_thealt", "thealt"],
["paar_activities", "paar_activities", "paaraktivitaeten_shared_by_gwendolin"],
["studies_main", "studies_main", "studies"],
["studies_timetable", "studies_timetable", "timetable"],
"others"
]
conflict_resolution = "a wins"
## Single File
[pair calendars_singlefile]
a = "calendars_local_singlefile"
## Merged to Remote: Merged calendars to remote
[pair calendars_merged_to_remote]
a = "calendars_local_merged_ro"
b = "calendars_nc_remote"
collections = ["from a", "from b"]
conflict_resolution = ["command", "nvim", "-d"]
collections = [
["personal_merged", "personal", "personal_merged"],
["studies_merged", "studies", "studies_merged"]
]
conflict_resolution = "a wins"
# Revert, as the only real source is coming from local
partial_sync = "revert"
## Create Single File: Sync general calendars to single file calendars
[pair calendars_to_singlefile]
a = "calendars_local"
b = "calendars_local_singlefile"
collections = ["from a"]
conflict_resolution = "a wins"
[storage calendars_local]
type = "filesystem"
path = "~/.local/share/calendar/"
path = "~/.local/share/calendar/regular/"
fileext = ".ics"
[storage calendars_local_merged_ro]
type = "filesystem"
path = "~/.local/share/calendar/merged/"
fileext = ".ics"
read_only = true
[storage calendars_local_singlefile]
type = "singlefile"
path = "~/.local/share/calendar_singlefile/%s.ics"
path = "~/.local/share/calendar/singlefile/%s.ics"
[storage calendars_nc_remote]
type = "caldav"
@ -36,7 +61,8 @@ password.fetch = ["command", "pass", "online/nc.jeanclaudegraf.ch/jeanclaude"]
a = "contacts_local"
b = "contacts_nc_remote"
collections = ["from a", "from b"]
conflict_resolution = ["command", "nvim", "-d"]
# conflict_resolution = ["command", "nvim", "-d"]
conflict_resolution = "a wins"
[storage contacts_local]
type = "filesystem"

31
Calendar/sync.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# Enable globs
shopt -s extglob
calendarPath="/home/jeanclaude/.local/share/calendar/"
# Get from singlefile
vdirsyncer sync calendars_to_singlefile
# Get from remote
vdirsyncer sync calendars_to_remote
# Push to singlefile
vdirsyncer sync calendars_to_singlefile
# Generate merged
rm -fr "${calendarPath}/merged/personal"
rm -fr "${calendarPath}/merged/studies"
mkdir -p "${calendarPath}/merged/personal"
mkdir -p "${calendarPath}/merged/studies"
cp "${calendarPath}/regular/personal_"*"/"* "${calendarPath}/merged/personal"
cp "${calendarPath}/regular/studies_"*"/"* "${calendarPath}/merged/studies"
# Push merged
vdirsyncer sync calendars_merged_to_remote
# Sync Calendar
vdirsyncer sync calendar