From 17d3831d2da31f4ce6393254ba69a5e54f6ab8dc Mon Sep 17 00:00:00 2001 From: nl6720 Date: Wed, 3 Oct 2018 12:38:28 +0300 Subject: [PATCH] aa-notify: Read user's configuration file from XDG_CONFIG_HOME Legacy path ~/.apparmor/notify.conf is preferred if it exists, otherwise $XDG_CONFIG_HOME/apparmor/notify.conf, with fallback to ~/.config/apparmor/notify.conf, is used. PR: https://gitlab.com/apparmor/apparmor/merge_requests/215 Signed-off-by: nl6720 (cherry picked from commit 1fb9acc59eef229e4a3758c3abb3891b030b38ab) Signed-off-by: John Johansen --- utils/aa-notify | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/utils/aa-notify b/utils/aa-notify index 9c7b28be6..32c0285e9 100755 --- a/utils/aa-notify +++ b/utils/aa-notify @@ -34,7 +34,7 @@ use Getopt::Long; my %prefs; my $conf = "/etc/apparmor/notify.conf"; -my $user_conf = "$ENV{HOME}/.apparmor/notify.conf"; +my $user_conf = ""; my $notify_exe = "/usr/bin/notify-send"; my $notify_home = ""; my $notify_display = ""; @@ -156,6 +156,18 @@ if (-s $conf) { } } +# find user's notify.conf +if (-e "$ENV{HOME}/.apparmor/notify.conf" ) { + # use legacy path if the conf file is there + $user_conf = "$ENV{HOME}/.apparmor/notify.conf"; +} elsif (defined $ENV{XDG_CONFIG_HOME}) { + # use XDG_CONFIG_HOME if it is defined + $user_conf = "$ENV{XDG_CONFIG_HOME}/apparmor/notify.conf"; +} else { + # fallback to the default value of XDG_CONFIG_HOME + $user_conf = "$ENV{HOME}/.config/apparmor/notify.conf"; +} + if ($opt_p) { # notify-send is packaged in libnotify-bin on Debian/Ubuntu, libnotify-tools on openSUSE -x "$notify_exe" or _error("Could not find '$notify_exe'. Please install it (package libnotify-bin or libnotify-tools). Aborting");