Setting up environments variables on specific Qubes OS qubes

published Mar 07, 2022

Sometimes you need a specific qube to start up, or start one of its applications up, with a specific environment variable set to a specific value. This guide helps you accomplish that.

The following guide requires you be using a recent-enough Qubes OS release that includes this fix.

The environment.d Freedesktop.org standard is a mechanism that allows you to set custom environment variables for user sessions.  Linux distributions that implement the environment.d Freedesktop.org standard are the majority.  As of today, Qubes OS follows this standard just like its parent (Fedora) does.

Set a variable up in a qube

Suppose you need to set the environment variable VISUAL to have the value kwrite in qube accounting.  Do the following:

  1. Launch the accounting qube.
  2. Open the file manager in that qube, and navigate to the ~/.config directory.
  3. Create folder environment.d if it doesn't yet exist.
  4. Within that new folder, create an empty file visualkwrite.conf.
  5. Add the following content to the file: VISUAL=kwrite
  6. Shut off the qube, and start it again.

Once the qube is running again, you will notice that every app launched in the qube has the variable properly set up.

Set a variable up in a template for all qubes

You'll do the same thing in a template qube, except for the following differences:

  • You will do everything as root rather than as user
  • You'll create the environment config file in folder /etc/environment.d rather than ~/.config/environment.d.

That's all.