Noisy PuTTY Patch

From Schmid.wiki
Jump to: navigation, search

Contents

Information

This hack makes PuTTY play a sound each time text is output to the terminal. Needless to say, that can be really annoying if the sound is loud. Select a low amplitude sound and you get a nice retro-terminal feel and sound feedback, enabling you to leave the computer alone and still be alerted when anything happens.

Please note that:

  • The cursor blinking also is done by do_text_internal, so you might want to disable cursor blinking.
  • The sound sample is fixed to "c:\samples\beep.wav", you might want to change that.
  • If the sample is missing, neither sound nor an error is produced.

Patch

Change putty-src\WINDOWS\WINDOW.C:

void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
		      unsigned long attr, int lattr)
{
    // ...

    // <Noisy PuTTY Patch>
    static long lastbeep = 0;
    long beepdiff;

    beepdiff = GetTickCount() - lastbeep;
    if (!(beepdiff >= 0 && beepdiff < 7)) {
        PlaySound("c:\\samples\\beep.wav", NULL,
                SND_NOWAIT | SND_ASYNC | SND_FILENAME);
        /*
         * The above MessageBeep call takes time, so we record the
         * time _after_ it finishes rather than before it starts.
         */
        lastbeep = GetTickCount();
    }
    // </Noisy PuTTY Patch>
}

Download Beep

You can download an example beep.wav from this location.

References

Personal tools