Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: How to set $ENV{'DISPLAY'} variable programatically?

by nysus (Parson)
on Apr 20, 2016 at 23:52 UTC ( [id://1161045]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to set $ENV{'DISPLAY'} variable programatically?
in thread How to set $ENV{'DISPLAY'} variable programatically?

Sorry, here is the script that I use to create an EventRepository object which extends my FFMech class (see OP for that code).

#!/usr/bin/perl package Mech; $ENV{'DISPLAY'} = ':3.0'; use Modern::Perl; use EventRepository2; my $er = EventRepository2->new(display => 0, fast_mode => 1, launch => + ['firefox', '-P', "CCAgenda", '-rep', '4244'], repl => 'localhost:42 +44'); $er->get ('http://slashdot.org'); $er->mySendKeys("^(l)slashdottiejksdjf");

When I run this code, I get the error noted in my last post.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^5: How to set $ENV{'DISPLAY'} variable programatically?
by Anonymous Monk on Apr 21, 2016 at 01:30 UTC

      Yes, that worked! I also had to change require back to use for loading EventRepository2 class.

      .

      This will probably work good enough, but the holy grail would be able to do something as illustrated with the code below. The code doesn't work but you get the idea of what I'm trying to do. I'd like each object to be able to set which display it's on:

      #!/usr/bin/perl package Mech; BEGIN { $ENV{'DISPLAY'} = ':3.0'; unshift @INC, "/home/perl/perl-lib"; + } use Modern::Perl; use EventRepository2; my $er = EventRepository2->new(display => 0, fast_mode => 1, launch => + ['firefox', '-P', "Profile1", '-rep', '4244'], repl => 'localhost:42 +44'); $er->get ('http://slashdot.org'); $er->mySendKeys("^(l)slashdottiejksdjf"); $ENV{'DISPLAY'} = ':2.0'; my $er = EventRepository2->new(fast_mode => 1, launch => ['firefox', ' +-P', "Profile2", '-rep', '4242'], repl => 'localhost:4242'); $er->get ('http://nyt.com'); $er->mySendKeys("^(l)calendarie"); $ENV{'DISPLAY'} = ':1.0'; my $er = EventRepository2->new(fast_mode => 1, launch => ['firefox', ' +-P', "Profile3", '-rep', '4243'], repl => 'localhost:4243'); $er->get ('http://digg.com'); $er->mySendKeys("^(l)diggie");

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

Re^5: How to set $ENV{'DISPLAY'} variable programatically?
by Anonymous Monk on Apr 21, 2016 at 01:23 UTC
    Try  require EventRepository2;

      Thanks. The program at least runs now but I'm getting a Too late to run INIT block at /usr/lib/x86_64-linux-gnu/perl5/5.2/X11/GUITest.pm So I'm guessing X11::GUITest isn't getting loaded now.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
      $nysus = $PM . ' ' . $MCF;
      Click here if you love Perl Monks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1161045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-18 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found