]> git.rmz.io Git - dotfiles.git/commitdiff
mutt: show iCal entries in mutt
authorSamir Benmendil <samir.benmendil@ultrahaptics.com>
Mon, 2 Jul 2018 08:49:24 +0000 (09:49 +0100)
committerSamir Benmendil <samir.benmendil@ultrahaptics.com>
Mon, 2 Jul 2018 08:49:24 +0000 (09:49 +0100)
mutt/ical2txt [new file with mode: 0755]
mutt/mailcap

diff --git a/mutt/ical2txt b/mutt/ical2txt
new file mode 100755 (executable)
index 0000000..5b7c998
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+from icalendar import Calendar
+
+def format_cal(start, end, description):
+    str  = "Start: {:%Y-%m-%d %H:%M}\n".format(start)
+    str += "End:   {:%Y-%m-%d %H:%M}\n\n".format(end)
+    if description is not None:
+        str += description
+
+    return str
+
+
+with open('/dev/stdin', 'r') as f:
+    cal = Calendar.from_ical(f.read())
+
+for c in cal.walk():
+    if c.name == "VEVENT":
+        print(format_cal(
+            c.get('dtstart').dt,
+            c.get('dtend').dt,
+            c.get('description')))
index 52c4d1cfdfc7c8ed781572f0ad429c0731fb0d7f..6eb73912acfd7842625eea082c0a4b330947e89d 100644 (file)
@@ -1,4 +1,5 @@
 text/html;       $XDG_CONFIG_HOME/mutt/mutt_bgrun qutebrowser %s; test=test -n "$DISPLAY"; nametemplate=%s.html
 text/html;       w3m -I %{charset} -dump %s -T text/html -cols "$COLUMNS" -o display_link_number=1; copiousoutput; nametemplate=%s.html
+text/calendar;   $XDG_CONFIG_HOME/mutt/ical2txt; copiousoutput
 application/*;   $XDG_CONFIG_HOME/mutt/mutt_bgrun rifle -f F %s;
 image/*;         rifle -f F %s;