2

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.

9
  • Run set and read help set
    – ajeh
    May 10, 2018 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. May 10, 2018 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. May 10, 2018 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, 2018 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, 2018 at 16:06

1 Answer 1

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).

Not the answer you're looking for? Browse other questions tagged .