khal
khal copied to clipboard
Import .ics file from (neo)mutt to khal
Hi,
I am a big neomutt user for the management of my emails. When emails arrive with an attached.ics calendar file (for an appointment), I can't pipe it in khal.
I do get a request to be included in the agenda but the operation is aborted.
I have the impression that there is a time zone problem. My config looks like this:
[locale]
dateformat = %d/%m/%Y
longdateformat = %d/%m/%Y
datetimeformat = %d/%m/%Y %H:%M
longdatetimeformat = %d/%m/%Y %H:%M
firstweekday = 0
weeknumbers = left
#local_timezone = Europe/Paris
default_timezone = Europe/Paris
If you have an idea to solve this problem, it would help me! Thank you.
The issue about the timezone is "just" a warning and should not prevent khal from importing the event.
To me, it looks more like the interactive part is somehow not working (khal not getting any of your user input). Can you try khal import -a Perso --batch
as the import command (or, of course, use any of your other calendars)?
Hi @bepolymathe
I had the same issue, but I fixed it by passing the calendar.ics filepath instead of piping the contents. I have this line in my mailcap file:
# this did not work:
# text/calendar; khal -a my_calendar import;
text/calendar; khal import -a my_calendar %s;
The -a
flag is probably not necessary for you as it looks like you import into the default calendar.
That's great, it works! How could I not have thought of that before? Thank you to you @matt-snider Have a good day.
Just one more question. Do you have a solution to send an invitation to an event by combining khal and mutt (and only to receive)?
@bepolymathe Glad I could help! :smile:
Currently I don't think there is a way to do this. (neo)mutt contains all the functionality to do it, but if I'm not mistaken, there are few pieces missing for khal to support it.
Attachments not sourced from the filesystem (i.e. output or created by other programs) is supported in (neo)mutt/mailcap via the new-mime
command. This is normally bound to n
when composing a message. The command used to create the attachment must be specified with the compose
flag in the mailcap file.
So, for example, with the following line in your mailcap, run new-mime
and set the prompt values to name: calendar.ics
, Content-Type: text/calendar
:
text/calendar; khal import -a my_calendar %s; compose=nvim %s;
This is just an example to show you the compose functionality. It will open the calendar.ics file in neovim for editing, but of course you aren't going to write it by hand. At the moment there is no way of exporting an event from khal and that is the issue. There is however #839. This would help, but there would still be the issues of finding the event. I think for this there would ideally be an interactive search command:
$ khal search --interactive --output ics
Then events could be filtered interactively, and the selected event could be exported to standard output as ics. (neo)mutt would then be able to save this as an attachment.
Thank you for that clarification. That's interesting. What do you think of that @geier ?
Hi @bepolymathe
I had the same issue, but I fixed it by passing the calendar.ics filepath instead of piping the contents. I have this line in my mailcap file:
# this did not work: # text/calendar; khal -a my_calendar import; text/calendar; khal import -a my_calendar %s;
The
-a
flag is probably not necessary for you as it looks like you import into the default calendar.
Yes! I use the same hack, except I actally (ab)use the print action of mailcap, because I wrote a little parser for "view": https://git.madduck.net/etc/mutt.git/blob/HEAD:/.mutt/icalparser so that I can use it with aauto_view
and get an overview first before importing.
Thanks @madduck it's a good idea ;-)
@madduck Nice solution! So after viewing, do you import with a separate keybinding or the regular (non-print) part of the mailcap entry? Could you post the relevant line of your mailcap file?
Ah sorry it is of course in the same repo:
text/calendar; ~/.mutt/icalparser; description=iCal details; copiousoutput; print=khal import --batch
I just made a small bash script that prints the event in the ICS file, and then ask on which calendar to save this event. Cheers
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
@tdehaeze I don't know what dunstify
is, and I have not installed rofi
just now, but I am wondering: doesn't import
already ask you where to import to?
Here is what I get with my "print" hack:
2021-09-03 20:00-2021-09-03 22:00 Foo appointment
Which calendar do you want to import to? (unique prefixes are fine)
foo(0), bar(1), madduck(2), baz(3), bam(4), faa(5) [madduck]:
dunstify
is an alternative for notify-send
: just a way to send a notification to the user.
rofi
is an alternative to dmenu
which is a just a simple menu displayed to the user.
I was not aware to the fact that the import
now asked you where to import the ics, this is great!