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/my_beep.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-74dedaab1f75de511e9ded8f64dcf9a4c7d2946f.tar.xz irssi-scripts-74dedaab1f75de511e9ded8f64dcf9a4c7d2946f.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/my_beep.pl')
-rw-r--r-- | scripts/my_beep.pl | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/my_beep.pl b/scripts/my_beep.pl new file mode 100644 index 0000000..7723e75 --- /dev/null +++ b/scripts/my_beep.pl @@ -0,0 +1,61 @@ +#!/usr/bin/irssi +# +# irssi beep with-command-script +# (C) 2003 Remco den Breeje +# inspired by Georg Lukas + +# howtoinstall: +# copy this file to ~/.irssi/scripts/ +# in irssi: +# $/script load my_beep.pl +# change the settings +# $/set beep_msg_level HILIGHT +# $/set beep_cmd beep + +use strict; +use vars qw($VERSION %IRSSI); +$VERSION = "0.10"; +%IRSSI = ( + authors => "Remco den Breeje", + contact => "stacium or stek (most of the time) @ quakenet.org", + name => "my_beep", + description => "runs arbitrary command instead of system beep, includes flood protection", + license => "Public Domain", + url => "http://www.xs4all.nl/~stacium/irssi/my_beep.html", +); + +use Irssi; + +my $can_I_beep = 1; +my ($timeout_tag); + +sub beep_overflow_timeout() { + $can_I_beep = 1; +} + +sub my_beep() { + my $beep_cmd = Irssi::settings_get_str("beep_cmd"); + if ($beep_cmd) { + my $beep_flood = Irssi::settings_get_int('beep_flood'); + # check on given beep_flood + if($beep_flood < 0) { + Irssi::print("Warning! Wrong value for beep_flood (time in milisecs)"); + Irssi::signal_stop(); + return; + } + if (defined $timeout_tag) { + Irssi::timeout_remove($timeout_tag); + $timeout_tag= undef; + } + $timeout_tag = Irssi::timeout_add_once($beep_flood, 'beep_overflow_timeout', undef); + if ($can_I_beep) { + $can_I_beep = 0; + system($beep_cmd); + } + Irssi::signal_stop(); + } +} + +Irssi::settings_add_str("lookandfeel", "beep_cmd", "echo INeedToBeSet > /dev/null"); +Irssi::settings_add_int("lookandfeel", "beep_flood", 2000); +Irssi::signal_add("beep", "my_beep"); |