]> git.proxmox.com Git - pve-client.git/commitdiff
Helpers.pm: new helper configuration_directory
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 15 Jun 2018 05:21:13 +0000 (07:21 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 15 Jun 2018 07:17:29 +0000 (09:17 +0200)
Read configs from XDG_CONFIG_HOME/pveclient/ first.
if XDG_CONFIG_HOME is not set, then use $HOME/.config/pveclient/

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;