Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

customize Debian 11 evironment in lightdm (and in general?)

215 views
Skip to first unread message

Giovanni Biscuolo

unread,
May 5, 2022, 1:00:06 PM5/5/22
to
Hello,

I'm trying to customize my user environment when using the lightdm
display manager (then the LXDE desktop environment)

I need to customize some variables so I can see Guix installed
applications in my desktop menu, in particular I need to customize
XDG_DATA_DIRS and XDG_CONFIG_DIRS

I set up configuration files according to this "Quick Guide" chapter in
the "Environment Variables" wiki page:
https://wiki.debian.org/EnvironmentVariables#Quick_guide

This is my ~/.profile:

--8<---------------cut here---------------start------------->8---

### Guix settings
#
# add Guix current path
export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
# Locale path
export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
# add Guix infopath
export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
# set default Guix profile
export GUIX_PROFILE="$HOME/.guix-profile"
# source default Guix profile
. $GUIX_PROFILE/etc/profile

--8<---------------cut here---------------end--------------->8---

and this is my ~/.xsessionrc:

--8<---------------cut here---------------start------------->8---

if [ -f ~/.profile ]; then
. ~/.profile
fi

export XSESSION_WAS_HERE="Yes"

--8<---------------cut here---------------end--------------->8---

When I log in via lightdm to an LXDE session, I open LXterminal to check
my environment and I find:

--8<---------------cut here---------------start------------->8---

patrizia@raifort:~$ env | grep XDG
XDG_CONFIG_DIRS=/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_MENU_PREFIX=lxde-
XDG_DATA_HOME=/home/patrizia/.local/share
XDG_CONFIG_HOME=/home/patrizia/.config
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=lightdm-xsession
XDG_SESSION_TYPE=x11
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/patrizia
XDG_CURRENT_DESKTOP=LXDE
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_VTNR=7
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1001
XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

patrizia@raifort:~$ systemctl --user show-environment | grep XDG
XDG_RUNTIME_DIR=/run/user/1001
XDG_DATA_DIRS=/home/patrizia/.guix-profile/share
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/patrizia
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=lightdm-xsession
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11

--8<---------------cut here---------------end--------------->8---

As shown above, the "env" result and the "systemctl --user
show-environment" are slightly different, in particular I'm missing
XDG_DATA_DIRS as configured in my ~/.profile

If in the LXTerminal I start a login bash shell with "bash -l" I get:

--8<---------------cut here---------------start------------->8---

patrizia@raifort:~$ env | grep XDG
XDG_CONFIG_DIRS=/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_MENU_PREFIX=lxde-
XDG_DATA_HOME=/home/patrizia/.local/share
XDG_CONFIG_HOME=/home/patrizia/.config
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=lightdm-xsession
XDG_SESSION_TYPE=x11
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/patrizia
XDG_CURRENT_DESKTOP=LXDE
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_VTNR=7
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1001
XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

patrizia@raifort:~$ systemctl --user show-environment | grep XDG
XDG_RUNTIME_DIR=/run/user/1001
XDG_DATA_DIRS=/home/patrizia/.guix-profile/share
XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/patrizia
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_CLASS=user
XDG_SESSION_DESKTOP=lightdm-xsession
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11

--8<---------------cut here---------------end--------------->8---

Now the XDG_DATA_DIRS is fine.

The problem is that the lightdm (and LXDE) XDG_DATA_DIRS is missing
"/home/patrizia/.guix-profile/share" and this is the reason why
applications installed with Guix are not listed in my menu.

I searched extensively on the web how to fix this issue but I was not
able to find the cause and related "workaround".

I see that similar problems are described in this bugs:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927907
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931776

Please is there a way to fix my problem?

Is there a way to customize my environment in a standard way that works
with all display managers and desktop environments?

Thank you for your help!

Happy hacking, Gio'

--
Giovanni Biscuolo

Xelera IT Infrastructures
signature.asc

Greg Wooledge

unread,
May 5, 2022, 2:30:05 PM5/5/22
to
On Thu, May 05, 2022 at 06:48:49PM +0200, Giovanni Biscuolo wrote:
> I'm trying to customize my user environment when using the lightdm
> display manager (then the LXDE desktop environment)

OK.

> This is my ~/.profile:
>
> --8<---------------cut here---------------start------------->8---
>
> ### Guix settings
> #
> # add Guix current path
> export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
> # Locale path
> export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
> # add Guix infopath
> export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
> # set default Guix profile
> export GUIX_PROFILE="$HOME/.guix-profile"
> # source default Guix profile
> . $GUIX_PROFILE/etc/profile
>
> --8<---------------cut here---------------end--------------->8---

Note that your .profile has NOTHING about XDG in it. (It's also not
sourcing ~/.bashrc which is bad, but maybe you simply never work in
a login shell, so you never noticed it.)

> and this is my ~/.xsessionrc:
>
> --8<---------------cut here---------------start------------->8---
>
> if [ -f ~/.profile ]; then
> . ~/.profile
> fi
>
> export XSESSION_WAS_HERE="Yes"
>
> --8<---------------cut here---------------end--------------->8---

OK.

> As shown above, the "env" result and the "systemctl --user
> show-environment" are slightly different,

That's not a surprise.

> in particular I'm missing
> XDG_DATA_DIRS as configured in my ~/.profile

XDG_DATA_DIRS is not configured in your .profile.

To this day I've never found an actual use for systemctl --user. It
runs things when you login, and those things operate in some sort of
pristine daemonic environment, kind of like a cron job, but not quite
as bare.

The fact that you've apparently found some use for it is a surprise.
Maybe some day I'll find one as well.

Anyway, the environment provided to things launched by systemctl --user
is not the same as your interactive session's environment.

> When I log in via lightdm to an LXDE session, I open LXterminal to check
> my environment and I find:
>
> patrizia@raifort:~$ env | grep XDG
> [...]
> XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

> If in the LXTerminal I start a login bash shell with "bash -l" I get:
>
> patrizia@raifort:~$ env | grep XDG
> [...]
> XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

> Now the XDG_DATA_DIRS is fine.

Interesting. I'm not familiar with LXDE or LXterminal. Did they follow
GNOME's lead? Is LXterminal spawned as child of some daemon like dbus,
instead of a child of your X session?

It certainly looks that way.

You have my pity.

(Also, it's not clear where your XDG_DATA_DIRS variable is actually
coming from. Is it from that $GUIX_PROFILE/etc/profile thing that's
dotted in from your .profile? Or is it from some other magical place?)

If you need to customize your *shell* environment when you're working
under a cursed desktop like GNOME (and apparently LXDE?) where the
terminal does not inherit the X session's variables, you might need to
seek out GNOME (or LXDE) people who have already tackled that problem,
and find out how they deal with it.

