Skip to content

Commit

Permalink
Merge pull request #1025 from jonasbadstuebner/fix-whitespace-thunder…
Browse files Browse the repository at this point in the history
…bird

fix(modules,contrib,thunderbird): show not-found message; fix whitespace in inbox name
  • Loading branch information
tobi-wan-kenobi authored Jun 11, 2024
2 parents cee5f48 + b170b26 commit becd773
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bumblebee_status/modules/contrib/thunderbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def __init__(self, config, theme):
self.__home = self.parameter("home", "")
inboxes = self.parameter("inboxes", "")
if inboxes:
self.__inboxes = util.format.aslist(inboxes)
# we can not use utils.format.aslist here
# because we need the whitespace in inbox name
self.__inboxes = inboxes.split(",")

def thunderbird(self, _):
return str(self.__label)
Expand All @@ -50,6 +52,10 @@ def update(self):

counts = []
for inbox in self.__inboxes:
if not inbox in unread:
counts.append("-not-found-")
continue

count = unread[inbox]
self.__total += int(count)
counts.append(count)
Expand All @@ -63,10 +69,10 @@ def __getThunderbirdStream(self):
cmd = (
"find "
+ self.__home
+ " -name '*.msf' -exec grep -aREo '\^A1=[0-9a-fA-F]+)' {} + | grep"
+ " -name '*.msf' -exec grep -aREo '\\^A1=[0-9a-fA-F]+)' {} + | grep"
)
for inbox in self.__inboxes:
cmd += " -e {}".format(inbox)
cmd += " -e \"{}\"".format(inbox)
cmd += "| awk -F / '{print $(NF-1)\"/\"$(NF)}'"

return util.cli.execute(cmd, shell=True).strip().split("\n")
Expand All @@ -75,6 +81,9 @@ def __getUnreadMessagesByInbox(self, stream):
unread = {}
for line in stream:
entry = line.split(":^A1=")
if len(entry) < 2:
continue

inbox = entry[0]
count = str(int(entry[1][:-1], 16))
unread[inbox] = count
Expand Down

0 comments on commit becd773

Please sign in to comment.