This is not exactly what you describe but it may meet your requirements:
http://plugin.org.uk/timemachine/
It's a GUI program, but the GUI is just one big button, which may or may
not have a keyboard binding.
The program has an auto-record feature based on the signal level. here's
the command line help:
Usage timemachine: [-h] [-i] [-c channels] [-n jack-name]
[-t buffer-length] [-p file prefix] [-f format]
[-a] [-b begin-threshold] [-e end-threshold] [-T end-time]
[port-name ...]
-h show this help
-i interactive mode (console instead of X11) also enabled
if DISPLAY is unset
-c specify number of recording channels
-n specify the JACK name timemachine will use
-t specify the pre-recording buffer length
-p specify the saved file prefix, may include path
-s use safer characters in filename (windows compatibility)
-f specify the saved file format
-a enable automatic sound-triggered recording
-b specify threshold above which automatic recording will begin
-e specify threshold below which automatic recording will end
-T specify silence length before automatic recording ends
HTH, Chris