You are not logged in.

#1 2006-09-08 08:34:16

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

script question, detect if inside X

How can I detect if a script is executed in a X environment or outside?
Thanks

Offline

#2 2006-09-08 08:55:29

chrismortimore
Member
From: Edinburgh, UK
Registered: 2006-07-15
Posts: 655

Re: script question, detect if inside X

As in you want the script to know whether it is in X or not?  Or you want a separate program to check if a script was started in X?

For the first, I reckon just checking to see if DISPLAY is set is enough.
For the second, I have no idea.


Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB

Offline

#3 2006-09-08 10:31:01

palandir
Member
Registered: 2006-05-14
Posts: 73

Re: script question, detect if inside X

2nd: if $DISPLAY is NOT set. wink

Offline

#4 2006-09-08 10:36:56

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: script question, detect if inside X

Thanks everyone, here the solution... easy and working:

if [ ${DISPLAY} == "" ]
then
  elinks
else
  firefox
fi

Offline

Board footer

Powered by FluxBB