Skip to content

Instantly share code, notes, and snippets.

@professorjamesmoriarty
Created November 19, 2016 01:34
Show Gist options
  • Save professorjamesmoriarty/6cc8d0d0a6217c55089b444ea0072cad to your computer and use it in GitHub Desktop.
Save professorjamesmoriarty/6cc8d0d0a6217c55089b444ea0072cad to your computer and use it in GitHub Desktop.
#!/bin/bash
for msgid in $(notmuch search --output=messages tag:unread); do
msgjson=$(notmuch show --format=json --body=false --entire-thread=false "$msgid")
subject=$(echo "$msgjson" | jq 'recurse(.[]?) | .Subject? | select(length > 0)' -r)
sender=$(echo "$msgjson" | jq 'recurse(.[]?) | .From? | select(length > 0)' -r)
if echo "$sender" | grep -q '<'; then
sender=$(echo "$sender" | cut -d '<' -f2 | cut -d '>' -f1)
fi
notify-send "$sender" "$subject" -i /riddlebox/Dropbox/Photos/Icons/myicon70x70.png
done
num_mail="$(notmuch count tag:unread)"
if [ "$num_mail" -gt 0 ];then
aplay /riddlebox/Dropbox/Sounds/incoming.wav
fi
#notmuch tag -unnotified tag:unnotified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment