[pve-devel] [PATCH client 2/3] config: use more xdg compliant search path

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Jun 12 08:14:21 CEST 2018


On Tue, Jun 12, 2018 at 06:34:54AM +0200, Dietmar Maurer wrote:
> I don't really like the idea to use different file names:
> 
>  .config
>  client
>  .pveclient
> 
> ???

It's just two, not 3 ;-)

In case we ever add more tools I didn't want to recreate the mess in
/run ;-) (/run/pve-cluster/ as directory, /run/pve-cluster.pid as file,
/run/pveproxy/pveproxy.pid with the name twice including the pve prefix,
...)

The idea is to use $CONFIG/pve/client and concatenate the parts together
for the 'single dotfile in $HOME' variant as ~/.pveclient.
(Similarly, there's ~/.config/i3/config and ~/.i3config, and of course
some tools do also duplicate the names inside .config/ as well:
~/.config/FreeCAD/FreeCAD.conf, ~/.config/htop/htoprc, ...)
Of course, if we intend to have more than one file we might even want to
make .../pve/client/ a directory or at least give the config a
'.cfg' suffix.

Anyway, I'm open to suggestions. I think Rene wanted to have a .cfg
suffix, while Stoiko argued it would make editors try to use the usual
config highlighting on it which might not work well with our
SectionConfig.

> > +    # If XDG_CONFIG_HOME is not set or empty, its default is $HOME/.config
> > +    my $base = $xdg || "$home/.config";
> > +
> > +    my $filename = "$base/pve/client";
> > +    return $filename if -e $filename;
> > +
> > +    return "$home/.pveclient" if -e "$home/.pveclient";
> > +
> > +    return $filename;
> >  }
> >  
> >  sub load {
> > @@ -119,6 +133,7 @@ sub save {
> >      my ($class, $cfg) = @_;
> >  
> >      my $filename = $class->config_filename();
> > +    make_path(dirname($filename));
> >      my $raw = $class->write_config($filename, $cfg);
> >  
> >      file_set_contents($filename, $raw, 0600);
> > -- 
> > 2.11.0




More information about the pve-devel mailing list