Check, if X is already running? (Solved)

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

Check, if X is already running? (Solved)

#1 Post by RSH »

Hi.

I have some scripts that are running manually executed by menu entry or called from other scripts.

When called from other scripts X is not already running then.

But the scripts usually shows Xdialog messages.

So, how can I check, if X is already running, to avoid error messages in /tmp/bootsysinit.log.

Code: Select all

Xdialog: Error initializing the GUI...
Do you run under X11 with GTK+ v1.2.0+ installed ?
Thanks,

RSH
Last edited by RSH on Sat 09 Aug 2014, 18:50, edited 1 time in total.
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#2 Post by SFR »

Hey RSH, this should do:

Code: Select all

[ "$DISPLAY" ] && echo "X" || echo "no X"
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#3 Post by RSH »

Thanks!
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

Code: Select all

test "`pidof X`" && echo "X is running" || echo "OK"
would also give a correct message if the program is executed from
an additional linux kernel terminal console,
( switched to by Control+Alt+Fx )
which would not have DISPLAY set.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#5 Post by technosaurus »

You can also test for a socket at:
/tmp/.X11-unix/X*
Unix domain socket for display number *

This is how I replaced waitforx with a shell function.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply