change-subject-kmail.sh
· 673 B · Bash
Raw
#!/bin/bash
#
# Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
FILE="/tmp/mailtmp.txt"
OLD_SUBJECT="/tmp/mailsubject.txt"
trap "rm ${FILE}; exit" SIGHUP SIGINT SIGTERM
# create empty file
>${FILE}
if [[ -w ${OLD_SUBJECT} ]]; then
# read subject from file
oldsubject=$(<${OLD_SUBJECT})
else
# create empty file
>$OLD_SUBJECT
oldsubject="New subject"
fi
# set subject line
kdialog --inputbox "New subject:" "${oldsubject}" >${OLD_SUBJECT}
subject=$(<${OLD_SUBJECT})
# save mail in file
cat $* > ${FILE}
# change subject line
sed -i "s/^Subject: \(.*\)/Subject: ${subject}/" ${FILE}
# return file
cat ${FILE}
# delete email file
rm ${FILE}
| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com> |
| 4 | |
| 5 | FILE="/tmp/mailtmp.txt" |
| 6 | OLD_SUBJECT="/tmp/mailsubject.txt" |
| 7 | |
| 8 | trap "rm ${FILE}; exit" SIGHUP SIGINT SIGTERM |
| 9 | |
| 10 | # create empty file |
| 11 | >${FILE} |
| 12 | |
| 13 | if [[ -w ${OLD_SUBJECT} ]]; then |
| 14 | # read subject from file |
| 15 | oldsubject=$(<${OLD_SUBJECT}) |
| 16 | else |
| 17 | # create empty file |
| 18 | >$OLD_SUBJECT |
| 19 | oldsubject="New subject" |
| 20 | fi |
| 21 | |
| 22 | # set subject line |
| 23 | kdialog --inputbox "New subject:" "${oldsubject}" >${OLD_SUBJECT} |
| 24 | |
| 25 | subject=$(<${OLD_SUBJECT}) |
| 26 | |
| 27 | # save mail in file |
| 28 | cat $* > ${FILE} |
| 29 | |
| 30 | # change subject line |
| 31 | sed -i "s/^Subject: \(.*\)/Subject: ${subject}/" ${FILE} |
| 32 | |
| 33 | # return file |
| 34 | cat ${FILE} |
| 35 | |
| 36 | # delete email file |
| 37 | rm ${FILE} |
| 38 |