0

Where do I find a list of well-known environment variables?

Background

I am writing a script that will start a video player. So I am looking for the environment variable analogous to $EDITOR/$PDFVIEWER but for video player, so that my tool will start the video player that is preferred by the user.

So environment variables that are used by software installed on a high portion of software and that are not only used by that particular single piece of software.

Ole Tange
  • 33,591
  • 31
  • 102
  • 198
  • Run `set` and read `help set` – ajeh May 10 '18 at 14:53
  • By "well-known" do you mean recognized or provided by the shell? Or specifically by Bash? (`$PDFVIEWER` does not satisfy those characterizations, but then again, I wouldn't consider it "well-known".) Otherwise, I'm not sure any such thing exists. – John Bollinger May 10 '18 at 14:54
  • 1
    That's not answerable as written. Every application and possibly library they use will have variables they use. Most of the time that's documented in the application's manual. For libraries (like the dynamic linker, libc, libssl), you may need to have a look at developer documentation. – Stéphane Chazelas May 10 '18 at 15:20
  • @StéphaneChazelas It is answerable, if there exists a website with a list of well-known environment variables. This would probably include environment variables used by the software installed on a high portion of UNIX-machines. – Ole Tange May 10 '18 at 16:05
  • @ajeh `set` only include environment variables that are set. I am looking for variables that I may not be aware of is used by commonly used software. – Ole Tange May 10 '18 at 16:06
  • 1) if they are not set, you don't need them 2) if they are not set, set your own as you wish 3) sounds like you are solutionizing something before defining the problem – ajeh May 10 '18 at 16:09
  • @ajeh I have tried elaborating the background: It is not for me, it is for the users of my software. The users are not known to me, but can be anywhere in the world. – Ole Tange May 10 '18 at 16:11
  • Not much of an answer, so: consider documenting a variable of your own choosing that could define the user’s preference. If it’s unset (or unusable), fall back to whatever you’re doing now. – Jeff Schaller May 10 '18 at 16:33
  • What you want is a command called `xdg-open`, not an environment variable. That pulls configuration from somewhere in `~/.config` or `~/.local/share`, but I don't remember where. – Austin Hemmelgarn May 10 '18 at 19:37

1 Answers1

3

See also: Where do EDITOR, PAGER, BROWSER environment variables come from?

EDITOR and PAGER are mentioned in the standards as belonging to variables you'd be unwise to conflict with since they are widely used [...] Various programs respect various combinations of them [...]

The BROWSER variable is not in the same league as EDITOR or PAGER - it is not mentioned by the standards. However, some programs may use them.

IMO it could be best to consider variables for the GUI, as not being commonly used, unless you have a specific use case in mind. The reason is that the user will have set their preferences in their graphical desktop through the MIME system instead.

For example, Gnome Settings app lets you choose a browser, but it does not set the $BROWSER environment variable.

In this case you could try using xdg-open instead.

(xdg-open apparently has some special-cases e.g. for falling back to BROWSER. https://utcc.utoronto.ca/~cks/space/blog/linux/XdgOpenWhichBrowser But that probably means if you want a browser, you might as well use xdg-open and let it handle things for you).

sourcejedi
  • 48,311
  • 17
  • 143
  • 296