Is it possible to set an environment variable at runtime, affecting all the programs started from the DE after that point (Desktop Environment, in my case KDE4) (without rebooting)?

I know it it possible to set system-wide or user-wide environment variables in .profile, /etc/environment, etc., but logging out and back in is required before they are read.

My aim is to store the current display resolution in 2 environment vars named XRES and YRES and update them when I switch to the secondary display.

  • no txtspeak plz. kthxbye – Gilles 'SO- stop being evil' Apr 3 '14 at 21:54
  • No it is not possible to update a running programs environment. It is possible to start a new shell with the new environment. @Gilles I suspect if you remove the KDE aspect this is a duplicate... do you know? – xenoterracide Apr 4 '14 at 3:01
  • I took this question as meaning for programs newly started by the DE — i.e. change the environment of the launcher process. Indeed, if the question is updating the environment of already-running programs, the answer is a boring no. I'm editing the question accordingly. – Gilles 'SO- stop being evil' Apr 4 '14 at 8:11
  • eadmaster: if you want running programs to be informed of screen resolution changes, environment variables aren't the way to do it. Ask a new question about that, and tell us which programs you're interested in and how you want the programs to react. – Gilles 'SO- stop being evil' Apr 4 '14 at 8:14
  • ok, i can accept a "no" as answer... Btw i guess with root privileges it should be possible, even if i don't know any specific tool for that... – eadmaster Apr 7 '14 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.