From b46b2d22824a4feb351f27fff8dce3d6947b190b Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Wed, 15 Mar 2023 22:40:39 +0100 Subject: hooks: add aerc-shutdown Add a hook to run when aerc shuts down. The environment is supplemented with the duration aerc was alive for. References: https://todo.sr.ht/~rjarry/aerc/136 Signed-off-by: Moritz Poldrack Signed-off-by: Robin Jarry Tested-by: Bence Ferdinandy --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 9b76d0cc..99557d2b 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( "runtime" "sort" "strings" + "time" "git.sr.ht/~sircmpwn/getopt" "github.com/gdamore/tcell/v2" @@ -251,6 +252,14 @@ func main() { aerc.PushError(msg) } }() + defer func(start time.Time) { + err := hooks.RunHook( + &hooks.AercShutdown{Lifetime: time.Since(start)}, + ) + if err != nil { + log.Errorf("aerc-shutdown hook: %s", err) + } + }(time.Now()) for event := range libui.MsgChannel { switch event := event.(type) { case tcell.Event: -- cgit