my mods for watcher.pl take 1

This commit is contained in:
Petr Nyc
2026-06-05 12:02:57 +02:00
parent 1902fe4f1f
commit 657223f051

View File

@@ -22,7 +22,7 @@ use Fcntl qw(O_RDWR O_NONBLOCK);
use IO::Select; use IO::Select;
use POSIX qw(strftime mkfifo); use POSIX qw(strftime mkfifo);
my $SCRIPT = '/home/vmarek/watcher.pl'; my $SCRIPT = '/Users/jetpac/bin/watcher.pl';
my $LINES = 20; my $LINES = 20;
my $COOLDOWN = $ENV{WATCHER_COOLDOWN} || 60; my $COOLDOWN = $ENV{WATCHER_COOLDOWN} || 60;
my $LOG_FILE = $ENV{WATCHER_LOG} || ''; my $LOG_FILE = $ENV{WATCHER_LOG} || '';
@@ -259,11 +259,9 @@ sub rendered_last_lines {
sub start_pipe { sub start_pipe {
my ($sock, $pane, $event_path) = @_; my ($sock, $pane, $event_path) = @_;
my $cmd = shell_quote($^X) . ' ' . my $cmd = join ' ',
shell_quote($SCRIPT) . ' --watcher ' . map { tmux_pipe_shell_quote($_) }
shell_quote($sock) . ' ' . ($^X, $SCRIPT, '--watcher', $sock, $pane, $event_path);
shell_quote($pane) . ' ' .
shell_quote($event_path);
return run_quiet( return run_quiet(
'tmux', '-S', $sock, 'tmux', '-S', $sock,
@@ -372,6 +370,13 @@ sub shell_quote {
return "'$s'"; return "'$s'";
} }
sub tmux_pipe_shell_quote {
my ($s) = @_;
# pipe-pane expands percent escapes in the shell command before execution.
$s =~ s/%/%%/g;
return shell_quote($s);
}
sub log_msg { sub log_msg {
my ($msg) = @_; my ($msg) = @_;
my $ts = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()); my $ts = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime());