Add urxvt extensions
This commit is contained in:
parent
6f2a411528
commit
ca08de01c9
17
urxvt/ext/close-prompt
Normal file
17
urxvt/ext/close-prompt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
sub on_wm_delete_window {
|
||||||
|
my ($self, $event) = @_;
|
||||||
|
my $CP = `ps --ppid $self->{shell_pid} -o pid= | wc -l`;
|
||||||
|
chomp $CP;
|
||||||
|
if ( $CP != 0 ) {
|
||||||
|
return system("zenity --question --title 'Close window' --text 'Subprocess is running. Really close?'")
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub on_child_start {
|
||||||
|
my($self, $pid) = @_;
|
||||||
|
$self->{shell_pid} = $pid;
|
||||||
|
}
|
38
urxvt/ext/new-window
Normal file
38
urxvt/ext/new-window
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Cwd;
|
||||||
|
|
||||||
|
# Opening a new window.
|
||||||
|
# Fixed version of script from
|
||||||
|
# http://lists.schmorp.de/pipermail/rxvt-unicode/2012q3/001609.html
|
||||||
|
# by José Romildo Malaquias <malaquias at gmail.com>
|
||||||
|
# References: man 3 urxvtperl
|
||||||
|
# Debugging: urxvt --perl-lib ${HOME}/.urxvt -pe new-window
|
||||||
|
# Example config: URxvt.keysym.Control-Shift-N: perl:new-window
|
||||||
|
|
||||||
|
sub new_window
|
||||||
|
{
|
||||||
|
my ($self) = @_;
|
||||||
|
my $ccwd = readlink("/proc/".$self->{child_pid}."/cwd");
|
||||||
|
new urxvt::term $self->env, $urxvt::RXVTNAME, -cd => $ccwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub on_child_start {
|
||||||
|
my ($self,$pid) = @_;
|
||||||
|
|
||||||
|
$self->{child_pid} = $pid; # keep for later determining our shells
|
||||||
|
# CWD for relative path names
|
||||||
|
()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub on_user_command
|
||||||
|
{
|
||||||
|
my ($self, $cmd) = @_;
|
||||||
|
|
||||||
|
if ($cmd eq "new-window") {
|
||||||
|
new_window($self);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue