Skip to content

Commit

Permalink
Handle header names case insensitively
Browse files Browse the repository at this point in the history
  • Loading branch information
crabvk committed Sep 28, 2023
1 parent b52ebae commit 7c2988d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ bar-gmail auth
```

Then just run `bar-gmail` or `bar-gmail --format polybar` periodically to get unread messages count and new message notifications.

Credentials and session are stored in *~/.cache/bar-gmail*.

## Waybar config example
Expand Down Expand Up @@ -98,7 +99,8 @@ click-left = xdg-open https://mail.google.com/mail/u/0/#inbox
## Script arguments

See `bar-gmail --help` for the full list of available subcommands and command arguments.
Possible values for `-s`, `--sound` can be obtained with:

Possible values for `-s`, `--sound` is obtained with:

```shell
ls /usr/share/sounds/freedesktop/stereo/ | cut -d. -f1
Expand Down
2 changes: 1 addition & 1 deletion bar_gmail/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _play_sound(self):

def _send_notification(self, message):
try:
Popen(['notify-send', *self.notification_args, message['From'], message['Subject']],
Popen(['notify-send', *self.notification_args, message['from'], message['subject']],
stderr=open(os.devnull, 'wb'))
except FileNotFoundError:
pass
Expand Down
5 changes: 3 additions & 2 deletions bar_gmail/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def gmail(self):
def _filter_headers(headers: list) -> dict:
result = {}
for header in headers:
if header['name'] == 'From' or header['name'] == 'Subject':
result[header['name']] = header['value']
name = header['name'].lower()
if name in ['from', 'subject']:
result[name] = header['value']
return result

def authenticate(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bar-gmail"
version = "1.0.2"
version = "1.0.3"
description = "Get notifications and unread messages count from Gmail (Waybar/Polybar module)"
license = "MIT"
readme = "README.md"
Expand Down

0 comments on commit 7c2988d

Please sign in to comment.