package Sound; use warnings; use Milkbone; eval "use Win32::Sound" if $^O =~ /Win32/; register_hook("signed_in", sub { play_sound("signed_in"); }); register_hook("protocol_go_away", sub { play_sound("go_away"); }); register_hook("protocol_return", sub { play_sound("return"); }); register_hook("msg_in", sub { play_sound("msg_in"); }); register_hook("protocol_send_im", sub { play_sound("send_im"); }); register_hook("buddy_in", sub { play_sound("buddy_in"); }); register_hook("buddy_out", sub { play_sound("buddy_out"); }); register_hook("error", sub { play_sound("error"); }); register_hook("protocol_signoff", sub { play_sound("signoff"); }); sub play_sound { return if hook("protocol_away_status") and !option("SoundsWhileAway") and $_[0] ne "go_away"; my ($name) = @_; my $path = "sounds/$name.wav"; return unless -e $path; if($^O =~ m/Win32/) { Win32::Sound::Play($path, 0x0001 | 0x0010); } else { exec 'play', $path unless fork(); } }