diff options
author | terminaldweller <devi@terminaldweller.com> | 2023-07-16 09:05:55 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2023-07-16 09:05:55 +0000 |
commit | 913c3ada47759757f1b4b49c0616891d0f88a704 (patch) | |
tree | 4c2ea8c1ad4e72fa3d2432ea77e65fd459b7f9cf | |
parent | update (diff) | |
download | irssi-scripts-913c3ada47759757f1b4b49c0616891d0f88a704.tar.gz irssi-scripts-913c3ada47759757f1b4b49c0616891d0f88a704.zip |
update
Diffstat (limited to '')
-rw-r--r-- | holes/holes.pl | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/holes/holes.pl b/holes/holes.pl new file mode 100644 index 0000000..9d77ac3 --- /dev/null +++ b/holes/holes.pl @@ -0,0 +1,40 @@ +use Irssi; +use strict; + +Irssi::settings_add_int('misc', 'holes_frequency', 30000); +Irssi::settings_add_str('misc', 'holes_separator', ""); +my $holes = ''; +my $timeout; +my $holes_cmd = << 'HOLES_CMD'; +lsof | grep socket | awk '{print $4}' | awk 'BEGIN{FS=":"}{print $2}' | tr -d [] | uniq +HOLES_CMD + +sub uniq { + my %seen; + grep !$seen{$_}++, @_; +} + +sub holes_sub { + my $result; + Irssi::timeout_remove($timeout); + my $output = `$holes_cmd`; + my $sep = Irssi::settings_get_str('holes_separator'); + my @lines = split /\n/, $output; + my @lines = uniq(@lines); + $holes = ''; + foreach my $line (@lines) { + if ($result == "") { + $result = $line + } + $result = $result.$sep.$line + } + $holes= $result; + $timeout = Irssi::timeout_add_once(Irssi::settings_get_int('holes_frequency'), 'holes_sub' , undef); +} + +Irssi::expando_create('holes', sub { + return $holes; +}, {}); + +$timeout = Irssi::timeout_add(Irssi::settings_get_int('holes_frequency'), 'holes_sub' , undef); +holes_sub(); |