Added an iMac to my desk recently, but really didn't want keyboards and mice everywhere. Remembered I purchased Synergy (https://symless.com/synergy) years ago. Great on Linux and macOS! It's a bit awkward when both are on WiFi though, so at least one wired connection is a good idea.