diff --git a/urxvt/ext/close-prompt b/urxvt/ext/close-prompt new file mode 100644 index 0000000..81c76ef --- /dev/null +++ b/urxvt/ext/close-prompt @@ -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; +} diff --git a/urxvt/ext/new-window b/urxvt/ext/new-window new file mode 100644 index 0000000..968434d --- /dev/null +++ b/urxvt/ext/new-window @@ -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 +# 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); + } +}