screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Am I running under X?


From: Stephane Chazelas
Subject: Re: Am I running under X?
Date: Thu, 28 Jul 2005 16:38:42 +0100
User-agent: Mutt/1.5.7i

On Thu, Jul 28, 2005 at 10:55:03AM -0400, address@hidden wrote:
> How can I tell if I'm running under X in a shell script?  If I'm in X, I
> want to start screen:  screen -m -c /my/config/file.  If I'm not under X,
> I want to start without the -m.  It's an odd google to find the answer to
> this question, so your wisdom is appreicated.
[...]

Assuming a Bourne-like shell:

if [ -n "${DISPLAY++}" ]; then
  exec screen -m -c /my/config/file
fi

You may additionaly want to check whether you can connect to
that X server:

if xdpyinfo > /dev/null 2>&1; then
  exec screen -m -c /my/config/file
fi

If by "under X" you mean, is the current pseudo terminal
controlled by a X terminal emulator, you can try:

if xwininfo -id "$WINDOWID" > /dev/null 2>&1; then
  exec screen -m -c /my/config/file
fi

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]