diff options
author | Jeffas <dev@jeffas.io> | 2019-07-21 21:01:51 +0100 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-26 14:00:24 -0400 |
commit | dc4c36adbfbffd34319ddc007bad437ef802ee72 (patch) | |
tree | 1742b507d27a9564c3f51623c01266cca8f9a267 /config/config.go | |
parent | 0950e39f538610172858a5e3b7582a7f5cb1fd64 (diff) | |
download | aerc-dc4c36adbfbffd34319ddc007bad437ef802ee72.tar.gz |
Add new-email trigger
This patch sets up the trigger config section of aerc.conf.
Each trigger has its own function which is called from the place where
it is triggered. Currently only the new-email trigger is implemented.
The triggers make use of format strings. For instance, in the new-email
trigger this allows the user to select the trigger command and also the
information extracted from the command and placed into their command.
To actually execute the trigger commands the keypresses are simulated.
Further triggers can be implemented in the future.
Formatting of the command is moved to a new package.
Diffstat (limited to 'config/config.go')
-rw-r--r-- | config/config.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go index 4a049fa0..f8637292 100644 --- a/config/config.go +++ b/config/config.go @@ -84,6 +84,11 @@ type ViewerConfig struct { HeaderLayout [][]string `ini:"-"` } +type TriggersConfig struct { + NewEmail string `ini:"new-email"` + ExecuteCommand func(command []string) error +} + type AercConfig struct { Bindings BindingConfig Compose ComposeConfig @@ -91,6 +96,7 @@ type AercConfig struct { Accounts []AccountConfig `ini:"-"` Filters []FilterConfig `ini:"-"` Viewer ViewerConfig `ini:"-"` + Triggers TriggersConfig `ini:"-"` Ui UIConfig General GeneralConfig } @@ -278,6 +284,11 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { return err } } + if triggers, err := file.GetSection("triggers"); err == nil { + if err := triggers.MapTo(&config.Triggers); err != nil { + return err + } + } return nil } |