From 0ca370283dcfe778a1ff2473e4952dbf13a40683 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 15 Jun 2018 07:21:13 +0200 Subject: [PATCH] Helpers.pm: new helper configuration_directory Read configs from XDG_CONFIG_HOME/pveclient/ first. if XDG_CONFIG_HOME is not set, then use $HOME/.config/pveclient/ --- PVE/APIClient/Helpers.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm index cc19514..8a96e81 100644 --- a/PVE/APIClient/Helpers.pm +++ b/PVE/APIClient/Helpers.pm @@ -273,4 +273,18 @@ sub poll_task { return $task_status->{exitstatus}; } +sub configuration_directory { + + my $home = $ENV{HOME} // ''; + my $xdg = $ENV{XDG_CONFIG_HOME} // ''; + + my $subdir = "pveclient"; + + return "$xdg/$subdir" if length($xdg); + + return "$home/.config/$subdir" if length($home); + + die "neither XDG_CONFIG_HOME nor HOME environment variable set\n"; +} + 1; -- 2.39.2