I want to access environment variable from a Gnome-Shell extension.
Some context: I want to create an extension adding "Xorg" or "Wayland" to the panel, based upon the environment variable $XDG_SESSION_TYPE
. I have to do this because I frequently switch (Wine has issues with Wayland), and I don't always remember which type of session is running.
I was able to find how to get environment variables in the source code of the Argos extension:
Also the environment variable are stored as an array of strings and should be parsed, i.e.: split on the first '=' occurrence to separate the key and the value.
EDIT:
GLib.getenv('ENV_VAR_NAME')
is more convenient because it avoids parsing the environment variable (thanks to @andyholmes).