OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Applications => Topic started by: Martin Iturbide on September 30, 2022, 02:47:33 am

Title: To .config or not .config
Post by: Martin Iturbide on September 30, 2022, 02:47:33 am
Hi

I noticed that some Linux ported apps create their configuration files inside /.config inside the /home directory (example featherpad), but some other applications just go directly to the /home. (example Doodle, Tea).

Do you know if this is something hardcoded on the application, or if it something that can be adjust on compile time (when it is compiled on the OS/2 platform)?

I would prefer everything to try to get standarized and use /.config but I'm not sure if that should be a standard thing on the Linux apps. Is there any recommendation to use .config for Linux developers? Or was something interpreted for the OS/2 platform ports? I was not able to find about it on the internet.

Regards

Title: Re: To .config or not .config
Post by: Paul Smedley on September 30, 2022, 04:01:24 am
Plenty of *nix apps install their config into ETC/.config - there's no standardisation...
Title: Re: To .config or not .config
Post by: Dave Yeo on September 30, 2022, 04:20:04 am
It's all up to the app. Linux ports usually use $HOME, somewhere under /var for shared configs or for older ones, under /etc but if locally compiled or ported to Windows, /.config.
A well behaving program will also have fall backs, what if $HOME doesn't exist?
The screensaver for example tries for %HOME% first, then tries for the boot drive and if that fails, falls back on c:\os2\apps\SSaver\ and judging by the comments in the code, using %HOME% was a more recent addition.
Generally when porting, it is easiest to go with the flow, which usually means $HOME.
Title: Re: To .config or not .config
Post by: Paul Smedley on September 30, 2022, 08:39:54 am
Hey Dave,

Generally when porting, it is easiest to go with the flow, which usually means $HOME.

Agreed - otherwise you're just asking for code maintenance issues down the track...
Title: Re: To .config or not .config
Post by: Martin Iturbide on September 30, 2022, 05:59:16 pm
Thanks for the feedback.

I was wondering if the ".config" was standarized, because if it was, maybe that can be requested to the original develper (or project owner) of the open source project, so in the next port update it will reflected.  But since it is not standarized, I guess it can be more difficult for the original developer to agree on that.

Regards
Title: Re: To .config or not .config
Post by: Dave Yeo on September 30, 2022, 06:23:45 pm
Can always wrap the program in a cmd file that sets HOME. Have to test but something like,
Code: [Select]
@echo off
SET HOME= ./config
app.exe
exit
may work for you
Title: Re: To .config or not .config
Post by: jailbird on September 30, 2022, 08:41:13 pm
Thanks for the feedback.

I was wondering if the ".config" was standarized, because if it was, maybe that can be requested to the original develper (or project owner) of the open source project, so in the next port update it will reflected.  But since it is not standarized, I guess it can be more difficult for the original developer to agree on that.

Regards

On the *IX side, it's part of the "XDG Base Directory Specification" @ https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

$XDG_DATA_HOME defines the base directory relative to which user-specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.

$XDG_CONFIG_HOME defines the base directory relative to which user-specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

$XDG_STATE_HOME defines the base directory relative to which user-specific state files should be stored. If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.

Personally I find it annoying, but what can you do?  :)
Title: Re: To .config or not .config
Post by: Alex Taylor on October 03, 2022, 01:59:29 pm
%HOME%/.config is a Qt thing. The built-in Qt routines for reading/writing settings automatically use that location.
Title: Re: To .config or not .config
Post by: Martin Iturbide on October 03, 2022, 08:31:37 pm
%HOME%/.config is a Qt thing. The built-in Qt routines for reading/writing settings automatically use that location.

That's something I didn't expect  :o But for example Tea is a Qt app and it does not use the /.config.

Regards
Title: Re: To .config or not .config
Post by: Martin Iturbide on October 03, 2022, 08:34:35 pm
Hi

I also have a different question but related. Will it work to declare "XDG_CONFIG_HOME" to change the location (obviously for application that respect that) like:
  SET XDG_CONFIG_HOME=C:\HOME\MARTIN\.config;

Regards
Title: Re: To .config or not .config
Post by: Dave Yeo on October 03, 2022, 10:26:08 pm
Hi

I also have a different question but related. Will it work to declare "XDG_CONFIG_HOME" to change the location (obviously for application that respect that) like:
  SET XDG_CONFIG_HOME=C:\HOME\MARTIN\.config;

Regards

Only for programs that have implemented it. Grepping sources here, not many.
Amoebax, lastpass-cli, mercurial, pango, qemu, OpenTTD and some QT5 stuff.
Sure there is more but most don't seem to have implemented it.
Title: Re: To .config or not .config
Post by: Martin Iturbide on January 28, 2023, 06:43:13 pm
Hi

I get back to this subject in my mind everything I see my /Home directory. I personally prefer all the configuration of linux ported programs goes to .config.

For example, what can I say to the Dooble author so  things got stored on /Home/.config/.dooble ?
That he should adhere to use $XDG_CONFIG_HOME to store configuration files? And link him to something like https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Regards
Title: Re: To .config or not .config
Post by: Dave Yeo on January 28, 2023, 07:41:09 pm
You could try suggesting it. Problem is that it will break every install where the profile is already in .dooble, not good. You could always set DOOBLE_HOME to point to your preference.
Remember too that a leading dot in a file name on *nix systems means hidden file, so most file managers on *nix will not show these configuration files.
Title: Re: To .config or not .config
Post by: Martin Iturbide on January 29, 2023, 12:11:12 am
Hi Dave, thanks for the feedback

SET XDG_CONFIG_HOME=C:\HOME\.config;
and
SET DOOBLE_HOME=C:\HOME\.config;

Both didn't help me to put the \.dooble inside \.config. It didn't work for me.

Regards
Title: Re: To .config or not .config
Post by: Dave Yeo on January 29, 2023, 01:14:52 am
Perhaps SET DOOBLE_HOME=C:\HOME\.config\Dooble
Maybe need / instead of \
Title: Re: To .config or not .config
Post by: Martin Iturbide on January 29, 2023, 02:36:47 am
Hi Dave

I asked the Dooble author and he told me he uses "$XDG_DATA_HOME" for the config files.

So, I was able to easy up my OCD with...
  SET XDG_DATA_HOME=C:\HOME\.config

With that the Dooble files, and I guess other Linux ported software that uses "XDG_DATA_HOME" will be now on my C:\HOME\.config

But now I see that also .pki is part of Dooble. I need to know where is the author pointing that.

Regards
Title: Re: To .config or not .config
Post by: Dave Yeo on January 29, 2023, 04:02:09 am
pki is from NSS, the Netscape Security Suite. Mozilla is in charge of it and has been since they took over from Netscape.
Note that Firefox etc leave those files (actually older ones as our old browser currently ships with an older NSS) in their profile.
Edit: Looking at the source, nss\lib\sysinit\nsssysinit.c, I see this comment.
Code: [Select]
/**
 * Return the path to user's NSS database.
 * We search in the following dirs in order:
 * (1) $HOME/.pki/nssdb;
 * (2) $XDG_DATA_HOME/pki/nssdb if XDG_DATA_HOME is set;
 * (3) $HOME/.local/share/pki/nssdb (default XDG_DATA_HOME value).
 * If (1) does not exist, then the returned dir will be set to either
 * (2) or (3), depending if XDG_DATA_HOME is set.
 */

So try deleting (or moving out of the way) c:\home\.pki with Dooble closed and see where it is created with XDG_DATA_HOME set.