[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



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

-- 
Giovanni Biscuolo

Xelera IT Infrastructures


Reply to: