Source code for i3pystatus.regex

import re

from i3pystatus import IntervalModule

[docs]class Regex(IntervalModule): """ Simple regex file watcher The groups of the regex are passed to the format string as positional arguments. """ flags = 0 format = "{0}" settings = ( ("format", "format string used for output"), "regex", ("file", "file to search for regex matches"), ("flags", " flags"), ) required = ("regex", "file") def init(self): = re.compile(self.regex, self.flags) def run(self): with open(self.file, "r") as f: match = self.output = { "full_text": self.format.format(*match.groups()), }