You are not logged in.
From the command line it is fairly easy
$ echo $VAR1
$ VAR1=toast bash
$ echo $VAR1
toast
$
But there is a user-wide way?
I tried to play around with systemctl --user import-environment and systemctl --user set-environment but I could not manage to get any result.
Offline
export VAR1=toast
EDIT
After a second read...
But there is a user-wide way?
If you want to set a variable for all applications launched from elsewhere (e.g. in a graphical environment), I don't think there is any way. Setting variables only affects the current shell/application session, not other ones.
The `systemctl set-environment` approach only affects the systemd daemon (although - if you launch applications as systemd services, it might work - but I haven't tried that).
Last edited by ayekat (2016-11-25 10:42:59)
Offline
Also, when you call bash from within bash like that you're actually starting a new shell:
$ echo $foo
$ echo $$
953
$ foo=bar bash
$ echo $foo
bar
$ echo $$
1391
$ exit
exit
$ echo $foo
$ echo $$
953
($$ is PID)
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
This is not how it works - the environment is a process environment. You need to alter it for the shell process that you use to spawn other processes (which will usually inherit the parenting environment)
This is eg. a bash but also krun, gnomedo, plasma-desktop, ....
Altering the process environment from outside is not globally supported (but eg. via dedicated dbus interfaces for few processes, ...)
What exactly are you trying to do (ie. which problem do you seek to solve - altering the env of a running process is a non globally available solution attempt)
Offline