]> git.rmz.io Git - dotfiles.git/blobdiff - mutt/ical2txt
mutt: show iCal entries in mutt
[dotfiles.git] / mutt / ical2txt
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')))