gaurav208012

urxvtclip

Dec 2nd, 2020
836
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #############################################################################
  2. #
  3. # -->Add these lines to your .Xdefaults/.Xresources for extension to work:--
  4. #
  5. #
  6. # URxvt.keysym.Shift-Control-V: perl:clipboard:paste
  7. # URxvt.iso14755: False
  8. # URxvt.perl-ext-common: default,clipboard
  9. #
  10. # -->now save this extension in /usr/lib/urxvt/perl/clipboard
  11. # -->this extension requires "xclip" to work.please download it from your
  12. # -->distribution's repos.
  13. # --> Use Ctrl+Shift+V to paste the text in urxvt.
  14. # --> To copy the text from urxvt just select it with mouse and it will be
  15. # --> copied to the clipboard, use Ctrl+V to paste the text elsewhere.
  16. #
  17. #                   -Credit goes to Original Author
  18. ############################################################################
  19.  
  20.  
  21.  
  22. #! perl
  23.  
  24. sub on_sel_grab {
  25.     my $query = $_[0]->selection;
  26.     open (my $pipe,'| /usr/bin/xclip -in -selection clipboard') or die;
  27.     print $pipe $query;
  28.     close $pipe;
  29. }
  30.  
  31. sub paste {
  32.     my ($self) = @_;
  33.     my $content = `/usr/bin/xclip -loop 1 -out -selection clipboard` ;
  34.     $self->tt_write ($content);
  35. }
  36.  
  37. sub on_user_command {
  38.     my ($self, $cmd) = @_;
  39.     if ($cmd eq "clipboard:paste") {
  40.         $self->paste;
  41.     }
  42. }
  43.  
RAW Paste Data