aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go16
-rw-r--r--config/openers.go29
2 files changed, 32 insertions, 13 deletions
diff --git a/config/config.go b/config/config.go
index ef824279..20e28bd2 100644
--- a/config/config.go
+++ b/config/config.go
@@ -9,7 +9,6 @@ import (
"unicode"
"github.com/go-ini/ini"
- "github.com/google/shlex"
"github.com/kyoh86/xdg"
"github.com/mitchellh/go-homedir"
@@ -117,17 +116,6 @@ func installTemplate(root, name string) error {
}
func (config *AercConfig) LoadConfig(file *ini.File) error {
- if openers, err := file.GetSection("openers"); err == nil {
- for mimeType, command := range openers.KeysHash() {
- mimeType = strings.ToLower(mimeType)
- if args, err := shlex.Split(command); err != nil {
- return err
- } else {
- config.Openers[mimeType] = args
- }
- }
- }
-
if triggers, err := file.GetSection("triggers"); err == nil {
if err := triggers.MapTo(&config.Triggers); err != nil {
return err
@@ -186,6 +174,9 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
if err := config.parseStatusline(file); err != nil {
return nil, err
}
+ if err := config.parseOpeners(file); err != nil {
+ return nil, err
+ }
if err = config.LoadConfig(file); err != nil {
return nil, err
}
@@ -196,7 +187,6 @@ func LoadConfigFromFile(root *string, accts []string) (*AercConfig, error) {
return nil, err
}
- logging.Debugf("aerc.conf: [openers] %#v", config.Openers)
logging.Debugf("aerc.conf: [triggers] %#v", config.Triggers)
if err := config.parseTemplates(file); err != nil {
diff --git a/config/openers.go b/config/openers.go
new file mode 100644
index 00000000..d41c5455
--- /dev/null
+++ b/config/openers.go
@@ -0,0 +1,29 @@
+package config
+
+import (
+ "strings"
+
+ "git.sr.ht/~rjarry/aerc/logging"
+ "github.com/go-ini/ini"
+ "github.com/google/shlex"
+)
+
+func (config *AercConfig) parseOpeners(file *ini.File) error {
+ openers, err := file.GetSection("openers")
+ if err != nil {
+ goto out
+ }
+
+ for mimeType, command := range openers.KeysHash() {
+ mimeType = strings.ToLower(mimeType)
+ if args, err := shlex.Split(command); err != nil {
+ return err
+ } else {
+ config.Openers[mimeType] = args
+ }
+ }
+
+out:
+ logging.Debugf("aerc.conf: [openers] %#v", config.Openers)
+ return nil
+}