From 625d6a0b9db42198707c68f3081dde89b4084770 Mon Sep 17 00:00:00 2001 From: Josip Janzic Date: Mon, 3 Dec 2018 12:35:06 +0100 Subject: [PATCH] Add options to skip certain events (#673) --- i3pystatus/calendar/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/i3pystatus/calendar/__init__.py b/i3pystatus/calendar/__init__.py index 033b39c..a1d5c0a 100644 --- a/i3pystatus/calendar/__init__.py +++ b/i3pystatus/calendar/__init__.py @@ -1,4 +1,5 @@ import inspect +import re import threading from abc import abstractmethod from datetime import datetime, timedelta @@ -119,6 +120,8 @@ class Calendar(IntervalModule, ColorRangeModule): ('format', 'Format string to display in the bar'), ('backend', 'Backend to use for collecting calendar events'), ('skip_recurring', 'Whether or not to skip recurring events'), + ('skip_all_day', 'Whether or not to skip all day events'), + ('skip_regex', 'Skip events with titles that match this regex'), ('update_interval', "How often in seconds to call the backend's update method"), ('urgent_seconds', "When within this many seconds of the event, set the urgent flag"), ('urgent_blink', 'Whether or not to blink when within urgent_seconds of the event'), @@ -128,6 +131,8 @@ class Calendar(IntervalModule, ColorRangeModule): required = ('backend',) skip_recurring = False + skip_all_day = False + skip_regex = None interval = 1 backend = None update_interval = 600 @@ -160,8 +165,12 @@ class Calendar(IntervalModule, ColorRangeModule): self.backend.update() def valid_event(ev): + if self.skip_all_day and not isinstance(ev.start, datetime): + return False if self.skip_recurring and ev.recurring: return False + if self.skip_regex and re.search(self.skip_regex, ev.title) is not None: + return False elif ev.time_remaining < timedelta(seconds=0): return False return True