You are not logged in.
Hi All,
I have set added the following 2 export lines to my ~/.bash_profile to set my EDITOR and VISUAL variables to emacs.
#
# ~/.bash_profile
#
export EDITOR=emacs
export VISUAL=emacs
[[ -f ~/.bashrc ]] && . ~/.bashrcHowever, when I start up and do printenv, neither EDITOR or VISUAL is set. Typing export VISUAL=emacs in my terminal does set the environment variable.
Could someone advise on my error?
Thanks and regards,
Simon
Last edited by simon_sjw (2017-10-27 06:32:30)
Offline
I am guessing you are using a display manager: some/most of them read from different files when setting the ENV.
You would typically source .bashrc at the start of the file, also.
Offline
OK thanks Jason.
I am using GDM with the GNOME desktop. I'll have a look at the GDM documentation to see if it recommends a location for setting environment variables. (If you have a suggestion I'd be keen to hear).
Also, I have changed the put the line [[ -f ~/.bashrc ]] && . ~/.bashrc above the two export lines now.
I'll post back with results when I have them.
Thanks for a superfast response.
Simon
Offline
Apparently, GDM will read ~/.profile
Offline
Hi All/Jason,
I've now tried pasting
export EDITOR=emacs
in
~/.profile
/etc/profile
~/.bashrc
~/bash_profile
without any result.
Anyone know how I set an environment variable with GDM and wayland if the above doesn't work?
Regards,
Simon
Offline
I don't know why this does not work, assuming you have restarted gdm or rebooted, however an alternative would be to put 'EDITOR=emacs' into your /etc/environment, which is read upon login, i.e. GDM will probably not know about it, but that should not matter.
Offline
Hi Respiranto,
I did add the environment variable exports (for EDITOR and VISUAL) to /etc/environment and it worked.
However, I'm not going to mark this closed quite yet - does anyone know how I might troubleshoot this to find out why my ~/.profile gets ignored along with .bashrc.
If there are any resources I can visit to get 'skilled up', I don't at all mind putting in the effort - I'm quite keen to learn this stuff.
Thanks everyone for your help so far.
Thanks,
Simon
Offline
I had problems with Gnome as well. I was trying to set an environment variable in a script in /etc/X11/xinitrc.d/ but it didn't work. While trying to diagnose things, I looked at the environment of running processes. You can do that through /proc. Each process has a directory there under its pid. The environment of the process is in a file "environ". Example here:
$ pgrep firefox
15232
$ sudo cat /proc/15232/environ | tr '\0' '\n'The environment variable was missing in the processes for some reason. I was guessing that in Gnome a bunch of things are run through a "systemd --user" process that's perhaps started at a different point, before the normal login stuff goes on, and it does not get the environment variables set in the normal scripts. Or perhaps my particular problem was that I was testing through logging out and logging in and that "systemd --user" process was kept running.
My particular problem of the script in /etc/X11/xinitrc.d/ was solved by creating a file "/etc/X11/xinitrc.d/zzzzz.sh" and putting this here in there:
#!/bin/sh
(
unset XDG_SEAT
unset XDG_SESSION_ID
unset XDG_VTNR
unset DISPLAY
dbus-update-activation-environment --systemd --all
)That dbus-update-activation-environment line sends the environment to that "systemd --user" process. The ( ) and unsets are there because I was worried about problems as that "system --user" process seems to be reused through multiple logout and logins. I don't really know what I'm doing there. I couldn't find any real documentation about all of this. I'm really just guessing about what's going on.
If you want to set an environment variable in ~/.bash_profile that's supposed to show up for all programs you start through Gnome, I'm guessing you'd have to use dbus-update-activation-environment there in your ~/.bash_profile.
Offline
HI Ropid/All,
I had no luck with this. Afraid I don't get the relationship between Wayland and X11 - I thought it replaced it and if so, how come /etc/X11/xinitrc.d still gets used?
I also had a look over on the Gnome wiki - although there was documentation, it appears to relate to building apps. My Newbie level skills didn't help though.
If anyone knows a good starting point - I am well up for going away, reading up some documentation, fiddling about, then reporting back here with results.
I would love a good overview of how the desktop is initially set up and how the variables get assigned (and if I ever figure it out, will be up for writing a page in the arch wiki on it).
Anyhow, that gnome link is below but I'm keen to hear more suggestions if anyone has any. Until then I'm starting on the gnome 2 tutorial via the link.
Thanks and regards,
Simon
Offline
This appears to be a reasonable summary (not sure how up-to-date it is):
https://wiki.debian.org/EnvironmentVariables
This may represent an alternative approach:
https://wiki.archlinux.org/index.php/Xprofile
As far as I can tell from the GDM git, it looks like Xsession should read your ~/.profile file (see line 34):
https://github.com/GNOME/gdm/blob/246d9 … session.in
You may want to have a look at the Xsession script as installed on your system.
Regards,
Offline
How come no one mention about pam (/etc/environment or ~/.pam_environment)
Last edited by tom.ty89 (2015-12-30 18:31:50)
Offline
Hi All,
This related to an early implementation of Wayland on Arch Linux. I now have no problems setting environment variables at bootup so I'm marking this as solved.
Offline