From deee38454aed9bffd270f2ec8a4bcae6d34bc398 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 26 Apr 2014 22:42:30 +1200 Subject: Replace clipboard urxvt with abbreviated script I didn't need the keybindings or the paste functionality, just the autocopy feature. --- Makefile | 4 +-- X/Xresources | 4 +-- urxvt/clip | 22 ++++++++++++ urxvt/clipboard | 109 -------------------------------------------------------- 4 files changed, 25 insertions(+), 114 deletions(-) create mode 100644 urxvt/clip delete mode 100644 urxvt/clipboard diff --git a/Makefile b/Makefile index a99b5002..b07da88f 100644 --- a/Makefile +++ b/Makefile @@ -99,8 +99,8 @@ install-tmux : install-urxvt : mkdir -p $(HOME)/.urxvt - rm -f $(HOME)/.urxvt/clipboard - ln -s $(PWD)/urxvt/clipboard $(HOME)/.urxvt/clipboard + rm -f $(HOME)/.urxvt/clip + ln -s $(PWD)/urxvt/clip $(HOME)/.urxvt/clip install-vim : mkdir -p $(HOME)/.vim diff --git a/X/Xresources b/X/Xresources index 75a9f154..a2f8a834 100644 --- a/X/Xresources +++ b/X/Xresources @@ -7,7 +7,6 @@ Xft.rgba : none ! Urxvt URxvt.buffered : false -URxvt.clipboard.autocopy : true URxvt.cursorBlink : on URxvt.cutchars : <>[]{}|* URxvt.depth : 32 @@ -16,8 +15,7 @@ URxvt.font : xft:Ubuntu Mono:size=12,xft:Deja Vu Sans Mono,xft:Loh URxvt.internalBorder : 0 URxvt.iso14755 : false URxvt.iso14755_52 : false -URxvt.perl-ext : clipboard -URxvt.perl-ext-common : clipboard +URxvt.perl-ext-common : clip URxvt.perl-lib : /home/tom/.urxvt URxvt.pointerBlank : true URxvt.saveLines : 10000 diff --git a/urxvt/clip b/urxvt/clip new file mode 100644 index 00000000..ce698328 --- /dev/null +++ b/urxvt/clip @@ -0,0 +1,22 @@ +#!/usr/bin/env perl + +# Copy PRIMARY selections to the clipboard too with xsel(1). + +use strict; +use warnings; + +sub on_start { + my ($self) = @_; + $self->enable( sel_grab => \&clip ); + return; +} + +sub clip { + my ($self) = @_; + if ( open CLIPBOARD, '| xsel -ib' ) { + print CLIPBOARD $self->selection(); + close CLIPBOARD; + } + return; +} + diff --git a/urxvt/clipboard b/urxvt/clipboard deleted file mode 100644 index 8e71792f..00000000 --- a/urxvt/clipboard +++ /dev/null @@ -1,109 +0,0 @@ -#! perl -w -# Author: Bert Muennich -# Website: http://www.github.com/muennich/urxvt-perls -# License: GPLv2 - -# Use keyboard shortcuts to copy the selection to the clipboard and to paste -# the clipboard contents (optionally escaping all special characters). -# Requires xsel to be installed! - -# Usage: put the following lines in your .Xdefaults/.Xresources: -# URxvt.perl-ext-common: ...,clipboard -# URxvt.keysym.M-c: perl:clipboard:copy -# URxvt.keysym.M-v: perl:clipboard:paste -# URxvt.keysym.M-C-v: perl:clipboard:paste_escaped - -# Options: -# URxvt.clipboard.autocopy: If true, PRIMARY overwrites clipboard - -# You can also overwrite the system commands to use for copying/pasting. -# The default ones are: -# URxvt.clipboard.copycmd: xsel -ib -# URxvt.clipboard.pastecmd: xsel -ob -# If you prefer xclip, then put these lines in your .Xdefaults/.Xresources: -# URxvt.clipboard.copycmd: xclip -i -selection clipboard -# URxvt.clipboard.pastecmd: xclip -o -selection clipboard -# On Mac OS X, put these lines in your .Xdefaults/.Xresources: -# URxvt.clipboard.copycmd: pbcopy -# URxvt.clipboard.pastecmd: pbpaste - -# The use of the functions should be self-explanatory! - -use strict; - -sub on_start { - my ($self) = @_; - - $self->{copy_cmd} = $self->x_resource('clipboard.copycmd') || 'xsel -ib'; - $self->{paste_cmd} = $self->x_resource('clipboard.pastecmd') || 'xsel -ob'; - - if ($self->x_resource('clipboard.autocopy') eq 'true') { - $self->enable(sel_grab => \&sel_grab); - } - - () -} - -sub copy { - my ($self) = @_; - - if (open(CLIPBOARD, "| $self->{copy_cmd}")) { - my $sel = $self->selection(); - utf8::encode($sel); - print CLIPBOARD $sel; - close(CLIPBOARD); - } else { - print STDERR "error running '$self->{copy_cmd}': $!\n"; - } - - () -} - -sub paste { - my ($self) = @_; - - my $str = `$self->{paste_cmd}`; - if ($? == 0) { - $self->tt_paste($str); - } else { - print STDERR "error running '$self->{paste_cmd}': $!\n"; - } - - () -} - -sub paste_escaped { - my ($self) = @_; - - my $str = `$self->{paste_cmd}`; - if ($? == 0) { - $str =~ s/([!#\$%&\*\(\) ='"\\\|\[\]`~,<>\?])/\\\1/g; - $self->tt_paste($str); - } else { - print STDERR "error running '$self->{paste_cmd}': $!\n"; - } - - () -} - -sub on_user_command { - my ($self, $cmd) = @_; - - if ($cmd eq "clipboard:copy") { - $self->copy; - } elsif ($cmd eq "clipboard:paste") { - $self->paste; - } elsif ($cmd eq "clipboard:paste_escaped") { - $self->paste_escaped; - } - - () -} - -sub sel_grab { - my ($self) = @_; - - $self->copy; - - () -} -- cgit v1.2.3