Using the "urxvt::term" Class

411 views Asked by At

I wanted to know if there are any resources available for understanding and using the 'term' class in urxvt.

The documentation makes a very general set of references to it, but doesn't really define the terms.

The uxrvt perl extensions also make very limited use of the 'term' object, so there isn't much code to study for reference.

My goals are simple:

  1. To open a new terminal window.

  2. To pass a command to the new terminal window, then leave the window open for further input. (example: "ls" or "echo 'Hello World'", then leave the cursor awaiting further input)

  3. To be able to specify which desktop the new terminal will appear on.

Questions:

1. How exactly is $term defined?

The documentation says:

$term = new urxvt::term $envhashref, $rxvtname, [arg...]

I've used "my $env = $self->env;" to define the $envhashref. So I suppose that the existing terminal's environment variables are used for the new terminal. I suppose this corresponds directly to the environment variables themselves, since the following reproduces those variables...

my @envv = $self->envv;
foreach (@envv) {
  print "$_\n";
}

...and the following creates a reference to the 'env' hash:

my $env = $self->env;

Is this correct? It seems odd to have to explicitly declare the environment if that setting will remain unchanged in the vast majority of cases.


2. How should $rxvtname be set? Setting it to a name of my choice results in two windows opening rather than one. That behavior is odd... what is the correct way to define the $rxvtname variable?

What exactly does ", [arg...]" refer to?


3. How is $term itself used? It apparently isn't a reference to the new terminal window. What is its purpose and how do you use it? An example would probably be extremely useful here.


4. How can $term->exec_async ($cmd) send a command to the new terminal window? Is there a better way to send commands to a new window? Examples?


5. Is there a way to specify which desktop a terminal window should appear in?


Hopefully this thread can serve as 'documentation' for anyone else who has already scoured the man pages for urxvt, urxvtperl (as well as urxvt.pm) and is left without a clear understanding. And if there's a comprehensive reference on the web somewhere that contains full explanations and examples, that would be great to know about, too. Thanks in advance for your help.

0

There are 0 answers