You are not logged in.

#1 2020-06-22 16:46:38

ffilho
Member
Registered: 2020-06-07
Posts: 21

[SOLVED] Undestanding XDG Base Directory how define my vars

Hi there,

While installing Firefox I noticed that I could use KDE file selection and print dialogs just by installing some packages and invoking the application with some parameters. That lead me to to Desktop entries/Modify environment variables wiki which mentioned a $XDG_DATA_HOME environment variable. I never noticed that before and I can't recall of any package that would define that. Trying env | grep XDG I've got this:

XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=KDE
XDG_SESSION_TYPE=x11
XDG_CURRENT_DESKTOP=KDE
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_VTNR=7
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1000

Several XDG vars, but no XDG_DATA_HOME.

After some search, I found that XDG would help me with default path and localization for user directories. Knowing this before moving on DATA_HOME, I installed XDG User Directories and create my /home/user base directories, hoping that will create the missing environment variables. No luck.
That's when I came across the fact that XDG is further bigger that I initially found.

Then I find XDG base directory wiki which explains more about XDG, mentioning DATA_HOME among other missing XDG variables on my system. It makes that user's responsibility to define them according to the specification, but how?
I can do it globally, per user and per sessions. I also can use systemd User Environment Variables, which I think is the most appropriate choice for this case. But, which is the more indicate? What's the correct approach?

I would like some help in this, pointing me to the right direction.
Besides, it will be nice if someone could let me know about more XDG configurations that would be missing on my system. That's quite new to me.

Thanks!

Last edited by ffilho (2020-06-23 01:40:32)

Offline

#2 2020-06-22 16:53:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: [SOLVED] Undestanding XDG Base Directory how define my vars

ffilho wrote:

It makes that user's responsibility to define them according to the specification, but how?

You don't need that package for this - I'm not even sure what it would do.  You just set / export the variables from wherever you'd want them defined.

ffilho wrote:

I can do it globally, per user and per sessions... What's the correct approach?

There isn't a universally "correct" approach.  It depends on what your goals are.

I just define such variables in my user's shell profile.  But if you use a DM, this will not affect most programs run from X nor will it impact other users on the same system.

None of the XDG variables are really necessary, but another commonly used one is XDG_CONFIG_HOME.  Many programs will read/store configs under the path indicated in this variable, or fall back to ~/.config if it is not set.  In this case, it's only worth setting XDG_CONFIG_HOME if you want configs from conforming programs somewhere other than ~/.config.

Last edited by Trilby (2020-06-22 16:55:20)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2020-06-22 22:09:30

ffilho
Member
Registered: 2020-06-07
Posts: 21

Re: [SOLVED] Undestanding XDG Base Directory how define my vars

Trilby wrote:
ffilho wrote:

It makes that user's responsibility to define them according to the specification, but how?

You don't need that package for this - I'm not even sure what it would do.  You just set / export the variables from wherever you'd want them defined.

ffilho wrote:

I can do it globally, per user and per sessions... What's the correct approach?

There isn't a universally "correct" approach.  It depends on what your goals are.

I just define such variables in my user's shell profile.  But if you use a DM, this will not affect most programs run from X nor will it impact other users on the same system.

None of the XDG variables are really necessary, but another commonly used one is XDG_CONFIG_HOME.  Many programs will read/store configs under the path indicated in this variable, or fall back to ~/.config if it is not set.  In this case, it's only worth setting XDG_CONFIG_HOME if you want configs from conforming programs somewhere other than ~/.config.

Hi Trilby!

After reading your reply, I'd opt to use systemd to set mine XDG variables. It seems more "compliant" since XDG_RUNTIME_DIR is set by pam_systemd. About the export being not mandatory, I think I'm stuck with it because I need a custom .desktop to Firefox to be present on my XDG_DATA_HOME/applications as shown here.

Thanks for your time and patience.

ff

Offline

#4 2020-06-23 01:39:59

ffilho
Member
Registered: 2020-06-07
Posts: 21

Re: [SOLVED] Undestanding XDG Base Directory how define my vars

Hi!

After some more search, I found out this. What a newbie mistake! Since the path is assigned by default, I didn't have to set nothing by hand, just create an applications folder into that path and start using it. So, I was wrong to assume that a XDG_DATA_HOME is mandatory to this specific case.

As Trilby said, this variables aren't necessary, since its standard values works by default.

I'll be marking this as solved. Thanks again, Trilby!

Offline

Board footer

Powered by FluxBB