Script to add ICS file to Khal

This commit is contained in:
Thomas Dehaeze 2021-10-25 14:23:15 +02:00
parent a8d1d81724
commit 5b04ad7bda

View File

@ -21,7 +21,7 @@ conflict_resolution = "a wins"
type = "caldav" type = "caldav"
url = "https://radicale.tdehaeze.xyz/tdehaeze/" url = "https://radicale.tdehaeze.xyz/tdehaeze/"
username = "tdehaeze" username = "tdehaeze"
password = "<<get-password(passname="radicale.tdehaeze.xyz/tdehaeze")>>" password = "<<get-password(passname='radicale.tdehaeze.xyz/tdehaeze')>>"
[storage radicale_calendar_local] [storage radicale_calendar_local]
type = "filesystem" type = "filesystem"
@ -38,7 +38,7 @@ conflict_resolution = "a wins"
type = "caldav" type = "caldav"
url = "https://calendar.esrf.fr/egroupware/groupdav.php/calendar" url = "https://calendar.esrf.fr/egroupware/groupdav.php/calendar"
username = "dehaeze" username = "dehaeze"
password = "<<get-password(passname="ce-esrf.fr/dehaeze")>>" password = "<<get-password(passname='esrf.fr/dehaeze')>>"
[storage esrf_calendar_local] [storage esrf_calendar_local]
type = "filesystem" type = "filesystem"
@ -60,7 +60,7 @@ fileext = ".vcf"
type = "carddav" type = "carddav"
url = "https://radicale.tdehaeze.xyz/tdehaeze/" url = "https://radicale.tdehaeze.xyz/tdehaeze/"
username = "tdehaeze" username = "tdehaeze"
password = "<<get-password(passname="radicale.tdehaeze.xyz/tdehaeze")>>" password = "<<get-password(passname='radicale.tdehaeze.xyz/tdehaeze')>>"
#+END_SRC #+END_SRC
* =khal= - CLI calendar application * =khal= - CLI calendar application
@ -163,3 +163,32 @@ search_in_source_files = no
# skip unparsable vcard files: yes / no # skip unparsable vcard files: yes / no
skip_unparsable = no skip_unparsable = no
#+END_SRC #+END_SRC
* =ics-add= - Add ICS file to Khal
:PROPERTIES:
:CUSTOM_ID: ics-add
:header-args:bash: :comments both :mkdirp yes
:header-args:bash+: :shebang "#!/usr/bin/env bash"
:header-args:bash+: :tangle-mode (identity #o555)
:header-args:bash+: :tangle ~/.local/bin/ics-add
:END:
This function is useful to easily add an event to =khal=.
It is for instance used in the =mutt= configuration.
To share an event by email, the currently best way to proceed is to first find the event on =khal=, press =e= to export it to a file, and then add this file as an attachment.
#+begin_src bash
if [[ -f $1 ]]; then
resp=$(echo -e "yes\nno" | rofi -i -only-match -dmenu -p "Would you like to add the event:" -mesg "`khal printics $1 | tail -n +2`")
if [[ "$resp" == "yes" ]]; then
calendar=$(echo "`khal printcalendars`" | rofi -i -only-match -dmenu -p "Save to:")
if [ -z "$calendar" ]; then
exit;
fi
khal import -a "$calendar" --batch $1 && \
dunstify "Calendar" "Even added";
fi
fi
#+end_src