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

Re: best way to check for an active X session from a maintainer script?



Hello!

On Tue, 11 Sep 2007 17:18:56 +0200, Evgeni Golov wrote:
> On Tue, 11 Sep 2007 09:55:00 -0500 Manoj Srivastava wrote:
>
>>         Umm. I am in X, right now.
>> __> who | awk '{print $2}'|grep -q '^:[0-9]'
>> __> 
>> 
>>         Do I need to be root?
>> __> sudo who | awk '{print $2}'|grep -q '^:[0-9]'
>> __> 
>
> Did you check the exit-code of grep? -q is kinda quiet, you know ;)

Nothing changed:
=====
luca@gismo:~$ who
luca     pts/1        Sep 12 01:58 (:0:S.0)
luca     pts/2        Sep 12 02:03 (:0:S.1)

luca@gismo:~$ who | awk '{print $2}'|grep -q '^:[0-9]'
luca@gismo:~$ 

luca@gismo:~$ who | awk '{print $2}'|grep '^:[0-9]'
luca@gismo:~$ 
=====

My X session is started from xdm which launch SBCL [1] from a shell
script to start StumpWM [2].

>>         So, this does not seem to work in all cases.
>
> However, THAT is right and was already corrected, the ^ is
> unnecessary.

Again, nothing changed:
=====
luca@gismo:~$ who | awk '{print $2}'|grep ':[0-9]'
luca@gismo:~$ 
=====

But without the awk part works:
=====
luca@gismo:~$ who | grep ':[0-9]'
luca     pts/1        Sep 12 01:58 (:0:S.0)
luca     pts/2        Sep 12 02:03 (:0:S.1)
luca@gismo:~$ 
=====

I don't know the internals of who, so just my 0.02€ :-)

Thx, bye,
Gismo / Luca

Footnotes: 
[1] http://packages.debian.org/sid/sbcl
[2] http://packages.debian.org/sid/stumpwm



Reply to: