Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 06-21-2010, 08:31 AM   #16
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195

Sorry to have taken so long to get back; I've just got an Internet connection again.

Copy and paste are working within urxvt:
  • via the X mechanism of copy by selection and paste by "middle mouse" (actually the equivalent action of left and right buttons together).
  • via the CUA mechanism of copy selection by Shift+Delete and paste by Shift+Insert.
Copy and paste are not working in either direction between urxvt and OOo, Mousepad (Xfce's GUI text editor) and Firefox -- using all three copy methods (selection/Shift+Delete/Ctrl+C) and paste methods (middle-mouse/Shift+Insert/Ctrl+V) in the GUI apps.

How does urxvt use the perl library? The ArchWiki on urxvt describes a file called clipboard containing a sub called on_sel_grab. Presumably the urxvt binary is designed to execute that file and sub when the user selects some text ... ?

I'll be studying a perl primer to find out how to add write-to-file in the sub to demonstrate that it is being run (or not).

Presumably if on_sel_grab() had run properly, Ctrl+V would work in most GUI apps ... ?

It would be very nice to get Ctrl+Shift+C/V working because this is initially for use on a netbook. It has a touchpad so "middle mouse click" is difficult and both Insert and Delete are half size keys on the top row so both Shift+Insert and Shift+Delete are awkward. Besides, I'm used to it.

Initial experiments suggest URxvt.keysym.M-S-<whatever> can't be unmapped from M-S so the only option is to explore modifying the build parameters or source code.
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-21-2010, 01:17 PM   #17
Senior Member
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,364

Rep: Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833Reputation: 833
Well I've said all I can about getting this specific copy/paste issue working...I have it working with shift+insert/middle-click on my desktop but I have no laptop and haven't tried Ctrl+C/V (though I'm sure it can be done). You might want to take a look at `man urxvtperl` which has some good information. Instead of using `urxvt --perl-lib /path/to/dir -pe scriptname`, I set those options in .Xdefaults as described in my previous post (URxvt.perl-lib and URxvt.perl-ext-common); however, if you are having trouble with getting that to work, you may wish to try the manual method mentioned in the man page. For info on the on_sel_grab bit, see the Hooks section in that same man page.
1 members found this post helpful.
Old 06-24-2010, 10:52 AM   #18
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Thanks for your detailed and informative help T3slider :-) It has gone a long way toward evolving a satisfactory solution, although I'm still:
  • using ~/.Xresources rather than ~/.Xdefaults (it works and I don't know any difference between them that signifies .Xdefaults is more appropriate -- always willing to learn, though).
  • Putting the Perl functions file, clipboard, in the default directory, /usr/lib/urxvt/perl
As installed, urxvt follows X tradition: selecting text copies it to the X PRIMARY buffer from where it can be pasted using both "middle mouse click" and Shift+Insert.

That's fine until you want to use urxvt with applications that use the X CLIPBOARD buffer, which also use the Common User Access (CUA) Ctrl+C and Ctrl+V key combinations. Then it would be useful to be able to:
  • Copy from urxvt to the X CLIPBOARD buffer and paste from there using Ctrl+V, menus etc.
  • Copy from other programs using Ctrl+C, menus etc into the X CLIPBOARD buffer and then paste it into urxvt.
Which key combinations to use?
  1. Ctrl+C is not practicable in terminals where it is used to generate Break.
  2. Ctrl+V is more practicable but is used in bash, as in vi, to allow the insertion of a control character into the command string.
  3. Ctrl+Shift+C/V are widely used in other terminal emulators but Ctrl+Shift+<anything> seems not to be available in urxvt where Ctrl+Shift is the key combination for unicode data entry.
  4. Super+C/V is easy to reach and rarely used -- so that's the one I chose.
The only other design decision was not to bother with a key combination to copy the selection to the X CLIPBOARD buffer but to extend the original "selecting copies to the X PRIMARY" to "selecting copies to both X PRIMARY and X CLIPBOARD".

This scheme was implemented by installing xclip (xsel is an alternative) ...

... by creating /usr/lib/urxvt/perl/clipboard (root:root, rw-r--r--) ...
#! perl

sub on_sel_grab {
    my $query = $_[0]->selection;
    open (my $pipe,'| /usr/bin/xclip -in -selection clipboard') or die;
    print $pipe $query;
    close $pipe;

sub paste {
    my ($self) = @_;
    my $content = `/usr/bin/xclip -loop 1 -out -selection clipboard` ;
    $self->tt_write ($content);

sub on_user_command {
    my ($self, $cmd) = @_;
    if ($cmd eq "clipboard:paste") {
... and by adding corresponding lines to ~/.Xresources (~./Xdefaults could also be used but I did not test it)
URxvt.keysym.Mod4-v: perl:clipboard:paste
URxvt.perl-ext-common: default,matcher,clipboard
  1. Acknowledgements and thanks to the many who shared information: all in this LQ thread, all contributors to the ArchLinux WIKI urxvt page, Sergei Steshenko who suggested a variation on the ArchLinux WIKI Perl that made it work on my system in this LQ thread, the Play Linux Blog page on urxvt copy-and-paste and, of course, the authors of urxvt itself (listed in the urxvt man page).
  2. The on_sel_grab() and on_user_command() functions in /usr/lib/urxvt/perl/clipboard are urxvt "hook"s as described in the urxvtperl man page.
  3. xmodmap can be used to show whether Super (actually Super_R and Super_L) are mapped to the "mod4" used in URxvt.keysym.Mod4-v
  4. The Super key is sometimes known as the Windows key.
  5. The "clipboard:paste" in URxvt.keysym.Mod4-v: perl:clipboard:paste identifies the user command which is handed to the on_user_command() function.
  6. The "clipboard" in URxvt.perl-ext-common: default,matcher,clipboard tells urxvt to load the clipboard Perl file when it initialises the terminal.

Last edited by catkin; 06-24-2010 at 10:56 AM. Reason: Perl indentation typo
1 members found this post helpful.
Old 06-07-2011, 10:27 AM   #19
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195

Thanks to information on the urxvt mailing list, paste by Control+Shift+V is now configured. The .Xresources file now looks like
URxvt.background: #efd5c6
URxvt.boldFont: xft:Liberation Mono:bold:pixelsize=14:antialias=true:hinting=true
URxvt.font: xft:Liberation Mono:pixelsize=14:antialias=true:hinting=true
URxvt.geometry: 111x33
URxvt.iso14755: False
URxvt.keysym.Shift-Control-V: perl:clipboard:paste
URxvt.matcher.button: 1
URxvt.perl-ext-common: default,matcher,clipboard
URxvt.perl-lib: /home/c/lib/urxvt/perl
URxvt.saveLines: 8192
URxvt.scrollBar_right: True
URxvt.scrollstyle: next
URxvt.urlLauncher: firefox
Change notes:
  1. Removed a trailing space on URxvt.keysym.Mod4-v: perl:clipboard:paste (caused breakage; upgrade to xrdb 1.0.9 triggered the changed behaviour).
  2. Added URxvt.perl-lib: /home/c/lib/urxvt/perl (so customised urxvt perl lib not lost on upgrade).
  3. Added URxvt.scrollstyle: next (wider right scroll bar; easier to land in).
  4. Corrected URxvt.iso14755_52 to URxvt.iso14755 (iso14755_52 is a valid option according to urxvt --help output; IDK what it controls).
  5. Changed URxvt.keysym.Mod4-v to URxvt.keysym.Shift-Control-V (possible now Shift+Control does not trigger ISO14755 feature).

Last edited by catkin; 06-07-2011 at 10:28 AM. Reason: disabled smileys in text


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] TERM=rxvt / rxvt-unicode and ctrl-L irb Slackware 10 06-09-2010 05:09 AM
rxvt unicode problem with fluxbox Josh000 Slackware 16 12-24-2009 03:45 AM
rxvt-unicode fonts proper setup zomane Linux - Desktop 1 04-12-2009 05:02 PM
problem with rxvt-unicode corbis_demon Linux - Software 0 11-27-2007 10:55 AM
Making rxvt-unicode change window title when using ssh tkarkkainen Linux - Software 1 10-15-2007 03:07 PM

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration