Last active 1731166974

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