If you actually need to customize your systemctl --user environment, I
think there are manuals for how to do that. I believe there's a special
command that you can run to inject environment variables into the
systemctl --user daemon from outside. But it's been a long time since I
looked at that stuff, and it was never my primary intention to learn how
to configure systemctl --user. It was simply knowledge that I glimpsed
as a side effect of the thing I was actually trying to do (find a shell-
and DE-agnostic way to configure the login session). Which it turns out
is not a thing systemd supports.

> Is there a way to customize my environment in a standard way that works
> with all display managers and desktop environments?

(And shells. That's a big one.)

If there is, I have never found it.

The systemd/XDG people clearly do not care about this. They provide no
means of doing it. Their documentation doesn't even address the issue.
It's like the *concept* of a user customizing their own login environment
never occurred to any of them.

The GNOME people made it even worse, by launching their terminal as a
child of a daemon that is not part of the session. Nothing gets inherited
in the ways that a Unix user expects. Every new instance of gnome-terminal
has the generic, default, non-customized environment. The only way *I*
know of to change anything in that environment is to do it at the shell
level, *after* gnome-terminal has launched a shell. Because you can't
do it at the GNOME level, that's for sure.

Now, I don't know LXDE, but from your descriptions, it certainly sounds
like LXDE shares some of these characteristics with GNOME.

So, if you really do need to override the environment at the shell level,
you'd be looking at the ~/.bashrc file, assuming bash is your shell.
That's the file that bash reads when it's run as an interactive, non-login
shell -- which is what you should get when you launch an LXterminal,
for example. It's also the file that it'll read when you type "bash"
with no arguments, or when you do a shell escape out of a text editor,
or anything else that launches a shell in a normal way.

In a traditional Unix setup, all of your environment variables would be
set in ~/.profile which is read by your login shell, which is spawned
by login(1) when you login on your terminal. Then you can run 'startx'
or whatever, which starts an X session which is a child of your login
shell, and therefore inherits all of the stuff that was set in .profile.
The X session launches a window manager, and the window manager can
launch terminals on demand. The terminals inherit the environment from
the WM, which inherited it from the X session, which inherited it from
the login shell.

Your desktop environment clearly doesn't work that way, though.

David

unread,
May 5, 2022, 7:20:05 PM5/5/22
to
On Fri, 6 May 2022 at 04:24, Greg Wooledge <gr...@wooledge.org> wrote:
> On Thu, May 05, 2022 at 06:48:49PM +0200, Giovanni Biscuolo wrote:

> > I'm trying to customize my user environment when using the lightdm
> > display manager (then the LXDE desktop environment)

Hello

TLDR: try defining the variables you need in ~/.xsessionrc

I don't have time to read the detail of the OP message, but
I use LXDE on Debian 11, so I can offer some information
that might be useful to others in the thread.

I configured all this years ago and it has been working ever since,
so I have forgotten all the details.

To achieve the same LXDE login configuration and environment
as a console login, I have these two lines in $HOME/.xsessionrc:
. "/etc/profile"
. "${HOME}/.profile"

(the double quotes just highlight strings in my editor)

The file $HOME/.xsessionrc is sourced by
/etc/X11/Xsession
via
/etc/X11/Xsession.d/40x11-common_xsessionrc
which contains this self-documentation:
# This file is sourced by Xsession(5), not executed.
# Source user defined xsessionrc (locales and other environment variables)

Some do-it-yourself tracing that I have placed into my scripts
when I was trying to figure out how to get this working informs me that
this is the sequence of events:
lightdm(1310) > lightdm(1393) > Xsession(1414) . ~/.xsessionrc
lightdm(1310) > lightdm(1393) > Xsession(1414) . ~/.profile
lightdm(1310) > lightdm(1393) > Xsession(1414) . ~/bin/_my_export
lightdm(1310) > lightdm(1393) > lxsession(1414) > lxpanel(1503) >
x-terminal-emul(2403) > bash(2433) . ~/.bashrc
The format of this data is:
"parent(PID) > subparent(PID) > process(PID)
some_statement_invoked_in_a_sourced_script_indented_if_child_of_above_script"
The indented statements at the far right show the statements being
executed in my instrumented scripts.

So it appears that . ~/.profile runs when Xsession starts,
but ~/.bashrc is not run until I manually open a terminal
in LXDE, which appears in the above as x-terminal-emul.

I assume that Xsession and lxsession are the same process
because they have the same PID.

I have chosen to use lxterminal to provide x-terminal-emul.
One quirk of lxterminal is that there is only one process
which handles all open terminal windows.

~/bin/_my_export file is where I set and export environment variables
so that this file can be sourced by either ~/.profile or ~/.bashrc
as needed.

Greg Wooledge

unread,
May 5, 2022, 7:40:05 PM5/5/22
to
On Fri, May 06, 2022 at 09:16:09AM +1000, David wrote:
> So it appears that . ~/.profile runs when Xsession starts,
> but ~/.bashrc is not run until I manually open a terminal
> in LXDE, which appears in the above as x-terminal-emul.

Your .profile should be written to dot in ~/.bashrc if it's being run
by bash. E.g. something like:

test "$BASH_VERSION" && test -r ~/.bashrc && . ~/.bashrc

In the absence of this, you will not have the desired shell environment
if you ever use a login shell -- e.g. if you hit Ctrl-Alt-F2 and login
on a console, or if you ssh into the system.

If you never do either of these things, well, you're fine.

> I assume that Xsession and lxsession are the same process
> because they have the same PID.

In a proper universe, the former would exec (chain-load) the latter.

> I have chosen to use lxterminal to provide x-terminal-emul.
> One quirk of lxterminal is that there is only one process
> which handles all open terminal windows.

Sounds atrocious.

If you ever feel bored, you could run this experiment, and see what
happens:

1) Put "umask 002" in your ~/.xsessionrc file.

2) Log out and back in.

3) Open an lxterminal.

4) Type "umask" and see what it's set to.

If my conclusions from the OP's post are correct, it will report 0022,
the Debian system default, totally ignoring your attempt to customize it.

Less invasively, a process tree showing the ancestry of a shell running
inside an lxterminal would be helpful. Something like this:

unicorn:~$ pstree -s $$
systemd───login───bash───startx───xinit───.xsession───rxvt───bash───pstree

That's for one of the rxvt's that's launched from my .xsession file;
for one that's launched from the FVWM menu, I have:

unicorn:~$ pstree -s $$
systemd───login───bash───startx───xinit───.xsession───fvwm2───rxvt───bash───pst+

David

unread,
May 5, 2022, 8:20:05 PM5/5/22
to
On Fri, 6 May 2022 at 09:34, Greg Wooledge <gr...@wooledge.org> wrote:
> On Fri, May 06, 2022 at 09:16:09AM +1000, David wrote:

Hi, thanks for your comments.

> > So it appears that . ~/.profile runs when Xsession starts,
> > but ~/.bashrc is not run until I manually open a terminal
> > in LXDE, which appears in the above as x-terminal-emul.
>
> Your .profile should be written to dot in ~/.bashrc if it's being run
> by bash. E.g. something like:
>
> test "$BASH_VERSION" && test -r ~/.bashrc && . ~/.bashrc

