You are not logged in.

#1 2017-10-08 15:42:57

Hund
Member
From: Sweden
Registered: 2010-03-22
Posts: 479
Website

I need a little bit of help with two scripts (inotifywait/notify-send)

The first script watches for new mails and executes the other one when a new mail is found.

#!/bin/sh
MAILDIR1=$HOME/Mail/Fastmail/INBOX/new

echo "Watching $MAILDIR1"
while MAILNAME1=$(inotifywait -qe MOVED_TO --format '%f' $MAILDIR1) 
do
	echo $MAILNAME1
	mailpop $MAILDIR1/$MAILNAME1
done
#!/bin/bash
from=`formail -X From: < $1`
sub=`formail -X Subject: < $1`

# tweaks < > are special
from=${from//</\(}
from=${from//>/\)}
from=${from//&/\.}
sub=${sub//</\(}
sub=${sub//>/\)}
sub=${sub//&/\.}

sub=${sub:0:200}
from=${from:0:75}
#TM=2000

/usr/bin/notify-send -u normal "$from" "$sub" -i "/home/johan/.icons/Dunst/mail.png"

The output of the notification is:

From: <Name> (<adress>)
Subject: <Subject>

1. I can't figure out of how to remove everything but the "<Name>" and the "<Subject>"?
2. My second issue is that the output gets borked when the subject contains any of the letters å, ä or ö. The word "Bekräftelse" turns into "=?UTF-8?Q?Bekr=C3=A4ftelse?=". What's up with that?

Thank you for your time. smile

Offline

#2 2017-10-09 05:53:36

adesh
Member
Registered: 2016-10-05
Posts: 167

Re: I need a little bit of help with two scripts (inotifywait/notify-send)

fram=$(printf "$from" | awk '{print $2}')
subj=$(printf "$sub" | awk '{print $2}')

Offline

#3 2017-10-09 06:04:28

Hund
Member
From: Sweden
Registered: 2010-03-22
Posts: 479
Website

Re: I need a little bit of help with two scripts (inotifywait/notify-send)

adesh wrote:
fram=$(printf "$from" | awk '{print $2}')
subj=$(printf "$sub" | awk '{print $2}')

Thanks! I didn't think of that. smile

Offline

Board footer

Powered by FluxBB