Advertisement
joachip

beep script for irssi

Mar 12th, 2011
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.58 KB | None | 0 0
  1. #!/usr/bin/irssi
  2. #
  3. # irssi beep with-command-script
  4. # (C) 2003 Remco den Breeje
  5. # inspired by Georg Lukas
  6.  
  7. # howtoinstall:
  8. #  copy this file to ~/.irssi/script/
  9. #  in irssi:
  10. #   $/script load my_beep.pl
  11. #  change the settings
  12. #   $/set beep_msg_level HILIGHT
  13. #   $/set beep_cmd beep
  14. #  consult the file /etc/devfs.conf to give yourself permissions to the beep device
  15.  
  16.  
  17. $VERSION = "0.9";
  18. %IRSSI = (
  19.     authors => "Remco den Breeje",
  20.     contact => "stacium or stek (most of the time) @ quakenet.org",
  21.     name    => "my_beep",
  22.     description => "runs arbitrary command instead of system beep, includes flood protection",
  23.     license => "Public Domain",
  24.     url     => "http://www.xs4all.nl/~stacium/irssi/my_beep.html",
  25. );
  26.  
  27. use Irssi;
  28.  
  29. my $can_I_beep = 1;
  30.  
  31. sub beep_overflow_timeout()
  32. {
  33.     $can_I_beep = 1;
  34.     # and kill the loop
  35.     Irssi::timeout_remove($timeout_tag);
  36.     $autoaway_to_tag = undef;
  37. }
  38.  
  39. sub my_beep()
  40. {
  41.     my $beep_cmd = Irssi::settings_get_str("beep_cmd");
  42.     if ($beep_cmd)
  43.     {
  44.         my $beep_flood = Irssi::settings_get_int('beep_flood');
  45.         # check on given beep_flood
  46.         if($beep_flood < 0)
  47.         {
  48.             Irssi::print("Warning! Wrong value for beep_flood (time in milisecs)");
  49.             Irssi::signal_stop();
  50.             return;
  51.         }
  52.  
  53.         if ($can_I_beep)
  54.         {
  55.             $timeout_tag = Irssi::timeout_add($beep_flood, 'beep_overflow_timeout', undef);
  56.             system($beep_cmd);
  57.             $can_I_beep = 0;
  58.         }
  59.         Irssi::signal_stop();
  60.     }
  61. }
  62.  
  63. Irssi::settings_add_str("lookandfeel", "beep_cmd", "echo l30g > /dev/speaker");
  64. Irssi::settings_add_int("lookandfeel", "beep_flood", 20000);
  65. Irssi::signal_add("beep", "my_beep");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement