From 01da7bbadb1cc91c91b453bc8a137c6b9f50a735 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 26 Jul 2023 20:28:36 -0400 Subject: [PATCH] [mail] don't notify if no email --- bin/.bin/notify-on-new-mail.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/.bin/notify-on-new-mail.py b/bin/.bin/notify-on-new-mail.py index f294d50..ed4f9fd 100755 --- a/bin/.bin/notify-on-new-mail.py +++ b/bin/.bin/notify-on-new-mail.py @@ -8,11 +8,12 @@ new_mail_list = json.loads( ) -output = "Mail's here!\n\n" -for message in new_mail_list: - msg = message[0][0] - dt = msg['headers']['Date'] - subj = msg['headers']['Subject'] - output += f"{dt}\n{subj}\n\n" +if new_mail_list: + output = "Mail's here!\n\n" + for message in new_mail_list: + msg = message[0][0] + dt = msg['headers']['Date'] + subj = msg['headers']['Subject'] + output += f"{dt}\n{subj}\n\n" -subprocess.run(["dunstify", output]) + subprocess.run(["dunstify", output])