Life without optical input
You can connect the optical outputs of your two computers to an optical switch, then connect the switch to your speakers.

Since most switches have TOSLINK inputs you might need 3.5mm optical -> TOSLINK cables to connect your computers to the switch.

All of these parts are common and relatively cheap.