aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-10-12 00:55:49 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-16 11:35:20 +0200
commitc95961fc74585b4284441863c2ebc77a31ea7332 (patch)
tree9d087fbcde3920dbb39d0f6fed405cb748f74bfa /config
parent9cf69747ebc9b7d1504e07cec02866e748d57377 (diff)
downloadaerc-c95961fc74585b4284441863c2ebc77a31ea7332.tar.gz
filters: append well known dirs to exec PATH
To allow referencing built-in filters without hard coding a path during installation, append the following folders to the exec PATH when running the filter commands: ~/.config/aerc/filters ~/.local/share/aerc/filters $PREFIX/share/aerc/filters /usr/share/aerc/filters If a filter script has the same name than a command in the default exec PATH, it will not shadow it. In that edge case, the absolute path to the filter script must be specified. Suggested-by: Teo Luppi <me@luppi.uk> Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'config')
-rw-r--r--config/aerc.conf8
-rw-r--r--config/config.go6
2 files changed, 11 insertions, 3 deletions
diff --git a/config/aerc.conf b/config/aerc.conf
index 1f9c8021..dda983a4 100644
--- a/config/aerc.conf
+++ b/config/aerc.conf
@@ -302,6 +302,14 @@ reply-to-self=true
# Filters allow you to pipe an email body through a shell command to render
# certain emails differently, e.g. highlighting them with ANSI escape codes.
#
+# The commands are invoked with sh -c. The following folders are appended to
+# the system $PATH to allow referencing filters from their name only:
+#
+# ${XDG_CONFIG_HOME:-~/.config}/aerc/filters
+# ${XDG_DATA_HOME:-~/.local/share}/aerc/filters
+# $PREFIX/share/aerc/filters
+# /usr/share/aerc/filters
+#
# The first filter which matches the email's mimetype will be used, so order
# them from most to least specific.
#
diff --git a/config/config.go b/config/config.go
index faaab610..e40d964a 100644
--- a/config/config.go
+++ b/config/config.go
@@ -426,7 +426,7 @@ func buildDefaultDirs() []string {
return defaultDirs
}
-var searchDirs = buildDefaultDirs()
+var SearchDirs = buildDefaultDirs()
func installTemplate(root, name string) error {
var err error
@@ -437,7 +437,7 @@ func installTemplate(root, name string) error {
}
}
var data []byte
- for _, dir := range searchDirs {
+ for _, dir := range SearchDirs {
data, err = os.ReadFile(path.Join(dir, name))
if err == nil {
break
@@ -597,7 +597,7 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
}
// append default paths to template-dirs and styleset-dirs
- for _, dir := range searchDirs {
+ for _, dir := range SearchDirs {
config.Ui.StyleSetDirs = append(
config.Ui.StyleSetDirs, path.Join(dir, "stylesets"),
)