diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/beep_beep.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-upstream/20231031.tar.xz irssi-scripts-upstream/20231031.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | scripts/beep_beep.pl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/beep_beep.pl b/scripts/beep_beep.pl new file mode 100644 index 0000000..2c139ab --- /dev/null +++ b/scripts/beep_beep.pl @@ -0,0 +1,54 @@ +#!/usr/bin/irssi +# +# irssi beep replace script (tested with irssi v0.8.8.CVS (20030126-1726)) +# (C) 2002-2004 Ge0rG@IRCnet (Georg Lukas <georg@op-co.de>) +# inspired and tested by Macrotron@IRCnet (macrotron@president.eu.org) + +# added beep_flood to irssi settings: beep_cmd will be run not more often +# then every $beep_flood milliseconds + +# fixed memory leak with timeout_add (made irssi waste 80mb and more after a day of IRC) +# added > /dev/null, thx to Luis Oliveira +# fixed timeout handling bug, thx to frizop@charter.net + +use strict; +use vars qw($VERSION %IRSSI); +$VERSION = "0.10"; +%IRSSI = ( + authors => "Georg Lukas", + contact => "georg\@op-co.de", + name => "beep_beep", + description => "runs arbitrary command instead of system beep, includes flood protection", + license => "Public Domain", + url => "http://op-co.de/irssi/", +); + +use Irssi; + +my $might_beep = 1; +my $to_tag; + +sub beep_overflow_timeout() { + $might_beep = 1; + Irssi::timeout_remove($to_tag); +} + +sub beep_beep() { + my $beep_cmd = Irssi::settings_get_str("beep_cmd"); + if ($beep_cmd) { + if ($might_beep) { + my $beep_flood = Irssi::settings_get_int('beep_flood'); + $beep_flood = 1000 if $beep_flood < 0; + Irssi::timeout_remove($to_tag); + $to_tag = Irssi::timeout_add($beep_flood, 'beep_overflow_timeout', undef); + system($beep_cmd); + $might_beep = 0; + } + Irssi::signal_stop(); + } +} + +Irssi::settings_add_str("lookandfeel", "beep_cmd", "play ~/.irssi/scripts/beep_beep.wav > /dev/null &"); +Irssi::settings_add_int("lookandfeel", "beep_flood", 250); +Irssi::signal_add("beep", "beep_beep"); + |