aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-07-17 14:31:20 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-04 23:16:29 +0200
commitd5210acf092f3c3346c363dbe3ce5ca899fb5a24 (patch)
treeb84228cdb3ff6dbe914a4eae788fbaa9e93dca3e
parent24eab0f5ef6324b00717997f671cf1d13317bd5c (diff)
downloadaerc-d5210acf092f3c3346c363dbe3ce5ca899fb5a24.tar.gz
aerc-d5210acf092f3c3346c363dbe3ce5ca899fb5a24.zip
hooks: add account and folder to mail-received env
Add AERC_ACCOUNT and AERC_FOLDER to the environment of the mail-received hook command. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
-rw-r--r--config/aerc.conf2
-rw-r--r--doc/aerc-config.5.scd4
-rw-r--r--lib/hooks/mail-received.go4
-rw-r--r--widgets/account.go2
4 files changed, 10 insertions, 2 deletions
diff --git a/config/aerc.conf b/config/aerc.conf
index d195563b..79a3936a 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -540,7 +540,7 @@ message/rfc822=colorize
#
# Executed when a new email arrives in the selected folder
-#mail-received=notify-send "New mail from $AERC_FROM_NAME" "$AERC_SUBJECT"
+#mail-received=notify-send "[$AERC_ACCOUNT/$AERC_FOLDER] New mail from $AERC_FROM_NAME" "$AERC_SUBJECT"
#
# Executed when aerc starts
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index 0a4fd9eb..0cdad99b 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -878,13 +878,15 @@ They are configured in the *[hooks]* section of aerc.conf.
Variables:
+ - *AERC_ACCOUNT*
+ - *AERC_FOLDER*
- *AERC_FROM_NAME*
- *AERC_FROM_ADDRESS*
- *AERC_SUBJECT*
Example:
- *mail-received* = _notify-send "New mail from $AERC_FROM_NAME" "$AERC_SUBJECT"_
+ *mail-received* = _notify-send "[$AERC_ACCOUNT/$AERC_FOLDER] New mail from $AERC_FROM_NAME" "$AERC_SUBJECT"_
*aerc-shutdown* = _<command>_
Executed when aerc shuts down. Aerc will wait for the command to finish
diff --git a/lib/hooks/mail-received.go b/lib/hooks/mail-received.go
index 66622e9e..8f62be50 100644
--- a/lib/hooks/mail-received.go
+++ b/lib/hooks/mail-received.go
@@ -8,6 +8,8 @@ import (
)
type MailReceived struct {
+ Account string
+ Folder string
MsgInfo *models.MessageInfo
}
@@ -18,6 +20,8 @@ func (m *MailReceived) Cmd() string {
func (m *MailReceived) Env() []string {
from := m.MsgInfo.Envelope.From[0]
return []string{
+ fmt.Sprintf("AERC_ACCOUNT=%s", m.Account),
+ fmt.Sprintf("AERC_FOLDER=%s", m.Folder),
fmt.Sprintf("AERC_FROM_NAME=%s", from.Name),
fmt.Sprintf("AERC_FROM_ADDRESS=%s", from.Address),
fmt.Sprintf("AERC_SUBJECT=%s", m.MsgInfo.Envelope.Subject),
diff --git a/widgets/account.go b/widgets/account.go
index e9c86504..ecf357e9 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -241,6 +241,8 @@ func (acct *AccountView) newStore(name string) *lib.MessageStore {
uiConf.SortThreadSiblings,
func(msg *models.MessageInfo) {
err := hooks.RunHook(&hooks.MailReceived{
+ Account: acct.Name(),
+ Folder: name,
MsgInfo: msg,
})
if err != nil {