Re: [PATCH] XDG base directory support (history and wxt)

Ethan A Merritt <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Organization University of Washington
Message-ID <12580097.Sef9oaCgNr@stonelion>
On Sunday, 12 September 2021 07:29:51 PDT Jun. T wrote:
> I'm not a fan of XDG basedir, but moving only ~/.gnuplot to XDG
> directory may be a kind of "half done".

I am not a fan either. Neither my home nor my lab machines use XDG
except for the KDE desktop itself, so I don't even have any examples
to look it from other user applications.

The one possible advantage I see, which isn't currently in place at all,
would be to use a XDG_CONFIG file to set the default gnuplot terminal
type.  That way distros who provide separate x11/wxt/qt/dumb packages
for gnuplot installation could place a corresponding file in 
/etc/xdg/gnuplot.config to set the appropriate system default.
Users could override this in $HOME/.config/gnuplotrc or whatever the
xdg convention is.

In any case I would prefer to minimize any references to XDG in the
core source code.  I realize that the previous XDG patch already put a
chunk of code in plot.c to hande the gnuplotrc file, but wouldn't it
be better to have that code and the new patch code for the history file
live in xdg.c instead?  Then in plot.c or history.c the call site would
be:

#ifdef USE_XDG_BASEDIR
    expanded_history_filename = some_new_xdg_routine(GNUPLOT_HISTORY_FILE));
#endif
    if (!expanded_history_filename) {
	/* current code */
	expanded_history_filename = tilde_expand(GNUPLOT_HISTORY_FILE);
    }
    read_history(expanded_history_filename);
 
> Attached is a possible patch for moving ~/{.gnuplot_history,.gnuplot-wxt}
> to XDG directories (it seems qtterminal.conf is already taken care of).
> A few points to discuss:
> 
> [1] Where to save the history?
> There were three possibilities $XDG_{CONFIG,DATA,CACHE}_HOME, and probably
> DATA directory is most widely used for history (but I'm not sure).
> But to make the situation still more complicated, they added one more
> directory $XDG_STATE_HOME recently. It seems this directory is most
> suitable for history, but it is new and very few programs are using it yet,
> and I'm rather suspicious of whether many programs that are already using
> DATA (or CACHE?) directory for history will modify their code.
> (and XDG may add more basedirs to make it further complicated...)
> 
> In the attached patch I use the STATE directory,
> but I have no objection to using other directories.
> 
> Since only one file (the history file) is saved in the directory, I think
> we can save it directly under XDG ( ~/.local/state/gnuplot_history)
> instead of saving it as ~/.local/state/gnuplot/history.
> 
> [2] Migration
> With the patch, gnuplot will continue to use traditional config or history
> files in ~/ if they exist (as it does for the main config file ~/.gnuplot).
> Users must move the traditional files to XDG dirs (or remove ~/.gnuplot-wxt
> and ~/.gnuplot_history) manually if they want to migrate.

Isn't the obvious migration to set
	XDG_DATA_DIRS = $HOME:$HOME/.local/share
	XDG_CONFIG_HOME = $HOME:$HOME/.config
and so on?  Your current home directory files will be used whether or not
you have XDG enabled, so moving files is not required.
If you choose to enable XDG and move the files, that works also.

> 
> We could make gnuplot to force move traditional ones to XDG directories, but
> I rather hesitate to do this.

See above.  I see no reason to do this.
But since I'm not actually using XDG maybe I am failing to see a possible benefit.

Other comments or opinions?

	Ethan


> [3] wxWidgets
> They added a function (wxStandardPaths::FileLayout()) for supporting XDG
> basedir in wxWidgets 3.1.1.
> https://docs.wxwidgets.org/3.1.5/classwx_standard_paths.html
> But even if FileLayout is set to FileLayout_XDG, it seems I still need to set
> the full pathname of the config flie manually in wxFileConfig constructor to
> make it saved in $XDG_CONFIG_HOME/gnuplot/ (i.e., not directly under
> $XDG_CONFIG_HOME/). So I didn't use wxStandardPaths but used xdg_get_var() in
> xdg.c and manually set the full pathname of the config file.
> 
> Good thing of this is it works with older wxWidgets (3.1.x is a kind of
> development release).
> 
> I'm not familiar with wxWidgets. If there are anyone who knows wxWidgets better
> please feel free to improve the patch.
> 
> [4] Documents
> Are there any documents that need be updated?
> 
> 
> 
> 


-- 
Ethan A Merritt
Biomolecular Structure Center,  K-428 Health Sciences Bldg
MS 357742,   University of Washington, Seattle 98195-7742




_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.