Yeah, I have this, to handle other shells apart from bash:

# user environment
if [ -n "${BASH_VERSION}" ] ; then
#: this login is bash, include .bashrc
f="${HOME}/.bashrc"
else
#: this login not bash, include _my_export
f="${HOME}/bin/_my_export"
fi
if [ -r "${f}" ] ; then
. "${f}"
fi
unset f

My ~/.bashrc uses the same _my_export to set and export
environment variables.

> In the absence of this, you will not have the desired shell environment
> if you ever use a login shell -- e.g. if you hit Ctrl-Alt-F2 and login
> on a console, or if you ssh into the system.
>
> If you never do either of these things, well, you're fine.

I do all those things, and they work.

> > I assume that Xsession and lxsession are the same process
> > because they have the same PID.
>
> In a proper universe, the former would exec (chain-load) the latter.

Maybe that's what Xsession does, I can't recall.

> > I have chosen to use lxterminal to provide x-terminal-emul.
> > One quirk of lxterminal is that there is only one process
> > which handles all open terminal windows.
>
> Sounds atrocious.

Well, I mentioned it for a reason :)

> If you ever feel bored, you could run this experiment, and see what
> happens:
>
> 1) Put "umask 002" in your ~/.xsessionrc file.
>
> 2) Log out and back in.
>
> 3) Open an lxterminal.
>
> 4) Type "umask" and see what it's set to.
>
> If my conclusions from the OP's post are correct, it will report 0022,
> the Debian system default, totally ignoring your attempt to customize it.

I'm not using the Debian default. I use ~/bin/_my_export to set umask,
and it works. I don't have time to experiment with that for this thread.

> Less invasively, a process tree showing the ancestry of a shell running
> inside an lxterminal would be helpful. Something like this:
>
> unicorn:~$ pstree -s $$
> systemd───login───bash───startx───xinit───.xsession───rxvt───bash───pstree

Inside lxterminal:
[david@kablamm ~]$ pstree -s $$
systemd───lightdm───lightdm───lxsession───lxpanel───x-terminal-emul───bash───pstree

which is consistent with my homemade trace posted in previous message:
lightdm(1310) > lightdm(1393) > lxsession(1414) > lxpanel(1503) >
x-terminal-emul(2403) > bash(2433) . ~/.bashrc

I believe that what I have implemented also works using startx when
lightdm is not installed, but I'm not going to test that for this thread,
I have other things to do, and this lives in the bucket of things
I figured out long ago, and luckily it meets all my needs that I'm aware
of, so I forgot all about it :)

Greg Wooledge

unread,
May 5, 2022, 8:40:05 PM5/5/22
to
On Fri, May 06, 2022 at 10:17:01AM +1000, David wrote:
> I'm not using the Debian default. I use ~/bin/_my_export to set umask,
> and it works. I don't have time to experiment with that for this thread.

Yeah, totally understandable. I hate logging out and back in. Way too
many of my things are still started/moved by hand.

> Inside lxterminal:
> [david@kablamm ~]$ pstree -s $$
> systemd───lightdm───lightdm───lxsession───lxpanel───x-terminal-emul───bash───pstree
>
> which is consistent with my homemade trace posted in previous message:
> lightdm(1310) > lightdm(1393) > lxsession(1414) > lxpanel(1503) >
> x-terminal-emul(2403) > bash(2433) . ~/.bashrc

Thanks. Hmm. Perhaps you're using a different version of LXDE than
the OP, and they have different behaviors. Or perhaps I misunderstood
something the OP posted. Or perhaps one of the processes that starts
with "lx" is clearing the environment on its own.

Giovanni Biscuolo

unread,
May 6, 2022, 3:20:06 AM5/6/22
to
Hi Greg,

thank you very much for your quick reply!

Sorry I did not mention I'm not subscribed to the mailing list, I had to
"manually" copy the text from
https://lists.debian.org/debian-user/2022/05/msg00154.html
here

I also did not mention that there is a related thread on guix-bugs
mailing list [1], but AFAIU it's not a Guix bug

On Thu, May 05, 2022 at 14:23:44 -0400, Greg Wooledge wrote:

[...]

>> This is my ~/.profile:
>>
>> --8<---------------cut here---------------start------------->8---
>>
>> ### Guix settings
>> #
>> # add Guix current path
>> export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
>> # Locale path
>> export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
>> # add Guix infopath
>> export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
>> # set default Guix profile
>> export GUIX_PROFILE="$HOME/.guix-profile"
>> # source default Guix profile
>> . $GUIX_PROFILE/etc/profile
>>
>> --8<---------------cut here---------------end--------------->8---
>
> Note that your .profile has NOTHING about XDG in it.

Sorry, I missed to say that all needed env variables are defined in
$GUIX_PROFILE/etc/profile, including XDG_DATA_DIRS

$GUIX_PROFILE/etc/profile it's very long (and auto-generated by Guix)
and I'd omit this here, please trust me it's OK

I also missed to mention that all but XDG_DATA_DIRS env are set up
according to $GUIX_PROFILE/etc/profile, and I can't understand why

> (It's also not sourcing ~/.bashrc which is bad, but maybe you simply
> never work in a login shell, so you never noticed it.)

OK I'll fix it but AFAIU it's not related to the problem concerning
XDG_DATA_DIRS customization

[...]

> To this day I've never found an actual use for systemctl --user.

Me too, I simply ignored all the systemd user configuration, I was just
using the Debian default settings.

