1 |
On Sunday 05 December 2004 00:54, Peter Gordon wrote: |
2 |
> Kevin O'Gorman wrote: |
3 |
> | Is there a way for a script (bash, for instance) to know |
4 |
> | if it's running under X, such as in an xterm or konsole? |
5 |
> | |
6 |
> | I want to have scripts that run graphical tools if the |
7 |
> | infrastructure is present, and text tools otherwise. |
8 |
> | For me this is particularly useful for tools I don't use |
9 |
> | all that often, and can forget that a graphical version |
10 |
> | exists. |
11 |
> |
12 |
> One way to do it (though I don't know how to do this in Bash) is to check |
13 |
> X's Process ID (PID). If `pidof X` returns an integer, than that's the PID |
14 |
> of the currently running X server. If X is not running it will return an |
15 |
> empty string. |
16 |
|
17 |
The $DISPLAY method is safer. X could be running for another user, or X is |
18 |
running for you but the script isn't running in a login shell, or or or. |
19 |
|
20 |
Uwe |
21 |
|
22 |
-- |
23 |
Alternative phrasing of the First Law of Thermodynamics: |
24 |
If you eat it, and you don't burn it off, you'll sit on it. |
25 |
|
26 |
http://www.uwix.iway.na (last updated: 20.06.2004) |
27 |
|
28 |
-- |
29 |
gentoo-user@g.o mailing list |