It's really no problem at all -- simply buy a standard PS/2-type KVM switch and add in a circuit for the speakers. You only need to switch two wires -- the right and left channel leads; the common can be left connected to both system units at all times.
Here's what you'll need:
-- 1/8" mini-stereo jacks panel-mount style (3 needed)
-- 1/8" mini-stereo male to 1/8" mini-stereo male patch cords (2 needed)
-- 1N4002 diode (1 needed)
-- 5VDC mini PCB relay (1 needed -- see below)
-- hook-up wire
Mount the three 1/8" mini-stereo jacks to the switch housing. One of these will be used as the "out" to the speakers; the other two will be for the "in" lines from the two system units. wire the common (shell or ring) terminals of the three jacks to each other. Wires from the remaining two terminals of each jack will go to the relay as described below.
Switching can be accomplished fairly easily using a 5V DPDT miniature relay such as the G5A-234P-DC5 (sealed) or G5A-237P-DC5 (vented) from
**broken link removed**. Both are stocked by Mouser. This relay has a 125-ohm coil, drawing about 40mA for operation, and is designed to switch very low signal levels.
Each set of relay contacts will have a C (Common), NC (Normally Closed) and NO (Normally Open) terminal. For each set of contacts, the C terminal will go to the speaker, the NO terminal will go to the appropriate channel of the less-used system unit, and the NC terminal will go to the appropriate channel of the more frequently used system unit.
The relay coil will get connected to Pins 4 (+5VDC) and 3 (GND) of the PS/2 Keyboard port for the less-used system unit, and a 1N4002 diode should be placed across the relay coil, with the cathode to the +5VDC side. The diode is there for anti-spike protection, intended to shunt current induced by the collapse of the relay coil's magnetic field. This is necessary, so don't leave it out! The relay can be mounted to a convenient location inside the switch unit housing using double-sided mounting tape or hot glue.
What this circuit does is provide relay switching of both audio channel signal lines from the two system units simultaneously. When the KVM switch is set to the position of the more frequently used PC, the audio signals flow through the NC & C terminals of the relay, thus going from the input jack for that PC to the output jack. When the KVM switch is then set to the less-frequently used PC, the relay coil is energized by the +5VDC now being available at Pin 4 of the PS/2 keyboard port for that unit, causing the relay contacts to shift from the NC-C pairing to the NO-C pairing, and allowing the audio signals to be routed from the opposite input jack to the output jack.
I have built many of these for customers, and they work very well. If you need further information how to wire this, post back...