check if X is running?

1999-01-24 Thread Hamish Moffatt
Can anyone suggest a good way to tell if the user is running a program from X? A program I maintain can run in terminal or graphical mode. It currently checks if graphics are available by comparing $TERM to a string included at compile time. That's xterm by default, which doesn't work on Debian

Re: check if X is running?

1999-01-24 Thread Martin Held
I think another way to do it is to build two seperate binaries. For example, create xprog and prog, one that is X-only, and another that is console-only. This allows the user to specifcally set which version they want, and it might also reduce the amount of code needed per program and speed it

Re: check if X is running?

1999-01-24 Thread Hamish Moffatt
On Sun, Jan 24, 1999 at 02:30:56AM +, Martin Held wrote: I think another way to do it is to build two seperate binaries. For example, create xprog and prog, one that is X-only, and another that is console-only. This allows the user to specifcally set which version they want, and it might

Re: check if X is running?

1999-01-24 Thread Martin Held
Hmm. This sounds a lot like the Matlab Engineering tool I just learned how to use last Term. It's mainly console based, but can display graphs and plots and the like. If the user doesn't have the DISPLAY variable set right, it just tries to send the graphics off to a null server and doens't

Re: check if X is running?

1999-01-24 Thread aqy6633
I think another way to do it is to build two seperate binaries. For example, create xprog and prog, one that is X-only, and another that is console-only. This allows the user to specifcally set which version they want, and it might also reduce the amount of code needed per program and speed

Re: check if X is running?

1999-01-24 Thread Hamish Moffatt
On Sun, Jan 24, 1999 at 02:43:49AM +, Martin Held wrote: Hmm. This sounds a lot like the Matlab Engineering tool I just learned how to use last Term. It's mainly console based, but can display graphs and plots and the like. If the user doesn't have the DISPLAY variable set right, it

Re: check if X is running?

1999-01-24 Thread Havoc Pennington
On Sun, 24 Jan 1999, Hamish Moffatt wrote: I'd like to remove that check and make it a better one. Is checking for $DISPLAY sufficient? Why not just try to open the display, and if that fails bail out to text mode? (Since $DISPLAY might be invalid, or there might be a -display command line