Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Ralph Corderoy

Hi Dan,

> The first X session being :0.0, (you can specify a hostname before the
> colon) the second will be :1.0, will it not?

No, not necessarily.  When you start the X server you can tell it what
display number this particular X server has by specifying it as a
parameter.

X :1

The "switch user" mechanism in Gnome seems to leap straight from :0 to
:20, perhaps to allow the :0 user a few displays to use, e.g. for
Xnest(1).

The number determines the network port the X server listens on.  6000 is
the base,

$ grep -w 6000 /etc/services
x11 6000/tcpx11-0   # X Window System
x11 6000/udpx11-0
$

i.e. :0 listens on 6000 and :20 listens on 6020.

> I'm not sure about the .0, as you can also refer to it with just :0,
> :1, etc., and they get mapped on the local machine like :0 ->
> ctrl+alt+f7, :1 -> ctrl+alt+f8, etc., unless they're virtual (e.g.
> VNC)

It's "[network_host]:display[.screen]".  The screen defaults to 0.  It's
the logical X screen and may not relate to the physical screens you
have.

Here's I've two X server's running, :0 and :20.  The Unix domain sockets under
/tmp/.X11-unix are how clients connect to them.  lsof(8) shows :0 has quite a
few more clients than :20 but it's always showing Xorg as the command rather
than a client e.g. xclock(1).

