Environment Variables

Some notes because I can never remember which envvar I need to set to debug something.

I need to document these better, but here’s a rough list of some in my history.

TMOUT
Idle timeout for a shell.
DISPLAY
X11 display. Values like :0
XDG_RUNTIME_DIR
Freedesktop runtime directory, usually something like /run/user/1000.
GDK_BACKEND
If you set this to “broadway” and set BROADWAY_DISPLAY, you can run GTK programs in the browser. Can set to “x11” and “wayland”.
QT_QPA_PLATFORM
Can set to values like “wayland”, “xcb”.
PULSE_SERVER
Doesn’t need to be set, but can set to a value like “unix:/run/user/1000/pulse/native2” (some other socket).
WAYLAND_DISPLAY
Normally set to a value like “wayland-0”. Can set to other values to switch where a wayland program appears.
TERM
Colors not working? Can set to values like “xterm-256color”. A more permanent solution is to update your terminfo.
MOZ_WAYLAND
Can set to “0” to disable Wayland on Firefox.
GDK_DEBUG
Can set to values like “vulkan-disable”, “xim”, “draw”, “events”, “all”.
GTK_DEBUG
Set this to “interactive” to view GTK debugging information (there’s also a hotkey that’s now enabled by default. I think it’s like Ctrl+Shift+D or something).
GTK_USE_PORTAL
Values like “0”, “1”. I forget what I was debugging with this.
PIPEWIRE_CONFIG_NAME
Can set to an absolute path? Don’t remember.
NIXPKGS_ALLOW_UNFREE
Can set to “1”, but usually don’t. I think I did this temporarily to try out “firefox-nightly-bin”.
MANPATH
man can search here.
PINENTRY_USER_DATA
Don’t remember. I think I was trying to figure out why Emacs wasn’t prompting for a GPG key password with a GUI.
TZ
Can be set to a timezone like “America/Los_Angeles” for the “date” command.
LD_LIBRARY_PATH
Look at man ld.so.8.

There are some times when I run into issues with Nix where an application can't find a library, so I override the LD_LIBRARY_PATH. For example, something like:

LD_LIBRARY_PATH=$(nix-build '<nixpkgs>' -A imagemagick)/lib emacs

This is also how Pipewire overrides some (IIRC PulseAudio) functionality in NixOS.

LD_PRELOAD
Also look at man ld.so.8
EDITOR
It should be set to emacsclient -c.
XMODIFIERS
If you’re using some other input method (like ibus) you might set it to @im=ibus.

Note that in some sandbox situations keyboard input won’t work if this environment variable or input method variables below are set. I think this happens because the sandboxed application tries to communicate with the input method, but is unable to. You also might be able to fix this temporarily by just killing the input method process (like pkill ibus). I don’t remember off the top of my head.

QT_IM_MODULE
If you’re using ibus, set it to ibus.
GTK_IM_MODULE
If you’re using ibus, set it to ibus. I’m just cargo-culting here, and I should double check to see what happens without this.