Recently I put
xset b off to my .bashrc. Now I'm annoyed by the error thet pops up when I log in via tty or via ssh, i.e. outside X session.
First thing that came in my mind was
[[ -z "$SOME_VAR" ]] && xset b off (well, turns out that testing variable being set vs. being empty is a different question). But which SOME_VAR is the correct one?
So I diffed tty's
set output and urxvt's
set output to see which variables are set in X and missing in tty. As expected, there were quite many differences (listing only those that seemed relevant to me):
Which one is the most correct and universal one to test in order to detect if I'm in an X session or not? Something that would work across as many distros and platforms and desktop environments as possible?
Or is there even better way than testing environment variables?