Discussion:
Problem scripting for arbitrary display
Mauro Fontana
2014-07-07 13:02:26 UTC
Permalink
Hey everyone

I come to you asking a very dumb question, but, as many simple problems,
perhaps the error is so obvious you'll never spot it.

I'm trying to make a simple script that runs xdotool with "at" command at a
specific time. After searching a lot, I found that as "at" works deattached
from the X session it was ran (or something like that), I had to append
"export DISPLAY=':0'" in order for xdotool to find an X server whose input
must be faked.

It was all rainbows and smiles, until I thought it would be better to
improve the script so it would run on an arbitrary X server, as I won't be
using always the same one. So basically I designed this minimal working
example.

The script itself:
http://paste.debian.net/108232/

The tempf file the scripts calls:
http://paste.debian.net/108234/

But it doesn't work.

When running ./temp.sh, I get a beautiful e-mail saying:
"Error: Can't open display: (null)
Failed creating new xdo instance"

The problem gets solved if I replace "export DISPLAY=$pantalla" in the
tempf file for "export DISPLAY=':0'", for example. However, this is not
what I'm trying to achieve.

If after running the script, if I type "echo $pantalla" it correctly
outputs displaynumber, so the variable is set. I can also see the "job ##
at DATE" message from at, so the problem isn't there neither. The options
are 2, bad scripting or not correctly understanding how xdotool works. I
can't find the syntax error, neither could I find a solution for a similar
problem, so I'm asking here for help, whatever be the case.

Thanks in advance and excuse me is this isn't the proper channel in order
to ask for help.

Cheers,
Mauro
--
You received this message because you are subscribed to the Google Groups "xdotool-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xdotool-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to xdotool-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/xdotool-users.
For more options, visit https://groups.google.com/d/optout.
Anthony Thyssen
2014-07-31 04:23:32 UTC
Permalink
The question becomes more of a... how does a command run at a arbitrary
time, without any connection to a existing session, get information about
what display it should display to!

DISPLAY is an environment variable, that is tied to the processes that
logged into the 'display'. The 'at' command (or any other 'cron' launched
command), has no connection to that session, so does not have that
information.

The simplest method would probably to have your current session write into
'dot' or 'config' file, which the 'at' command (when it does run) reads for
information about where it should be running, or otherwise doing, at the
time it is run.

Also something to think about.. What if you are running from two machines?
Say you logged in remotely from home, while your work machine is still
logged in. Or you are actually working from two separate machines, that
are side-by-side! Whcih display should 'at' commands (which is essentially
a 'third' background session).

Believe me I have hit that problem too!
Post by Mauro Fontana
Hey everyone
I come to you asking a very dumb question, but, as many simple problems,
perhaps the error is so obvious you'll never spot it.
I'm trying to make a simple script that runs xdotool with "at" command at
a specific time. After searching a lot, I found that as "at" works
deattached from the X session it was ran (or something like that), I had to
append "export DISPLAY=':0'" in order for xdotool to find an X server whose
input must be faked.
It was all rainbows and smiles, until I thought it would be better to
improve the script so it would run on an arbitrary X server, as I won't be
using always the same one. So basically I designed this minimal working
example.
http://paste.debian.net/108232/
http://paste.debian.net/108234/
But it doesn't work.
"Error: Can't open display: (null)
Failed creating new xdo instance"
The problem gets solved if I replace "export DISPLAY=$pantalla" in the
tempf file for "export DISPLAY=':0'", for example. However, this is not
what I'm trying to achieve.
If after running the script, if I type "echo $pantalla" it correctly
outputs displaynumber, so the variable is set. I can also see the "job ##
at DATE" message from at, so the problem isn't there neither. The options
are 2, bad scripting or not correctly understanding how xdotool works. I
can't find the syntax error, neither could I find a solution for a similar
problem, so I'm asking here for help, whatever be the case.
Thanks in advance and excuse me is this isn't the proper channel in order
to ask for help.
Cheers,
Mauro
--
You received this message because you are subscribed to the Google Groups
"xdotool-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/xdotool-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "xdotool-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xdotool-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To post to this group, send email to xdotool-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
Visit this group at http://groups.google.com/group/xdotool-users.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...