]> git.proxmox.com Git - pve-client.git/blobdiff - PVE/APIClient/Helpers.pm
Helpers.pm: new helper configuration_directory
[pve-client.git] / PVE / APIClient / Helpers.pm
index cc1951401d3247b5682a35857a164471f71cf8d0..8a96e8135a7fa47f6d6a94f2b167bd7a11d70fa4 100644 (file)
@@ -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;