Hi - this has been a big pain for me! I think I have a monkey patch. This script will monitor the logs for a disconnect, and then restart the service. You may have to run it on both machines. The cursor might bounce to the other machine, but at least the input devices will keep working.
- Open a text editor and paste in the code. Save in your home directory as uc_monitor.sh
- Open a terminal and change permissions to allow you to run the script:
- (optional) make sure you own the script: chown $USER uc_monitor.sh
- Set user execute permissions on the script: chmod u+x uc_monitor.sh
- run the script: ./uc_monitor.sh
There are definitely more refined things to do, like run it as a background process etc, but this gets the job done.
#!/bin/bash
echo "Monitoring Universal Control logs for disconnects..."
log stream --info --style compact --predicate 'subsystem == "com.apple.universalcontrol" AND category == "SYNC"' | grep --line-buffered "Device Unavailable" | while read -r line; do
echo "Disconnect detected at $(date): $line"
# Restart Universal Control
echo "Restarting Universal Control..."
killall UniversalControl
# Optional: Add a small delay to ensure stability
sleep 5
echo "Universal Control restarted."
done