This single-file Python script mutt-ical.py
displays and replies to Icalendar invitations (.ics files) from mutt.
It requires Mutt and Python with the Vobject Python package that can be installed with pip install --user git+https://github.com/py-vobject/vobject
.
Copy the script into a folder in your $PATH
, (or specify the $PATH
in your mailcap
and muttrc
files).
Mark it executable by chmod +x
.
We will assume that you copied it into ~/bin
so that its full path is ~/bin/mutt-ical.py
.
v
after having selected a mail in mutt), add to your mailcap
file (found at '~/.mailcap
, /etc/mailcap
or $mailcap_path
set in muttrc
) the following lines:text/calendar; ~/bin/mutt-ical.py -D %s; copiousoutput
text/x-vcalendar; ~/bin/mutt-ical.py -D %s; copiousoutput
application/ics; ~/bin/mutt-ical.py -D %s; copiousoutput
auto_view text/calendar text/x-vcalendar application/ics text/plain text/html
alternative_order text/calendar text/x-vcalendar application/ics text/plain text/html
Here the second line ensures that the calendar entry is displayed before the message text.
a
in the attachment view (usually opened by hitting v
after having selected a mail in mutt), add to your .muttrc a line such asmacro attach a \
"<pipe-entry>iconv -c --to-code=UTF-8 > ~/.cache/mutt.ics<enter><shell-escape>~/bin/mutt-ical.py -i -e your.email@address -s 'msmtp --account=work' ~/.cache/mutt.ics<enter>" \
"answer appointment request"
Here you need to customize the email address your.email@address
and the send command msmtp --account=work
.
If -s
is not set, the Mutt setting $sendmail
will be used.
Ical
, run xdg-open ~/.cache/mutt.ics
(on Linux, respectively open ~/.cache/mutt.ics
on Mac OS) after the mutt-ical.py
command, for examplemacro attach a \
"<pipe-entry>iconv -c --to-code=UTF-8 > ~/.cache/mutt.ics<enter><shell-escape>~/bin/mutt-ical.py -i -e your.email@address -s 'msmtp --account=work' ~/.cache/mutt.ics && xdg-open ~/.cache/mutt.ics<enter>" \
"reply to appointment request"
If you configure auto_view (as above), then the description should be visible in
the pager.
(Otherwise view the attachements (usually by hitting 'v'), select and open the Icalendar
entry.)
To answer, just open the Icalendar
file from mutt:
The script supports the following options: -i
, -a
, -d
, -t
, -D
, and -s
. The -e
option followed by an email address and the path to an .ics
file are required.
If the -D
option is used, the script will display the event details and terminate without sending any replies.
The -i
, -a
, -d
, and -t
options are mutually exclusive;
the last one specified determines the response type sent.
By default, the script will use Mutt's sendmail setting to send the answer, unless the -s
option is used to override it.
-e <your.email@address>
Specify the email address to send the answer from. This should be the email address that received the invitation.
-i
Interactive mode. Prompt for user input to accept, decline, or tentatively accept the invitation.
-a
Accept the invitation automatically without prompting.
-d
Decline the invitation automatically without prompting.
-t
Tentatively accept the invitation automatically without prompting.
-D
Display only. Show the event details but do not send any answer.
-s <sendmail command>
Specify the sendmail command to use for sending the email. If not set, the default Mutt setting will be used.
filename.ics
The .ics file to be processed. This should be the invitation file received.
Usage:
mutt-ical.py [OPTIONS] -e your@email.address filename.ics
Make sure to replace the placeholder your.email@address
with your actual email address and filename.ics
with the path to the .ics file when running the script.
Mac OS X iCal Users can force iCal to stop trying to send mail on your behalf by replacing
the file /Applications/iCal.app/Contents/Resources/Scripts/Mail.scpt
with your
own ActionScript. Martin Sander went with the following: error number -128
Which tells it that the user cancelled the action.
/Applications/iCal.app/Contents/Resources/Scripts/Mail.scpt
just in case you want to re-enable the functionality.This forks Martin Sander's whose (MIT) license restrictions apply, and which was inspired by accept.py and Rubyforge.org Samples.