In the New World Order, Linux apps should all store their user-specific data according to the FreeDesktop Base Directory specification, which in practice means that config details for myapp end up in $HOME/.config/myapp. All well and good. However, I don’t like having configuration stored in dotfiles; I like to be able to get at it more easily, so I want it in $HOME/Settings. The XDG spec provides for this: you set an environment variable XDG_CONFIG_HOME (which defaults to $HOME/.config) and then everything uses it. Great! But…where do I set this variable so that all the apps get it?
Some suggestions:
$HOME/.bashrc,$HOME/.bash_profile,$HOME/.profile— as far as I can tell, these aren’t run as part of the login process, so they’re no good. They get run when you start bash, which means when you first fire up a terminal.$HOME/.gnomerc— gets run by gdm. Might be a Debianism, and doesn’t work if I change away from gdm a few months from now$HOME/.xinitrc,$HOME/.xsession— get run if you’re in X but not if you’re running over SSH, and.xsessionis a Debianism/etc/xdg/user-dirs.conf— this will change it for all users on the machine, not just me- Something in PAM. Perhaps. It’s not clear what, though.
- A file of my choice, which I then source from all of the above places. This is doable but seems stupid to me, and I’m bound to miss something.
- Something else. This is where you come in; where am I meant to set the environment so that everything gets access to it?
Answers on a postcard…
whatever
Posted by Frank O'De on August 3rd, 2008.
Whoops - hit the button too quick there.
Why don’t you just make a symbolic link - ln -s $HOME/.config $HOME/Settings
Posted by Frank O'Dwyer on August 3rd, 2008.
Frank: that’s what I currently am doing. However, I ought to be able to set it correctly rather than working around the problem :)
Posted by sil on August 3rd, 2008.
There ~/.xprofile, which is read by gdm.
Posted by pclouds on August 3rd, 2008.
/etc/profile is the usual UNIX way to do this kind of thing - think it works on Linux too. It usually contains system wide defaults and (I think) should work regardless of whether you use X or ssh, as long as you’re not using some weird shell that ignores it. Worth a try anyhow.
Posted by Frank O'Dwyer on August 3rd, 2008.
Frank: /etc/profile will set it for all users on the system, not just me; same problem as /etc/xdg.
pclouds: I didn’t know about that, but it has the same problem as .xsession; it won’t work if I ssh in (or possibly if I switch to a different login manager).
Posted by sil on August 3rd, 2008.
Well you could put some logic in there, e.g. within /etc/profile test for the existence of a file such as $HOME/.xdg_profile and include it if it exists.
Or test if $HOME/Settings exists and set the variable if it does.
Otherwise you’re possibly stuck with doing it in two places, once for ssh and once for X.
Still think a symlink is the easiest way though :-)
Posted by Frank O'Dwyer on August 3rd, 2008.
Put it in
.config/FreeDesktop, of course! ;)Posted by Roberto on August 3rd, 2008.
Roberto: you’re all comedy all the time, you are :-)
Posted by sil on August 3rd, 2008.
I think .bashrc is loaded whenever bash is started.. And the gdm startup is a bash script (or maybe you use a crappy distro that uses another shell for gdm? Maybe this shell has an equivalent file?) On a unix system, I’ll bet there’s a shell somewhere in starting mostly anything.
Posted by Tester on August 4th, 2008.
Posted by sil on August 4th, 2008.
You will find that ~/.profile is parsed when you login both via gdm (with almost all sessions managers too) and when you ssh in.
Go ahead and try it:
echo ”.profile was called” >> $HOME/bash-startup
Posted by karl on August 4th, 2008.
I can confirm that ~/.profile is called when you log in - I use it to load the colour profile for my monitor, and so just after I log in first the screen does a noticeable colour shift.
Posted by Michael Maclean on August 4th, 2008.
Michael Maclean: aha. Yes. It does get run. *After* your autostart applications are autostarted. Useful, I don’t think. :)
Posted by sil on August 4th, 2008.
Well it doesn’t sound like there is any single clean way of accomplishing it at the mo then.
You can get anything run before starting your session using ~/.dmrc ~/.xsession and ~/.profile.
in ~/.dmrc
[Desktop]
Session=default
in ~/.xsession (assuming your still using gnome)
export XDG_CONFIG_HOME=$HOME/Settings
gnome-session
in ~/.profile add your XDG_CONFIG_HOME line to the end (or beginning) too. .profile wont be read till after things have autostarted, but that dont matter as the var is already exported in ~/.xsession. It is only there for when you open terminals/bash/dash.
Posted by karl on August 5th, 2008.
Oh, I didn’t realise it was after the autostart apps. But then, I don’t have any :)
Posted by Michael Maclean on August 5th, 2008.
CDE sources your profile at login if you set DTSOURCEPROFILE=true in ~/.dtprofile. It sounds like this is the behaviour you’re after.
You could get this by creating a .xsession that starts
#!/bin/bash –login
Posted by Peter Oliver on August 10th, 2008.
Did you ever find a solution to this elsewhere? I’m quite interested in this as well.
Posted by Dennis Fisher on September 4th, 2008.