📜 ⬆️ ⬇️

We screw the hilight notification in irssi via notify-osd

Due to the presence of Perl-scripting support in Irssi, it is possible in a very simple way, without using any additional modules or anything else, to implement the rather convenient function of notifying private messages and highlights via notify-osd, using the script provided here. Of course, you can use anything instead of notify-osd according to your desire, and then it will be just a small example of how to improve such an IRC client, which seems at first glance a poor IRC client.


 #! / usr / bin / perl -w -C

 use strict;
 use Irssi;
 use Irssi :: Irc;

 sub sig_public 
 {
         my @host;
         my ($ server, $ msg, $ nick, $ address, $ target) = @_;
         my $ mynick = $ server -> {nick};
         chomp $ mynick;
         if ($ msg = ~ m /. * mynick. * /)
         {
                 # Replacing various special characters with more understandable for notify-osd
                 $ msg = ~ s / </ & lt; /;
                 $ msg = ~ s /> / & gt; /;
                 $ msg = ~ s / '/ `/ g;
                 system ("/ usr / bin / notify-send 'Irssi: $ nick [$ target]' '$ msg'");

         }
 }

 sub sig_private 
 {
         my ($ server, $ msg, $ nick, $ address) = @_;
         system ("/ usr / bin / notify-send 'Irssi: $ nick [private]' '$ msg'");
 }

 Irssi :: signal_add_last ('message public', 'sig_public');
 Irssi :: signal_add_last ('message private', 'sig_private');


Of course, this only works if the client is running locally on your machine, and not in a screen on a remote server.
')
PS Found and fixed a bug with double notification about the highlight on the channel.

Source: https://habr.com/ru/post/90449/


All Articles