From f10b184eb34634b9642fa83ef0f1cd8d0687a4af Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Wed, 15 Mar 2023 22:40:38 +0100 Subject: hooks: add aerc-startup hook Add a hook to run when aerc starts up. The environment is supplemented with aerc version and the path to its binary. References: https://todo.sr.ht/~rjarry/aerc/136 References: https://todo.sr.ht/~rjarry/aerc/139 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 49684c53..9b76d0cc 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ import ( "git.sr.ht/~rjarry/aerc/commands/terminal" "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/crypto" + "git.sr.ht/~rjarry/aerc/lib/hooks" "git.sr.ht/~rjarry/aerc/lib/ipc" "git.sr.ht/~rjarry/aerc/lib/templates" libui "git.sr.ht/~rjarry/aerc/lib/ui" @@ -242,6 +243,14 @@ func main() { } ui.ChannelEvents() + go func() { + defer log.PanicHandler() + err := hooks.RunHook(&hooks.AercStartup{Version: Version}) + if err != nil { + msg := fmt.Sprintf("aerc-startup hook: %s", err) + aerc.PushError(msg) + } + }() for event := range libui.MsgChannel { switch event := event.(type) { case tcell.Event: -- cgit