$ sudo lsof /tmp/.X11-unix/*
COMMAND   PID USER   FD   TYPE DEVICE SIZE   NODE NAME
Xorg 6516 root1u  unix 0xee0cd700   16820 /tmp/.X11-unix/X0
Xorg 6516 root9u  unix 0xee0cdc40   17071 /tmp/.X11-unix/X0
Xorg 6516 root   10u  unix 0xef308380   17282 /tmp/.X11-unix/X0
Xorg 6516 root   11u  unix 0xeea5dc40   17338 /tmp/.X11-unix/X0
Xorg 6516 root   12u  unix 0xef37d1c0   17456 /tmp/.X11-unix/X0
Xorg 6516 root   13u  unix 0xeeedc540   19181 /tmp/.X11-unix/X0
Xorg 6516 root   14u  unix 0xeefffa80   19345 /tmp/.X11-unix/X0
Xorg 6516 root   15u  unix 0xee8f3a80   19478 /tmp/.X11-unix/X0
Xorg 6516 root   16u  unix 0xeea60a80   19495 /tmp/.X11-unix/X0
Xorg 6516 root   17u  unix 0xeeb7c1c0   20318 /tmp/.X11-unix/X0
Xorg 6516 root   18u  unix 0xef311e00   19593 /tmp/.X11-unix/X0
Xorg 6516 root   19u  unix 0xee579380   20089 /tmp/.X11-unix/X0
Xorg 6516 root   20u  unix 0xee5791c0   19941 /tmp/.X11-unix/X0
Xorg 6516 root   21u  unix 0xee582700  594142 /tmp/.X11-unix/X0
Xorg 6516 root   22u  unix 0xee640380   20041 /tmp/.X11-unix/X0
Xorg 6516 root   23u  unix 0xee640700   20046 /tmp/.X11-unix/X0
Xorg 6516 root   24u  unix 0xeeb08e00   20179 /tmp/.X11-unix/X0
Xorg 6516 root   25u  unix 0xeeb7ce00   20320 /tmp/.X11-unix/X0
Xorg 6516 root   26u  unix 0xef8ee8c0   20541 /tmp/.X11-unix/X0
Xorg 6516 root   27u  unix 0xef137c40  594383 /tmp/.X11-unix/X0
Xorg 6516 root   28u  unix 0xef28dc40  575863 /tmp/.X11-unix/X0
Xorg 6516 root   29u  unix 0xd10f58c0  614438 /tmp/.X11-unix/X0
Xorg 6516 root   30u  unix 0xefbbb380  584330 /tmp/.X11-unix/X0
Xorg 6516 root   31u  unix 0xefb82540  608470 /tmp/.X11-unix/X0
Xorg 6516 root   32u  unix 0xd10f5700  614453 /tmp/.X11-unix/X0
Xorg14916 root1u  unix 0xee60ee00  608993 /tmp/.X11-unix/X20
Xorg14916 root9u  unix 0xee60e380  609146 /tmp/.X11-unix/X20
Xorg14916 root   10u  unix 0xef1371c0  609777 /tmp/.X11-unix/X20
Xorg14916 root   11u  unix 0xef8ee540  609836 /tmp/.X11-unix/X20
Xorg14916 root   12u  unix 0xee736380  609951 /tmp/.X11-unix/X20
Xorg14916 root   13u  unix 0xc0d0a380  611567 /tmp/.X11-unix/X20
Xorg14916 root   14u  unix 0xc0d0a540  611677 /tmp/.X11-unix/X20
Xorg14916 root   15u  unix 0xeecdb700  611822 /tmp/.X11-unix/X20
Xorg14916 root   16u  unix 0xee583380  611888 /tmp/.X11-unix/X20
Xorg14916 root   17u  unix 0xef8c2c40  611911 /tmp/.X11-unix/X20
Xorg14916 root   19u  unix 0xd12f9e00  612433 /tmp/.X11-unix/X20
Xorg14916 root   20u  unix 0xc4ff48c0  612259 /tmp/.X11-unix/X20
Xorg14916 root   21u  unix 0xd1313380  612672 /tmp/.X11-unix/X20
Xorg14916 root   22u  unix 0xee60ac40  612382 /tmp/.X11-unix/X20
Xorg14916 root   23u  unix 0xd1313e00  612686 /tmp/.X11-unix/X20
Xorg14916 root   24u  unix 0xd1239c40  612724 /tmp/.X11-unix/X20
$

Cheers,
Ralph.


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Terry Coles
On Friday 07 Jan 2011, Ralph Corderoy wrote:
> I think you're approaching it the wrong way around.  When the X server
> starts it runs a command and when that command finishes the X server
> stops.  The command normally starts a window or session manager which in
> turn start up panels, initial applications, etc.  It's here that you
> should be running a browser.
> 
> Because of the flexibility it's hard to give explicit instructions as to
> how to set this up.  Is there a ~/.xsession or ~/.xsessionrc file?  If
> it's a shell script you should be able to spot where to run the browser
> in there.

There is a ~/.xsession.

> Alternatively, http://www.tinycorelinux.com/faq.html#appstart

That looks as if it might be the way.  I read those FAQs some weeks ago, but 
didn't know I wanted to do this then ;-(

-- 
Terry Coles
64 bit computing with Kubuntu Linux


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Ralph Corderoy

Hi Terry,

> This is going to run on our TC live disc with the command to start it
> being in /opt/bootlocal.sh.  There will only be one user when it is
> run and I know that X & the desktop are running when it gets to this
> part of the script.  I suppose it could conceivably happen the other
> way round, but I haven't seen it yet.
> 
> However, just in case; is there a reliable way of testing to see if X
> is up before launching Chromium?  If so, I could wait in a loop until
> it is.

I think you're approaching it the wrong way around.  When the X server
starts it runs a command and when that command finishes the X server
stops.  The command normally starts a window or session manager which in
turn start up panels, initial applications, etc.  It's here that you
should be running a browser.

Because of the flexibility it's hard to give explicit instructions as to
how to set this up.  Is there a ~/.xsession or ~/.xsessionrc file?  If
it's a shell script you should be able to spot where to run the browser
in there.

Alternatively, http://www.tinycorelinux.com/faq.html#appstart

Cheers,
Ralph.


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Victor Churchill
It's been a long time since I did it but I seem to recall you can set up a
.xinitrc file in the user's home directory to control things you want to
start when the X session starts. That way you know that X will be running,
and you don't need to know which $DISPLAY you are running.

-- 
best regards,

Victor Churchill,
Bournemouth
--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Dan Dart
The first X session being :0.0, (you can specify a hostname before the
colon) the second will be :1.0, will it not? I'm not sure about the .0, as
you can also refer to it with just :0, :1, etc., and they get mapped on the
local machine like :0 -> ctrl+alt+f7, :1 -> ctrl+alt+f8, etc., unless
they're virtual (e.g. VNC)

Cheers
--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Terry Coles
On Friday 07 Jan 2011, Ralph Corderoy wrote:
> John Carlyle-Clarke wrote:
> > Of course, if you have more than one X session running, or if you are
> > running X remotely, then things may go a bit wonky since DISPLAY will
> > need to be something else!
> 
> One way for this to happen is to "switch user" so that other user logs
> in on their own desktop.  `echo $DISPLAY' will show something else on
> that second X server, probably ":20.0".  So if one day that other user
> beats you to the machine, he gets :0.0 and you get lumbered with :20.0.
> 
> Where is this script to run at boot time?  It may also fail if the
> user's desktop isn't up and running by then.

This is going to run on our TC live disc with the command to start it being in 
/opt/bootlocal.sh.  There will only be one user when it is run and I know that 
X & the desktop are running when it gets to this part of the script.  I 
suppose it could conceivably happen the other way round, but I haven't seen it 
yet.

However, just in case; is there a reliable way of testing to see if X is up 
before launching Chromium?  If so, I could wait in a loop until it is.

-- 
Terry Coles
64 bit computing with Kubuntu Linux


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Ralph Corderoy

Hi Terry,

John Carlyle-Clarke wrote:
> Of course, if you have more than one X session running, or if you are
> running X remotely, then things may go a bit wonky since DISPLAY will
> need to be something else!

One way for this to happen is to "switch user" so that other user logs
in on their own desktop.  `echo $DISPLAY' will show something else on
that second X server, probably ":20.0".  So if one day that other user
beats you to the machine, he gets :0.0 and you get lumbered with :20.0.

Where is this script to run at boot time?  It may also fail if the
user's desktop isn't up and running by then.

Cheers,
Ralph.


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Terry Coles
On Friday 07 Jan 2011, John Carlyle-Clarke wrote:
> On 07/01/11 15:19, Terry Coles wrote:
> > I assume that I was right about the reason it wouldn't work in a script,
> > eg I'm not attached to the display in the X environment at the time?
> 
> That's pretty much it.  Processes generally inherit an environment from
> the process that spawns them.  xinit or startx or {x,k,g}dm set
> "DISPLAY" and other things when starting X and launching the clients
> (usually a window manager or similar).
> 
> This means when you start a shell in your graphical session, it inherits
> DISPLAY.  Start a terminal in X and do "echo $DISPLAY" to check it.
> 
> If your shell script was started outside of X in some way (by cron, atd,
> or boot process for example) then DISPLAY will not be set.
> 
> Of course, if you have more than one X session running, or if you are
> running X remotely, then things may go a bit wonky since DISPLAY will
> need to be something else!

Thanks.


-- 
Terry Coles
64 bit computing with Kubuntu Linux


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread John Carlyle-Clarke

On 07/01/11 15:19, Terry Coles wrote:

On Friday 07 Jan 2011, John Carlyle-Clarke wrote:


DISPLAY=:0.0 chromium-browser


Thanks.  That works fine.

I assume that I was right about the reason it wouldn't work in a script, eg
I'm not attached to the display in the X environment at the time?



That's pretty much it.  Processes generally inherit an environment from 
the process that spawns them.  xinit or startx or {x,k,g}dm set 
"DISPLAY" and other things when starting X and launching the clients 
(usually a window manager or similar).


This means when you start a shell in your graphical session, it inherits 
DISPLAY.  Start a terminal in X and do "echo $DISPLAY" to check it.


If your shell script was started outside of X in some way (by cron, atd, 
or boot process for example) then DISPLAY will not be set.


Of course, if you have more than one X session running, or if you are 
running X remotely, then things may go a bit wonky since DISPLAY will 
need to be something else!


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread Terry Coles
On Friday 07 Jan 2011, John Carlyle-Clarke wrote:

> DISPLAY=:0.0 chromium-browser

Thanks.  That works fine.

I assume that I was right about the reason it wouldn't work in a script, eg 
I'm not attached to the display in the X environment at the time?

-- 
Terry Coles
64 bit computing with Kubuntu Linux


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread John Carlyle-Clarke

On 07/01/11 15:04, John Carlyle-Clarke wrote:

On 07/01/11 15:02, Terry Coles wrote:

Hi,

Is there a reason why the Chromium Browser launches fine when I type

chromium-browser

in a shell, but doesn't when I put the same command into a script to
run at
boot time?




Try:-

TERMINAL=:0.0 chromium-browser




What am I talking about?

DISPLAY=:0.0 chromium-browser

--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Launching a graphical App from within a script

2011-01-07 Thread John Carlyle-Clarke

On 07/01/11 15:02, Terry Coles wrote:

Hi,

Is there a reason why the Chromium Browser launches fine when I type

chromium-browser

in a shell, but doesn't when I put the same command into a script to run at
boot time?

According to the error message, it can't find the display mode, so I'm
guessing that it works because I'm not in a true terminal when it works (it's
Aterm, which is a graphical app) and I am when the script is running.  Or is
it something else?

What do I need to do to get it to work?  I'm assuming I will need to do some
magic with xhost, etc, but some guidancce would be useful.



Try:-

TERMINAL=:0.0 chromium-browser



--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue


[Dorset] Launching a graphical App from within a script

2011-01-07 Thread Terry Coles
Hi,

Is there a reason why the Chromium Browser launches fine when I type

chromium-browser

in a shell, but doesn't when I put the same command into a script to run at 
boot time?

According to the error message, it can't find the display mode, so I'm 
guessing that it works because I'm not in a true terminal when it works (it's 
Aterm, which is a graphical app) and I am when the script is running.  Or is 
it something else?

What do I need to do to get it to work?  I'm assuming I will need to do some 
magic with xhost, etc, but some guidancce would be useful.

-- 
Terry Coles
64 bit computing with Kubuntu Linux


--
Next meeting:  Crown Hotel, Blandford Forum, Tuesday 2011-01-11 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
How to Report Bugs Effectively:  http://goo.gl/4Xue