In my research to try to find the root cause that's "resetting" (?)
XDG_DATA_DIRS after my customization, I found some documents explaining
how to set env variables in the user instance of systemd
(e.g. https://wiki.archlinux.org/title/Systemd/User#Environment_variables)

> The fact that you've apparently found some use for it is a surprise.

Actually I'm not configuring it in any way, the systemd user environment ("systemdctl
--user show-environment") I get is the result of the default Debian
systemd user configuration, including XDG_DATA_DIRS: I simply dont' know
what is configuring that

> Maybe some day I'll find one as well.
>
>Anyway, the environment provided to things launched by systemctl --user
>is not the same as your interactive session's environment.

OK, so let's forget about it :-D

>> When I log in via lightdm to an LXDE session, I open LXterminal to check
>> my environment and I find:
>>
>> patrizia@raifort:~$ env | grep XDG
>> [...]
>> XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
>
>> If in the LXTerminal I start a login bash shell with "bash -l" I get:
>>
>> patrizia@raifort:~$ env | grep XDG
>> [...]
>> XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
>
>> Now the XDG_DATA_DIRS is fine.
>
>Interesting. I'm not familiar with LXDE or LXterminal. Did they follow
>GNOME's lead? Is LXterminal spawned as child of some daemon like dbus,
>instead of a child of your X session?

I don't have the same laptop at hand now, but on another laptop with the
same problem (using gdm3 as display manager) the LXTerminal is a child
of gdm-session-worker (lightdm when i checked yesterday on the other
laptop)

[...]

>(Also, it's not clear where your XDG_DATA_DIRS variable is actually
>coming from. Is it from that $GUIX_PROFILE/etc/profile thing that's
>dotted in from your .profile?

It /should/ come from the sourced $GUIX_PROFILE/etc/profile but the
content is reset (?) by "something" after the .xsession sourcing and
before the X session process spawn (?)

[...]

> If you need to customize your *shell* environment when you're working
> under a cursed desktop like GNOME (and apparently LXDE?) where the
> terminal does not inherit the X session's variables,

As I said (and forgot to mention in my first message, sorry), all other
env variables exported by $GUIX_PROFILE/etc/profile (via .xsessionrc)
are actually inherited, all but XDG_DATA_DIRS that is /replaced/ with a
"hardcoded" (?) value:

XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

It should be:

XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

> you might need to seek out GNOME (or LXDE) people who have already
> tackled that problem, and find out how they deal with it.

OK, but it's a really hard issue to investigate ;-(

[...]

>> Is there a way to customize my environment in a standard way that works
>> with all display managers and desktop environments?
>
>(And shells. That's a big one.)
>
>If there is, I have never found it.

I'm sad, very sad! ;-(

>The systemd/XDG people clearly do not care about this. They provide no
>means of doing it. Their documentation doesn't even address the issue.
>It's like the *concept* of a user customizing their own login environment
>never occurred to any of them.

Actually there is environment.d [3] but I still have not tried that
approach, I was hoping to continue using .xsessionrc

Actually customizing .xsessionrc /does/ work, except for XDG_DATA_DIRS

>The GNOME people made it even worse, by launching their terminal as a
>child of a daemon that is not part of the session. Nothing gets inherited
>in the ways that a Unix user expects. Every new instance of gnome-terminal
>has the generic, default, non-customized environment. The only way *I*
>know of to change anything in that environment is to do it at the shell
>level, *after* gnome-terminal has launched a shell. Because you can't
>do it at the GNOME level, that's for sure.
>
>Now, I don't know LXDE, but from your descriptions, it certainly sounds
>like LXDE shares some of these characteristics with GNOME.

AFAIU it's not that case

[...]

>In a traditional Unix setup, all of your environment variables would be
>set in ~/.profile which is read by your login shell, which is spawned
>by login(1) when you login on your terminal. Then you can run 'startx'
>or whatever, which starts an X session which is a child of your login
>shell, and therefore inherits all of the stuff that was set in .profile.
>The X session launches a window manager, and the window manager can
>launch terminals on demand. The terminals inherit the environment from
>the WM, which inherited it from the X session, which inherited it from
>the login shell.

Please consider that, as I mentioned above, the X session I get via
lightdm+LXDE (the same with gdm3+LXDE) have all but XDG_DATA_DIRS
correctly customized; this means AFAIU that this "Quick guide":

https://wiki.debian.org/EnvironmentVariables#Quick_guide

--8<---------------cut here---------------start------------->8---

For the hasty who just need to get the system running, here is what you can do:

Put all global environment variables, i.e. ones affecting all users, into /etc/environment

Remember, this file is read by PAM, not by a shell. You cannot use shell expansions here. E.g. MAIL=$HOME/Maildir/ will not work!

There is no shell-agnostic and login-independent solution to the problem of how to configure the environment for all users, beyond the trivial cases that PAM can handle.

Put all your transient shell settings (aliases, functions, shell options) in ~/.bashrc

Put all your environment variables in ~/.profile

Create or edit file ~/.bash_profile and include commands:

if [ -f ~/.profile ]; then
. ~/.profile
fi
Create or edit file ~/.xsessionrc and include the same commands as above.

This is a quicky and dirty approach! Not for the pedantic user.

--8<---------------cut here---------------end--------------->8---

it's working as expected, except for XDG_DATA_DIRS ;-(


I'm really lost...

Thanks!
Gio'


[1] https://issues.guix.gnu.org/issue/48796

[2] https://issues.guix.gnu.org/issue/48796#24-lineno31

[3] https://manpages.debian.org/bullseye/systemd/environment.d.5.en.html
signature.asc

Giovanni Biscuolo

unread,
May 6, 2022, 3:20:06 AM5/6/22
to
Hi Greg,

thank you very much for your quick reply!

Sorry I did not mention I'm not subscribed to the mailing list, I had to
"manually" copy the text from
https://lists.debian.org/debian-user/2022/05/msg00154.html
here

I also did not mention that there is a related thread on guix-bugs
mailing list [1], but AFAIU it's not a Guix bug

On Thu, May 05, 2022 at 14:23:44 -0400, Greg Wooledge wrote:

[...]

>> This is my ~/.profile:
>>
>> --8<---------------cut here---------------start------------->8---
>>
>> ### Guix settings
>> #
>> # add Guix current path
>> export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
>> # Locale path
>> export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
>> # add Guix infopath
>> export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
>> # set default Guix profile
>> export GUIX_PROFILE="$HOME/.guix-profile"
>> # source default Guix profile
>> . $GUIX_PROFILE/etc/profile
>>
>> --8<---------------cut here---------------end--------------->8---
>
>> When I log in via lightdm to an LXDE session, I open LXterminal to check
>> my environment and I find:
>>
>> patrizia@raifort:~$ env | grep XDG
>> [...]
>> XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
>
>> If in the LXTerminal I start a login bash shell with "bash -l" I get:
>>
>> patrizia@raifort:~$ env | grep XDG
>> [...]
>> XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
>
>> Now the XDG_DATA_DIRS is fine.
>
>Interesting. I'm not familiar with LXDE or LXterminal. Did they follow
>GNOME's lead? Is LXterminal spawned as child of some daemon like dbus,
>instead of a child of your X session?

I don't have the same laptop at hand now, but on another laptop with the
same problem (using gdm3 as display manager) the LXTerminal is a child
of gdm-session-worker (lightdm when i checked yesterday on the other
laptop)

[...]

>(Also, it's not clear where your XDG_DATA_DIRS variable is actually
>coming from. Is it from that $GUIX_PROFILE/etc/profile thing that's
>dotted in from your .profile?

It /should/ come from the sourced $GUIX_PROFILE/etc/profile but the
content is reset (?) by "something" after the .xsession sourcing and
before the X session process spawn (?)

[...]

> If you need to customize your *shell* environment when you're working
> under a cursed desktop like GNOME (and apparently LXDE?) where the
> terminal does not inherit the X session's variables,

As I said (and forgot to mention in my first message, sorry), all other
env variables exported by $GUIX_PROFILE/etc/profile (via .xsessionrc)
are actually inherited, all but XDG_DATA_DIRS that is /replaced/ with a
"hardcoded" (?) value:

XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

It should be:

XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

> you might need to seek out GNOME (or LXDE) people who have already
> tackled that problem, and find out how they deal with it.

OK, but it's a really hard issue to investigate ;-(

[...]

>> Is there a way to customize my environment in a standard way that works
>> with all display managers and desktop environments?
>
if [ -f ~/.profile ]; then
. ~/.profile
fi
Create or edit file ~/.xsessionrc and include the same commands as above.

This is a quicky and dirty approach! Not for the pedantic user.

--8<---------------cut here---------------end--------------->8---

it's working as expected, except for XDG_DATA_DIRS ;-(


I'm really lost...

Thanks!
Gio'


[1] https://issues.guix.gnu.org/issue/48796

[2] https://issues.guix.gnu.org/issue/48796#24-lineno31

[3] https://manpages.debian.org/bullseye/systemd/environment.d.5.en.html

Greg Wooledge

unread,
May 6, 2022, 7:30:06 AM5/6/22
to
On Fri, May 06, 2022 at 09:14:20AM +0200, Giovanni Biscuolo wrote:
> Sorry I did not mention I'm not subscribed to the mailing list,

OK.

> Actually I'm not configuring it in any way, the systemd user environment ("systemdctl
> --user show-environment") I get is the result of the default Debian
> systemd user configuration, including XDG_DATA_DIRS: I simply dont' know
> what is configuring that

Ah. So the systemctl --user stuff is completely irrelevant? You only
thought it had some meaning, so you kept mentioning it.

> I don't have the same laptop at hand now, but on another laptop with the
> same problem (using gdm3 as display manager) the LXTerminal is a child
> of gdm-session-worker (lightdm when i checked yesterday on the other
> laptop)

That's *completely* different from what David showed:

> Inside lxterminal:
> [david@kablamm ~]$ pstree -s $$
> systemd───lightdm───lightdm───lxsession───lxpanel───x-terminal-emul───bash───pstree

I wonder why they're so different.

> It /should/ come from the sourced $GUIX_PROFILE/etc/profile but the
> content is reset (?) by "something" after the .xsession sourcing and
> before the X session process spawn (?)

The whole point of putting variables in .xsessionrc is so that they
become part of the Xsession process, and are therefore inherited by
all of its children. In a normal setup, that includes any programs
launched from .xsession (if it exists), or your x-session-manager or
x-window-manager program.

Also in a normal setup, a terminal is created as a child of the Xsession,
or as a child of the window manager.

However, you're saying that your terminal is a child of "gdm-session-worker"
(whatever that is, clearly some part of gdm3).

That process does *not* contain your .xsessionrc variables, so anything
spawned by it won't have them either.

> As I said (and forgot to mention in my first message, sorry), all other
> env variables exported by $GUIX_PROFILE/etc/profile (via .xsessionrc)
> are actually inherited, all but XDG_DATA_DIRS that is /replaced/ with a
> "hardcoded" (?) value:

I don't know what to tell you here. If your terminal is launched as a
child/grandchild of gdm, and does *not* inherit from the Xsession, then
it's not getting those variables from your .xsessionrc file.

Maybe it's getting them by some other means.

> Actually there is environment.d [3] but I still have not tried that
> approach,

I went down that rabbit hole once or twice. Maybe I can save you some
time by letting you know that it WILL NOT do anything helpful for you.

environment.d(5) DOES NOT configure the environment of an interactive
session. Please believe me, I tried everything I could think of. This
is just one of those cases where the systemd people solved a problem
that only they thought existed, and ignored the ACTUAL PROBLEM that
people wanted to solve. And, because the systemd people are so completely
out of touch with reality, they dropped their solution on us without
any real explanation of what it DOES, and they made it LOOK like it solves
the problem people would like to solve. But it doesn't.

Here's what the man page says:

Configuration files in the environment.d/ directories contain lists of
environment variable assignments for services started by the systemd
user instance.

What the bleeding hell is a "systemd user instance"? Is it a login session?
NO! No, it is not!

My best guess after all the time I wasted on this thing is that it refers
to the "systemctl --user" daemon. The same thing that neither you nor I
have ever been able to find a use for.

systemd will happily let you customize the environment of that... thing...
but not your login session.

Giovanni Biscuolo

unread,
May 6, 2022, 8:40:05 AM5/6/22
to
Hello Greg and David,

as I said, please leave me in Cc: as I'm not subscribed

Greg Wooledge <gr...@wooledge.org> writes:

> On Fri, May 06, 2022 at 09:14:20AM +0200, Giovanni Biscuolo wrote:
>> Sorry I did not mention I'm not subscribed to the mailing list,
>
> OK.
>
>> Actually I'm not configuring it in any way, the systemd user environment ("systemdctl
>> --user show-environment") I get is the result of the default Debian
>> systemd user configuration, including XDG_DATA_DIRS: I simply dont' know
>> what is configuring that
>
> Ah. So the systemctl --user stuff is completely irrelevant? You only
> thought it had some meaning, so you kept mentioning it.

I mentioned because I'm still curious to understand why in "systemctl
--user" stuff I have "XDG_DATA_DIRS=/home/patrizia/.guix-profile/share"
that is /part/ of what $GUIX_PROFILE/etc/profile (sourced in my
.xinitrc) is exporting for XDG_DATA_DIRS

>> I don't have the same laptop at hand now, but on another laptop with the
>> same problem (using gdm3 as display manager) the LXTerminal is a child
>> of gdm-session-worker (lightdm when i checked yesterday on the other
>> laptop)
>
> That's *completely* different from what David showed:
>
>> Inside lxterminal:
>> [david@kablamm ~]$ pstree -s $$
>> systemd───lightdm───lightdm───lxsession───lxpanel───x-terminal-emul───bash───pstree

On my laptop, inside LXTerminal:

--8<---------------cut here---------------start------------->8---

systemd---gdm3---gdm-session-wor---gdm-x-session---lxsession---lxpanel---lxterminal---bash---pstree

--8<---------------cut here---------------end--------------->8---

I see non difference except I have gdm3 (and related session manager)
instead of lightdm (on this laptop, different from the one of my first
message)

[...]

>> It /should/ come from the sourced $GUIX_PROFILE/etc/profile but the
>> content is reset (?) by "something" after the .xsession sourcing and
>> before the X session process spawn (?)
>
> The whole point of putting variables in .xsessionrc is so that they
> become part of the Xsession process, and are therefore inherited by
> all of its children. In a normal setup, that includes any programs
> launched from .xsession (if it exists), or your x-session-manager or
> x-window-manager program.

Thank you for your explanation: I can absolutely confirm that this is
what is happening with my Xsession environment (inherited by the window
manager and thus by the "menu manager" and by LXTerminal) /except/ for
XDG_DATA_DIRS that is reset /after/ .xsessionrc is read by my Xsession
manager

> Also in a normal setup, a terminal is created as a child of the Xsession,
> or as a child of the window manager.

AFAIU this is also what is happening on my laptop, given that lxterminal
is an (indirect) child of lxsession

> However, you're saying that your terminal is a child of "gdm-session-worker"
> (whatever that is, clearly some part of gdm3).
>
> That process does *not* contain your .xsessionrc variables, so anything
> spawned by it won't have them either.

I'm sorry I was not clear enough, but all my processes /do/ contain
.xsessionrc variables, except for XDG_DATA_DIRS that is reset by
"something"

>> As I said (and forgot to mention in my first message, sorry), all other
>> env variables exported by $GUIX_PROFILE/etc/profile (via .xsessionrc)
>> are actually inherited, all but XDG_DATA_DIRS that is /replaced/ with a
>> "hardcoded" (?) value:
>
> I don't know what to tell you here. If your terminal is launched as a
> child/grandchild of gdm, and does *not* inherit from the Xsession, then
> it's not getting those variables from your .xsessionrc file.
>
> Maybe it's getting them by some other means.

No , because in my ~/.xsessionrc (and only there) I have this variable:

--8<---------------cut here---------------start------------->8---

export XSESSION_WAS_HERE="Yes"

--8<---------------cut here---------------end--------------->8---

and if I check that variable via "env | grep HERE" in an LXTerminal
(or xterm, ot Mate terminal) started in LXDE I can see that variable is
configured; this is why I'm pretty sure my ~/.xsessionrc is actually
inherited by my Xsession

>> Actually there is environment.d [3] but I still have not tried that
>> approach,
>
> I went down that rabbit hole once or twice. Maybe I can save you some
> time by letting you know that it WILL NOT do anything helpful for you.

Thank you! :-)

[...]

> systemd will happily let you customize the environment of that... thing...
> but not your login session.

Fine, I'm happy to be able to ignore environment customization via
systemd because I'd really like to have an
init-distro-display_manager-desktop_manager agnostic way to configure it
(and keep it in my dotfolder, git versioned, etc., etc....)

I'm still investigating...

Thank you! Gio'
signature.asc

Greg Wooledge

unread,
May 6, 2022, 8:50:05 AM5/6/22
to
On Fri, May 06, 2022 at 02:30:59PM +0200, Giovanni Biscuolo wrote:
> On my laptop, inside LXTerminal:
>
> systemd---gdm3---gdm-session-wor---gdm-x-session---lxsession---lxpanel---lxterminal---bash---pstree

Aha. It's a (grand)child of lxsession, just as with David's.

> I'm sorry I was not clear enough, but all my processes /do/ contain
> .xsessionrc variables, except for XDG_DATA_DIRS that is reset by
> "something"

> No , because in my ~/.xsessionrc (and only there) I have this variable:
>
> export XSESSION_WAS_HERE="Yes"
>
> and if I check that variable via "env | grep HERE" in an LXTerminal
> (or xterm, ot Mate terminal) started in LXDE I can see that variable is
> configured; this is why I'm pretty sure my ~/.xsessionrc is actually
> inherited by my Xsession

OK. Then it sounds like something in between the Xsession and the shell
is indeed overwriting that XDG_DATA_DIRS variable.

According to your pstree output, those processes include lxsession,
lxpanel and lxterminal. You could start with those. Of course, there
could be other processes that are not shown, because they're exec'ed
out of the picture.

Remember, one of the tools available to you is looking at the initial
environment of a process, either by using ps with the "e" option, or
by reading the /proc/PID/environ file. The latter is NUL-delimited,
so you'd want something like this:

unicorn:~$ tr '\0' '\n' < /proc/$$/environ | head -n5
SHELL=/bin/bash
QT_ACCESSIBILITY=1
LESS=-X
QMAILSHOST=wooledge.org
QMAILHOST=wooledge.org

I find that a lot more useful than ps e. Of course in your case you
wouldn't use |head, but probably |grep XDG_DATA_DIRS.

If you see the desired variable value in, say, lxpanel but not in
lxterminal, then you have a pretty good idea of where the overwrite
occurred.

David

unread,
May 6, 2022, 10:40:06 AM5/6/22
to
On Fri, 6 May 2022 at 02:55, Giovanni Biscuolo <g...@xelera.eu> wrote:

> I'm trying to customize my user environment when using the lightdm
> display manager (then the LXDE desktop environment)
>
> I need to customize some variables so I can see Guix installed
> applications in my desktop menu, in particular I need to customize
> XDG_DATA_DIRS and XDG_CONFIG_DIRS

[...]

> When I log in via lightdm to an LXDE session, I open LXterminal to check
> my environment and I find:
[...]
> XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

> If in the LXTerminal I start a login bash shell with "bash -l" I get:
[...]
> XDG_DATA_DIRS=/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/home/patrizia/.guix-profile/share:/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
[...]
> Now the XDG_DATA_DIRS is fine.

> The problem is that the lightdm (and LXDE) XDG_DATA_DIRS is missing
> "/home/patrizia/.guix-profile/share" and this is the reason why
> applications installed with Guix are not listed in my menu.

Hi, you wrote a lot of other stuff that I have trimmed, but from
what I have quoted above it seems that your complaint is that
when you use a login shell you get a XDG_DATA_DIRS value
you want, and when you login via lightdm you do not.

Is that the entire problem that you want to solve?

If so, this suggests to me that your failure case occurs because you
are missing some aspect of ~/.profile from the good case.

Just a quick suggestion. From here
https://packages.debian.org/bullseye/amd64/guix/filelist
I see that the Debian guix package contains a file
/etc/profile.d/guix.sh
which looks to set XDG_DATA_DIRS similar to what you want.

The file can be seen here, note the last line:
https://sources.debian.org/src/guix/1.3.0-4/debian/guix.sh/

This is entirely based on guesswork by me, but maybe if you look into
it then you might discover that you need to arrange for
/etc/profile.d/guix.sh (or some of what it contains) to be executed
when you log in via lightdm.

Greg Wooledge

unread,
May 6, 2022, 10:50:04 AM5/6/22
to
On Sat, May 07, 2022 at 12:36:59AM +1000, David wrote:
> On Fri, 6 May 2022 at 02:55, Giovanni Biscuolo <g...@xelera.eu> wrote:
>
> > I'm trying to customize my user environment when using the lightdm
> > display manager (then the LXDE desktop environment)
> >
> > I need to customize some variables so I can see Guix installed
> > applications in my desktop menu, in particular I need to customize
> > XDG_DATA_DIRS and XDG_CONFIG_DIRS

This bring up another point that we haven't really pursued yet.

What program produces this "desktop menu"? What is that process's
ancestry (e.g. pstree -s THATPID)?

There's been a whole discussion about the environment variable being
set right or wrong in a *terminal*, but is that really relevant? Is
the desktop menu produced by running a shell command? If not, then
the terminal is not important.

Giovanni Biscuolo

unread,
May 6, 2022, 1:10:05 PM5/6/22
to
Hello Greg,

Greg Wooledge <gr...@wooledge.org> writes:

> On Fri, May 06, 2022 at 02:30:59PM +0200, Giovanni Biscuolo wrote:

[...]

>> No , because in my ~/.xsessionrc (and only there) I have this variable:
>>
>> export XSESSION_WAS_HERE="Yes"
>>
>> and if I check that variable via "env | grep HERE" in an LXTerminal
>> (or xterm, ot Mate terminal) started in LXDE I can see that variable is
>> configured; this is why I'm pretty sure my ~/.xsessionrc is actually
>> inherited by my Xsession
>
> OK. Then it sounds like something in between the Xsession and the shell
> is indeed overwriting that XDG_DATA_DIRS variable.

From what I see with my tests this is the most plausible explanation I
can think of

[...]

> Remember, one of the tools available to you is looking at the initial
> environment of a process, either by using ps with the "e" option, or
> by reading the /proc/PID/environ file.

Thank you for the suggestion, I was thinking about that but not found
some time to test this before; this is what I see...

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ pstree -ps $$
systemd(1)---gdm3(6358)---gdm-session-wor(16849)---gdm-x-session(16859)---lxsession(16876)---lxpanel(17020)---lxterminal(17144)---bash(17147)---pstre+

--8<---------------cut here---------------end--------------->8---

environment of gdm3:

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/6358/environ"
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
INVOCATION_ID=6c9d0299ede348bea719251815d25952
JOURNAL_STREAM=8:23700

--8<---------------cut here---------------end--------------->8---

environment of gdm-session-wor:

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/16849/environ"
LANG=en_US.UTF-8
INVOCATION_ID=6c9d0299ede348bea719251815d25952
GDM_SESSION_DBUS_ADDRESS=unix:abstract=/tmp/dbus-yPP2BhYk
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
JOURNAL_STREAM=8:23700

--8<---------------cut here---------------end--------------->8---

environment of gdm-x-session:

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/16859/environ"
XDG_SEAT=seat0
LOGNAME=g
USER=g
USERNAME=g
HOME=/home/g
PWD=/home/g
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin:/usr/games
XDG_SESSION_TYPE=x11
XDG_VTNR=5
LANG=en_US.utf8
XDG_SESSION_ID=61
XDG_RUNTIME_DIR=/run/user/1000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
XDG_SESSION_CLASS=user
GDM_LANG=en_US.utf8
GDMSESSION=LXDE
DESKTOP_SESSION=LXDE
XDG_SESSION_DESKTOP=LXDE

--8<---------------cut here---------------end--------------->8---

environment of lxsession:

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/16876/environ | grep XDG"
XDG_SEAT=seat0
XDG_SESSION_TYPE=x11
XDG_SESSION_CLASS=user
XDG_SESSION_ID=61
XDG_RUNTIME_DIR=/run/user/1000
XDG_MENU_PREFIX=lxde-
XDG_CURRENT_DESKTOP=LXDE
XDG_SESSION_DESKTOP=LXDE
XDG_CONFIG_HOME=/home/g/.config
XDG_DATA_HOME=/home/g/.local/share
XDG_VTNR=5
XDG_CONFIG_DIRS=/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

--8<---------------cut here---------------end--------------->8---

environment of lxpanel:

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/17020/environ | grep XDG"
XDG_SEAT=seat0
XDG_SESSION_TYPE=x11
XDG_SESSION_CLASS=user
XDG_SESSION_ID=61
XDG_RUNTIME_DIR=/run/user/1000
XDG_MENU_PREFIX=lxde-
XDG_CURRENT_DESKTOP=LXDE
XDG_SESSION_DESKTOP=LXDE
XDG_CONFIG_HOME=/home/g/.config
XDG_DATA_HOME=/home/g/.local/share
XDG_VTNR=5
XDG_CONFIG_DIRS=/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg
XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

--8<---------------cut here---------------end--------------->8---

environment of lxterminal:

--8<---------------cut here---------------start------------->8---

g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/17144/environ | grep XDG"
XDG_SEAT=seat0
XDG_SESSION_TYPE=x11
XDG_SESSION_CLASS=user
XDG_SESSION_ID=61
XDG_RUNTIME_DIR=/run/user/1000
XDG_MENU_PREFIX=lxde-
XDG_CURRENT_DESKTOP=LXDE
XDG_SESSION_DESKTOP=LXDE
XDG_CONFIG_HOME=/home/g/.config
XDG_DATA_HOME=/home/g/.local/share
XDG_VTNR=5
XDG_CONFIG_DIRS=/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg:/etc/xdg:/home/g/.guix-profile/etc/xdg:/home/g/.guix-profile/etc/xdg
XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

--8<---------------cut here---------------end--------------->8---

So the XDG_DATA_DIRS is (re)setted between gdm-x-session and lxsession:
I still have to find by what

Still, it seems to me that ~/.xsession is correctly sourced by (or
before) lxsession since other variables (e.g. XDG_CONFIG_DIRS) are
configured accordingly

...still investigating

Thanks! Gio'
signature.asc

Giovanni Biscuolo

unread,
May 6, 2022, 1:20:05 PM5/6/22
to
Hello David,

thank you for your help

David <bounci...@gmail.com> writes:

> On Fri, 6 May 2022 at 02:55, Giovanni Biscuolo <g...@xelera.eu> wrote:

[...]

>> The problem is that the lightdm (and LXDE) XDG_DATA_DIRS is missing
>> "/home/patrizia/.guix-profile/share" and this is the reason why
>> applications installed with Guix are not listed in my menu.
>
> Hi, you wrote a lot of other stuff that I have trimmed, but from
> what I have quoted above it seems that your complaint is that
> when you use a login shell you get a XDG_DATA_DIRS value
> you want, and when you login via lightdm you do not.

Yes, the same also happens when using gdm3

> Is that the entire problem that you want to solve?

Yes

> If so, this suggests to me that your failure case occurs because you
> are missing some aspect of ~/.profile from the good case.

Please read all I wrote about the fact that all the environment
variables I set via ~/.xsessionrc are correctly configures, all but
XDG_DATA_DIRS (for example: INFOPATH, GUIX_LOCPATH)


[...]

> /etc/profile.d/guix.sh
> which looks to set XDG_DATA_DIRS similar to what you want.

I'm just using a $HOME/.profile instead of /etc/profile.d/guix.sh but
the result is the same (but I admit I have not tried installing
/etc/profile.d/guix.sh)

As I said, the fact that is driving me crazy is that all ~/.xsession
variables are in my environment (as configured), all but XDG_DATA_DIRS

[...]

Thank you! Gio'
signature.asc

Tixy

unread,
May 6, 2022, 1:50:05 PM5/6/22
to
On Fri, 2022-05-06 at 19:07 +0200, Giovanni Biscuolo wrote:
[...]
> environment of lxsession:
>
> --8<---------------cut here---------------start------------->8---
>
> g@renaissance:~$ sudo sh -c "tr '\0' '\n' < /proc/16876/environ | grep XDG"
> [XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
>
[...]

> --8<---------------cut here---------------end--------------->8---
>
> environment of lxpanel:
>
> --8<---------------cut here---------------start------------->8---
>
[...]
> XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
>
> --8<---------------cut here---------------end--------------->8---
>
[...]
> So the XDG_DATA_DIRS is (re)setted between gdm-x-session and lxsession:
> I still have to find by what

Looks to me like it changed between lxsession and lxpanel by having a
second copy of the path prended to it, but without the trailing /

If it wasn't for the '/' difference I'd guess that whatever sets up
XDG_DATA_DIRS is following common pattern of prepending to a path like

XDG_DATA_DIRS=/some/directory1:/some/directory2:$XDG_DATA_DIRS

And that script is being called twice so you get two copies. Could
still be something like that, but the path getting processed in some
way before concatenating

--
Tixy

Giovanni Biscuolo

unread,
May 6, 2022, 2:40:06 PM5/6/22
to
Hello Greg,

Greg Wooledge <gr...@wooledge.org> writes:

> On Sat, May 07, 2022 at 12:36:59AM +1000, David wrote:

[...]

> There's been a whole discussion about the environment variable being
> set right or wrong in a *terminal*, but is that really relevant?

What's relevant is that lxsession does not have a proper XDG_DATA_DIRS

> Is the desktop menu produced by running a shell command? If not, then
> the terminal is not important.

Sorry I made confusion: I'm not concerned about LXTerminal (or other
terminals), it's just that I need a terminal to check my Xsession
environment via CLI

Thank you!
signature.asc

Greg Wooledge

unread,
May 6, 2022, 3:00:05 PM5/6/22
to
On Fri, May 06, 2022 at 08:33:49PM +0200, Giovanni Biscuolo wrote:
> What's relevant is that lxsession does not have a proper XDG_DATA_DIRS

You might be misreading things.

> Sorry I made confusion: I'm not concerned about LXTerminal (or other
> terminals), it's just that I need a terminal to check my Xsession
> environment via CLI

Yeah, but you assumed that the environment you saw in your terminal
would be identical to the environment seen by whatever is building
this menu. That may not be the case.

The first thing you need to do is figure out what process is actually
making that menu. I doubt very much that it's "lxsession".

Once you figure that out, then you can see what environment that process
started with (from /proc) and then try to figure out how it got that way.
Plus whatever else you need to know.

Up above, you mentioned that "lxsession does not have a proper XDG_DATA_DIRS",
but that's not necessarily unexpected.

/proc only shows you what the *initial* environment is. It's the environment
that was given to the process by its parent. Processes can change their
own environment, with the intent of passing new variables/values down to
their children. This is extremely common with shell scripts, for example.
Those changes to the running process's copy of the environment will not be
visible in /proc.

In the case of lxsession, you may be seeing the initial environment of
the session, *before* it dotted in your .profile stuff. Possibly. (I'm
still not 100% clear on the relationship between the X session launched by
the display manager, and this "lxsession".)

Giovanni Biscuolo

unread,
May 6, 2022, 3:00:05 PM5/6/22
to
Hello David and Greg,

Giovanni Biscuolo <g...@xelera.eu> writes:

[...]

>> On Fri, 6 May 2022 at 02:55, Giovanni Biscuolo <g...@xelera.eu> wrote:
>
> [...]
>
>>> The problem is that the lightdm (and LXDE) XDG_DATA_DIRS is missing
>>> "/home/patrizia/.guix-profile/share" and this is the reason why
>>> applications installed with Guix are not listed in my menu.

I did a test changing the user session started by gdm3 (also tried
lightdm): using Mate instead of LXDE is working, I have a correct
XDG_DATA_DIRS environment variable (and thus graphical menu and MIME
associations in file manager); sorry I did not try this before!

Tomorrow I'll try on my other laptop, where I have the same problem

Happy hacking! Gio'
signature.asc

David

unread,
May 6, 2022, 8:30:05 PM5/6/22
to
On Sat, 7 May 2022 at 03:16, Giovanni Biscuolo <g...@xelera.eu> wrote:

> > Hi, you wrote a lot of other stuff that I have trimmed, but from
> > what I have quoted above it seems that your complaint is that
> > when you use a login shell you get a XDG_DATA_DIRS value
> > you want, and when you login via lightdm you do not.
>
> Yes, the same also happens when using gdm3
>
> > Is that the entire problem that you want to solve?
>
> Yes
>
> > If so, this suggests to me that your failure case occurs because you
> > are missing some aspect of ~/.profile from the good case.
>
> Please read all I wrote about the fact that all the environment
> variables I set via ~/.xsessionrc are correctly configures, all but
> XDG_DATA_DIRS (for example: INFOPATH, GUIX_LOCPATH)



Hi Giovanni

If your ~/.profile and your ~/.xsessionrc are as you showed us in
your first message (quoted below), then they do not set any
value for XDG_DATA_DIRS.

On Fri, 6 May 2022 at 02:55, Giovanni Biscuolo <g...@xelera.eu> wrote:

> This is my ~/.profile:
>
> --8<---------------cut here---------------start------------->8---
>
> ### Guix settings
> #
> # add Guix current path
> export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
> # Locale path
> export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
> # add Guix infopath
> export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
> # set default Guix profile
> export GUIX_PROFILE="$HOME/.guix-profile"
> # source default Guix profile
> . $GUIX_PROFILE/etc/profile
>
> --8<---------------cut here---------------end--------------->8---
>
> and this is my ~/.xsessionrc:
>
> --8<---------------cut here---------------start------------->8---
>
> if [ -f ~/.profile ]; then
> . ~/.profile
> fi
>
> export XSESSION_WAS_HERE="Yes"
>
> --8<---------------cut here---------------end--------------->8---



I do not see XDG_DATA_DIRS being set anywhere there.

Perhaps it is being set by
$GUIX_PROFILE/etc/profile
if so then I'm sorry if I missed where you told us that.

That is why I am suggesting various methods that I successfully
use to configure my environment in LXDE.

These methods bascially are using ~/.xsessionrc to invoke
statements that need to occur at login, similar to what
~/.profile does.

However just invoking these files is insufficient, somewhere
they actually need to export the value of XDG_DATA_DIRS
that you desire.

Where do you try to set XDG_DATA_DIRS ?

Giovanni Biscuolo

unread,
May 7, 2022, 5:40:06 AM5/7/22
to
Hi David,

David <bounci...@gmail.com> writes:

[...]

> If your ~/.profile and your ~/.xsessionrc are as you showed us in
> your first message (quoted below), then they do not set any
> value for XDG_DATA_DIRS.

Sorry I was not clear on the first message, I already clarified this in
other messages in this thread

[...]

> Perhaps it is being set by
> $GUIX_PROFILE/etc/profile

Yes

> if so then I'm sorry if I missed where you told us that.

No prob, thank you for your heads up!

Happy hacking! Gio'

[...]
signature.asc
0 new messages