Re: Check if X is running

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Kevin Geiss
Date:  
To: plug-discuss
Subject: Re: Check if X is running
you could try

pgrep X

at least it would be one less process forked and exec'd, compared to running ps and grep separately :)

plus, you don't even have to parse its output, you can check its return status. (0 means there was a process whose name matched)

pgrep is a pretty cool program you'll probably want to know about anyway, along with its sister pkill.

and 'qpkg -f /usr/bin/pgrep' tells me it's in the procps package, so you probably already have it on your system.

On Thu, Nov 18, 2004 at 05:03:28PM -0700, Jared Anderson wrote:
> I just want to check if X is running - for instance: suppose I create an edit script, to open, say vi, if X is not running, or gvim if it is.
>
> I know I can ps -a | grep; but it doesn't seem like the most efficient way.
> Also, checking the DISPLAY variable worked rather well until now.
> I could also probe the exit status of many commands.
>
> I am just curious what others do.
>
>
>
> Somebody once said:
> >I think it may help if you clarify the question a little bit.
> >
> >You are running a script and it needs to ceck for the presence of a
> >running X server?
> >
> >Or are you trying to run X and unable to get the display using a
> >specific driver, and there are trying to troubleshoot via a script?
> >
> >The methodology shouldn't be any different in actuality, just pipe ps
> >ax to match X via egrep.
> >
> >
> >On Thu, 18 Nov 2004 15:02:14 -0700, Jared Anderson
> ><> wrote:
> >> Just curious of the most effective way to determine if X is running in a shell script. I have used a few ugly methods of such, but they are ugly: the most recent is no longer effective while using radeonfb driver and splashutils. Any useful input would be appreciated!!
> >>
> >> Thanks.
> >>
> >> -----
> >> Computers are like air conditioners.  Both stop working, if you open windows.
> >>        -- Adam Heath

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss