diff --git a/fnotify.pl b/fnotify.pl index ca96cbb..3d19920 100644 --- a/fnotify.pl +++ b/fnotify.pl @@ -23,7 +23,7 @@ sub notify { my ($title, $message) = @_; system("notify-send", "-i", "irssi", $title, $message); - if (Irssi::settings_get_bool('festival_enabled')) { + if(Irssi::settings_get_bool('festival_enabled')) { my $text_to_speak = "$title, $message"; # Fork the process to prevent Irssi from freezing while festival speaks. @@ -35,14 +35,16 @@ sub notify { # This will offload the entire backgrounding task to the systemd service # manager. - # We need to escape any single quotes in the text.. # Sorry @dacav, tried to use your open() suggestion, but as we can't # daemonise using the fork solution, we have to manually prevent shell injection. - $text_to_speak =~ s/'/'\\''/g; - my $command = "echo '$text_to_speak' | festival --tts --language english --pipe"; + $text_to_speak =~ s/\\/\\\\/g; # Must escape backslashes first + $text_to_speak =~ s/"/\\"/g; # Then escape double-quotes - system("systemd-run", "--user", "--quiet", "--no-ask-password", "/bin/sh", "-c", $command) + my $scheme_command = "$festival_voice(SayText \"$text_to_speak\")"; + $scheme_command =~ s/'/'\\''/g; + my $command = "echo '$scheme_command' | festival"; + system("systemd-run", "--user", "--quiet", "--no-ask-password", "/bin/sh", "-c", $command); } } @@ -51,7 +53,7 @@ sub notify { # Private messages are simple and clean. No theme conflicts. sub private_message_handler { my ($server, $msg, $nick, $address) = @_; - return if ($nick =~ /^(NickServ|ChanServ|MemoServ)$/i); + return if($nick =~ /^(NickServ|ChanServ|MemoServ)$/i); notify("Private Message from $nick", $msg); } @@ -68,7 +70,7 @@ sub print_text_handler { # Check if the level is a highlight and the target matches the one we just saved. # The target check prevents us from misfiring on other window text. - if (($dest->{level} & Irssi::MSGLEVEL_HILIGHT) && ($dest->{target} eq $last_public_target)) { + if(($dest->{level} & Irssi::MSGLEVEL_HILIGHT) && ($dest->{target} eq $last_public_target)) { # Make sure the data from the first signal is actually there. return unless defined $last_public_nick;