# Syncing with clouds

Calcure can view calendars from cloud services, such as Google calendar, Nextcloud etc. Basically, you can view any .ics file published online or saved on your computer. To do that, you need to either provide a URL of your .ics file or sync your .ics files to your computer and provide the path to a single file or a folder of .ics files. Below are a few examples:

### Obtaining secret URLs of .ics files (Google calendar)

The easiest way to view events from Google calendar is to obtain a secret URL. Open your Google calendar in the browser, in My calendars section click three dots > Settings and sharing > Copy the secret address in iCal format. It should look like:

```
https://calendar.google.com/calendar/ical/myemail%40gmail.com/private-xxx/basic.ics
```

Proceed to the section about [reading from .ics files](#reading-from-.ics-files-in-calcure).

{% hint style="info" %}
This method has a few cons, namely that loading from url usually take time and only works when you have internet. It is also possible to sync Google calendars locally, similar to the example below, but it is more complicated.
{% endhint %}

### Syncing .ics files locally (Nextcloud calendar)

Install [vdirsyncer](https://vdirsyncer.pimutils.org/en/stable/index.html) to sync .ics files from your cloud to your computer:

```
pip install vdirsyncer
```

Create a configuration file called `config` at `.config/vdirsyncer/config`. This example shows a typical config file for Nextcloud server. For other servers, see the [tutorials here](https://vdirsyncer.readthedocs.io/en/stable/tutorials/index.html#servers). For example, if you have a personal and work calendars, you need to create different sync records and get two .ics files (or two folders with .ics files). The example below shows typical records to sync two calendars, "work" and "personal":

```
[general]
status_path = "~/.vdirsyncer/status/"


# Sync personal events:

[pair events_personal]
a = "events_personal_local"
b = "events_personal_remote"
collections = null

[storage events_personal_local]
type = "singlefile"
path = "~/.config/vdirsyncer/data/events_personal.ics"

[storage events_personal_remote]
type = "caldav"
url = "https://nextcloud.yourserver.com/remote.php/dav/calendars/admin/personal" # this points to personal calendar (not all calendars)
username = "..."
password = "..." # this is your app password in nextcloud


# Sync work events:

[pair events_work]
a = "events_work_local"
b = "events_work_remote"
collections = null

[storage events_work_local]
type = "singlefile"
path = "~/.config/vdirsyncer/data/events_work.ics"

[storage events_work_remote]
type = "caldav"
url = "https://nextcloud.yourserver.com/remote.php/dav/calendars/admin/work" # this points to work calendar (not all calendars)
username = "..."
password = "..." # this is your app password in nextcloud


# Sync tasks:

[pair tasks]
a = "tasks_local"
b = "tasks_remote"
collections = null

[storage tasks_local]
type = "singlefile"
path = "~/.config/vdirsyncer/data/tasks.ics"

[storage tasks_remote]
type = "caldav"
url = "https://nextcloud.yourserver.com/remote.php/dav/calendars/admin/tasks/"
username = "..."
password = "..." # this is your app password in nextcloud

```

After creating the config file, run the following to discover the config:

```
vdirsyncer discover
```

Agree to create all necessary files and folders and run the following to sync:

```
vdirsyncer sync
```

This should sync your tasks and events into `.config/vdirsyncer/data`.\
However, you can also use the `type = "fylesystem"` option if you want to sync each event as a separate .ics file.

{% hint style="info" %}
To sync the files periodically run (more details [here](http://vdirsyncer.pimutils.org/en/stable/tutorials/systemd-timer.html)): \
`systemctl --user enable vdirsyncer.timer`
{% endhint %}

### Reading from .ics files in Calcure

Now, add paths or URLs of .ics files in your Calcure config at `.config/calcure/config.ini`. Calcure will accept a URL (starting with http) or path to a single file (ending with .ics) or path to a folder of .ics files, in which case the entire folder will be parsed a one calendar. Here is an example:

```
ics_task_files = /home/username/.config/vdirsyncer/data/tasks.ics
ics_event_files = https://calendar.google.com/calendar/ical/myemail%40gmail.com/private-xxxxxxxx/basic.ics
```

You can sync more than one path or URL. Multiple entry types can be mixed, but entries must be separated by a comma without a space, like this:

```
ics_event_files = /home/username/.config/vdirsyncer/data/events_personal.ics,/home/username/.config/vdirsyncer/data/events_work.ics
```

Run `calcure` and you should see the synced tasks and events. If nothing appeared, there must have been an error. Double check everything and take a look at info.log file in config folder. If nothing helps, open an issue on [GitHub](https://github.com/anufrievroman/calcure) and provide your configs (without passwords) and info.log file from your config folder.

### Not supported yet

* End time (only the beginning time is displayed)
* Colors (currently, items are colored according to colors in config, but you can set them the same as in your cloud)
* Editing (tasks and events from .ics are only displayed but can't be edited yet)

### Troubleshooting

See [this page](https://anufrievroman.gitbook.io/calcure/troubleshooting#syncing-and-displaying-.ics-files) for typical issues and solutions.
