mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
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 <nl6720@gmail.com>
(cherry picked from commit 1fb9acc59e
)
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
70ecff9962
commit
b0f55894f8
1 changed files with 13 additions and 1 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Reference in a new issue