Hello , today I ran into an issue because my BROWSER environment variable was set to /usr/bin/firefox even though I uninstalled firefox. I fixed the issue by adding export BROWSER=opera
in ~/.bashrc file.
Now my actual question is which file is exactly setting that BROWSER variable to firefox, because I cannot find it in my home directory files like bash_profile, bashrc and not even in the etc/environment, etc/profile.
I believe it is not a global environment variable since sudo printenv
doesn’t show a BROWSER variable but only printev
does. Also adding it to etc/environment don’t work, so it seems to be getting override by user definition but I’m not sure.
So where is it being set?
Thanks in advance if you reply to my curiosity-only question
It’s located in a somewhat obscure location.
/etc/xdg/plasma-workspace/env/envars.sh
4 Likes
Wow. Good find. I usually end up doing a grep
of /etc and $HOME. I’m thankful for text (well mostly) configuration files 
Some doc at: Session Environment Variables - KDE UserBase Wiki
If at the system level the location is /etc/xdg/plasma-workspace/env, then it seems at the user level it is $HOME/.config/plasma-workspace/env.
What is interesting, they say you might want to THEN source the file in .bashrc. Ugh, I’d just use .bashrc to keep things simple.
There’s a tip at archwiki which mentions this new (to me) location. The script could consist of only exporting a variable.
Tip: KDE Plasma supports executing shell scripts at login and even before launching Plasma, they can be used to set environment variables. See KDE#Autostart.
PS: When I was searching for this directory, I came across this KDE phabricator entry that says if GTK_USE_PORTAL=1 is set, firefox will use KDE File > Save dialogs. Someone suggested storing the variable in /etc/xdg/plasma-workspace/env/.
Thank you… Since it’s in /etc/ folder doesn’t that imply that it’s a global variable? And if it’s a global variable then why doesn’t it show up in sudo printenv
?
-
Check the value in System Settings > Applications > Default Applications > Web Browser. Or the shortcut, kcmshell5 componentchooser
.
-
What do the following show (hopefully opera if that is what you want):
I’m still trying to figure out why KDE felt they needed to create yet another location for environment variables
What’s the purpose? What problem were they trying to solve? This userbase says KDE startup is complicated and invites us to read the code to understand environment variables. UUUUmmm, okay 
1 Like