commit c66146b6276c2b31937a28228167126aa3a08529
parent d012394e9cf139c99029341f7b2894458708e354
Author: Jaromil <jaromil@dyne.org>
Date:   Tue, 18 Apr 2017 10:21:22 +0200
custom headers configured per-account
Diffstat:
3 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/jaro b/src/jaro
@@ -136,6 +136,7 @@ list=whitelist
 vars+=(name login imap imap_port smtp smtp_port protocol password auth accountopt)
 arrs+=(folders exclude)
 vars+=(host port type)
+vars+=(my_hdr)
 
 # global for server fingerprints
 vars+=(fingerprint)
@@ -850,6 +851,7 @@ EOF
     __empty) # unknown command, pass it to autostart
         func "no command, autostart"
         func "subcommand: $subcommand"
+		read_account "$account"
         if [[ "$subcommand" = "__empty" ]]; then
 			# open folder
 			if [[ "$option_params" = "" ]]; then
@@ -865,6 +867,7 @@ EOF
         # argument passed: determine if an email
 		subcommand=${subcommand[(ws@:@)2]}
 		func "subcommand: $subcommand"
+		read_account "$account"
         if isemail "$subcommand"; then
             notice "Composing message to: $*"
             # its an email, TODO see if we have it in our addressbook
diff --git a/src/zlibs/accounts b/src/zlibs/accounts
@@ -97,6 +97,7 @@ read_account() {
     }
 
     ttmp=`awk '
+	/^my_hdr/ { next }
     /^#/ { next }
     /^name/ { printf "name=\""; for(i=2;i<=NF;i++) printf "%s ", $i; printf "\";" }
     /^email/ { printf "email=\"%s\";", $2 }
@@ -167,6 +168,9 @@ read_account() {
     func "options: $accountopt"
     func "folders: $folders"
     func "exclude: $exclude"
+	my_hdr=`cat "$acct" | grep '^my_hdr'`
+	[[ "$my_hdr" = "" ]] ||
+		func "my_hdr:\n$my_hdr"
 
     return 0
 }
diff --git a/src/zlibs/mutt b/src/zlibs/mutt
@@ -97,7 +97,10 @@ source '$WORKDIR/.mutt/general'
 source '$WORKDIR/.mutt/formats'
 source '$WORKDIR/.mutt/keybindings'
 source '$WORKDIR/.mutt/colors'
+
+# identity built parsing accounts and global file
 source '$MAILDIRS/Identity.txt'
+source '$MAILDIRS/.mutt/identity'
 
 # pointer to password tempfile and dynamic settings
 # must be before mboxes to set folder on imap peek
@@ -113,6 +116,21 @@ source '$MAILDIRS/.mutt/notmuch'
 source '$MAILDIRS/.mutt/crypto'
 EOF
 
+	# identity
+	rm -f "$MAILDIRS/.mutt/identity"
+	touch "$MAILDIRS/.mutt/identity"
+	cat <<EOF > $MAILDIRS/.mutt/identity
+set realname = '$name'
+set from = '${name} <${email}>'
+EOF
+	[[ "$gpgkey" = "" ]] ||
+		print "set pgp_sign_as = '${gpgkey}'" >> $MAILDIRS/.mutt/identity
+	[[ -r ~/.signature ]] &&
+		print "set signature = '~/.signature'" >> $MAILDIRS/.mutt/identity
+	[[ "$my_hdr" = "" ]] ||
+		print "$my_hdr" >> $MAILDIRS/.mutt/identity
+
+
 	rm -f "$MAILDIRS/.mutt/crypto"
 	touch "$MAILDIRS/.mutt/crypto"
 	# support opmux or fallback to gpgewrap