From 0a56d15a837d6f1c231a8def148d423dde64a483 Mon Sep 17 00:00:00 2001 From: kaylee Date: Fri, 2 Feb 2024 23:52:53 +0000 Subject: [PATCH] we now use cat instead of redundant check function --- README.md | 6 +----- uvgotmail.py | 7 ++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 045b025..9c35319 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,13 @@ alerts u when u have unread messages by adding 📬 to your bash prompt - configure your imap server in `~/.uvgotmail/config` file. you can also use an existing `.muttrc` file. - add `(./uvgotmail.py --daemon &)` to the end of your `.bashrc` file -- find the line where your PS1 is set and put `\$(./uvgotmail.py --check)` at the start +- find the line where your PS1 is set and put `\$(cat ~/.uvgotmail/unread)` at the start ## OPTIONS: -### check mode - - `--mailbox-symbol [string]`: specify your own symbol instead of 📬 - `--no-count`: by default, if you have multiple messages you will get `(n) 📬` in your PS1. this option turns that off. - -### daemon mode - `--config [path]`: path to config file - `--mutt`: load server settings from .muttrc file diff --git a/uvgotmail.py b/uvgotmail.py index 9dd529b..6a94c13 100755 --- a/uvgotmail.py +++ b/uvgotmail.py @@ -184,7 +184,12 @@ def check(): def writeUnreadFile(unseen): try: with open(os.path.expanduser('~/.uvgotmail/unread'),'w') as f: - f.write(str(len(unseen))) + if len(unseen) == 0: + f.write('') + elif(len(unseen) > 1 and config["no_count"] == False): + f.write("("+str(len(unseen))+") "+config["mailbox_symbol"]+' ') + else: + f.write(config["mailbox_symbol"]+' ') except Exception as e: if config["debug"]: print(e) print("uvgotmail: could not write to unread file")