You are not logged in.

#1 2013-09-18 08:06:11

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Change an environment variable without re-logging-in

Is there a way to change an environment variable so that all the future processes get the new value without restarting the shell?

Here is my use case, I have two sound cards and I can select them via environment variable. Of course I can start a terminal, export the variable, and start a program. But it would be nice to change it with ease with for all the program executed by the menu.

Offline

#2 2013-09-18 09:15:29

chronozphere
Member
Registered: 2011-06-18
Posts: 18

Re: Change an environment variable without re-logging-in

export VARIABLE=value

http://www.cyberciti.biz/faq/set-enviro … ble-linux/

Edit: Sorry.. nevermind.

Last edited by chronozphere (2013-09-18 09:16:30)

Offline

#3 2013-09-18 11:42:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: Change an environment variable without re-logging-in

ezzetabi wrote:

But it would be nice to change it with ease with for all the program executed by the menu.

Then you'd need to change the environment variable in the "menu".

What menu is this?  Is it in a WM/DE?  Which one?

One approach is to relaunch the menu.  You don't need to "relogin", just something like:

killall <menuprogram> && SOUNDVAR=your_value <menuprogram>

whenever you want to change the value of SOUNDSVAR.  That could be in a script that could read from /proc/.../environ to determin which is the current value and toggle to the other.

But the specifics all depend on what menu/de/wm you are talking about.

Last edited by Trilby (2013-09-18 11:52:25)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2013-09-18 15:57:37

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: Change an environment variable without re-logging-in

I use xfce4, it is pretty much default with only few tweaks there and there. I tried killing the menubar and the panel program (xfce4-panel) restart by itself, but your idea sounds good. I try to work with it.

Offline

Board footer

Powered by FluxBB