--- name: logiswitch description: Install, test, fix or update LogiSwitch, the tool that moves one Logitech keyboard and mouse between a Mac and a Windows PC (screen edge or Easy-Switch, the other device follows) with optional encrypted clipboard sync. Use when someone says LogiSwitch, wants their Logitech keyboard and mouse to switch together between a Mac and a PC, or pastes a LogiSwitch report. --- # LogiSwitch: install, test, fix, update LogiSwitch is a small Swift menu-bar app on the Mac (`LogiSwitch.swift`, built by `install.sh`) and a PowerShell tray app on Windows (`LogiSwitch.ps1`, `LogiSwitchTray.ps1`, installed by `Install.cmd`). It sends Logitech's HID++ 2.0 Change Host command (feature 0x1814) to move Easy-Switch devices, and optionally shares the text clipboard: the Mac listens on TCP 51888, the PC dials out, AES-256-CBC + HMAC-SHA256 with keys from PBKDF2-SHA256 (200,000 rounds) of a 16-character pairing code. Source and a live demo: https://sghadimi.com/tools/logiswitch/ ## Rules - No admin password, unless macOS itself asks to install the Command Line Tools. - No internet, no third-party services. Clipboard sync stays off until the person turns it on, and they accept its warning themselves. - Ask before any macOS permission (Input Monitoring, incoming connections, Local Network). Never click Allow for them. - Keep the behaviour: 50 ms edge hold away from the corners, mice before keyboards, confirm the device left and re-send up to 3 times, the other device follows, nothing follows after a minute idle. ## Install 1. Mac: `bash ~/Downloads/LogiSwitch/install.sh`. It builds with `xcrun swiftc`; if the Command Line Tools are missing it opens Apple's installer and exits with code 3 (not a failure). On Apple silicon the Intel half of the universal build fails to link with some toolchains; the installer falls back to a native build, so `link command failed ... x86_64` is harmless. 2. The person allows LogiSwitch under Privacy & Security > Input Monitoring. The running app only picks it up after a restart: `launchctl kickstart -k gui/$(id -u)/com.logiswitch.agent`, or run install.sh again. 3. Check `"$HOME/Library/Application Support/LogiSwitch/LogiSwitch" --list`. Run from Claude's shell, its "permission: granted" line reflects Claude's own permission, not the app's. The truth is the `Input Monitoring permission:` line in watch.log after a restart. 4. Windows: unzip, double-click Install.cmd. Defaults: Mac on the right of the PC, Mac on channel 2. ## Test with the person (read watch.log after each) - a) cursor against the edge facing the other computer: both devices go. - b) Easy-Switch on the keyboard: the mouse follows. c) channel button on the mouse: the keyboard follows. - Leave about 10 s between tests and bring both devices back first. Nothing at all in the log usually means there was no time, not a bug. To check whether reconnects are seen, run a separate IOHIDManager watcher (vendor 0x046D, usage page 0xFF43) that logs arrivals and removals; never rebuild the app just to add logging. ## Clipboard sync - Mac: icon > Clipboard sync > Share the text clipboard with the PC. The pairing code and address dialogs are modal: until the person clicks OK, nothing listens on 51888 (`lsof -nP -iTCP:51888`). - PC: icon > Clipboard sync > Set the Mac's address, Pairing code (the same code), Share the text clipboard with the Mac. - Before involving the PC, test the Mac alone with a stand-in client that speaks the same protocol on 127.0.0.1 (hello 0x01, text 0x10, payload [count][format 1][4-byte length][UTF-8]). Restore the person's clipboard afterwards. - No "the PC connected" in the Mac's log means the PC never got through: wrong address, other network, or sync off on the PC. "rejected a message" means the codes differ, or a clock is more than 2 minutes off. The Mac's firewall asks once; after that `socketfilterfw --listapps` lists LogiSwitch as allowed. - Text copied while disconnected is sent when the other side connects, if it is still on the clipboard. ## Known traps - The Mac app is ad-hoc signed, so every rebuild is a new app to macOS: Input Monitoring must be removed (minus) and allowed again, then the app restarted. An install that reuses the ready-built `mac-bin/LogiSwitch` of the same version keeps it. Bump `version.txt` only when the Mac code changes. - On macOS, closing a socket from another thread does not wake accept() or recv(): the server thread owns its sockets, polls, and stop() only shuts the client down. Set SO_NOSIGPIPE on accepted sockets. - PowerShell `-eq` / `-ne` ignore case; compare clipboard text with `-ceq` / `-cne`. - The PC installer must keep every key of settings.json (ClipboardSync, PeerHost, PeerPort), or an update silently turns clipboard sync off. - Getting text between the computers while clipboard sync is down: write files into a folder both computers sync (for example OneDrive) or give the person one ready-made file to download. Do not ask them to retype long commands. ## Update - Mac: menu > Update (reinstall from the original folder, or pick a folder), or run install.sh from the new folder. Settings are kept. - PC: Install.cmd from the new folder, or tray menu > Update. Settings and the pairing code are kept. - Logs: Mac `~/Library/Application Support/LogiSwitch/watch.log` (also stderr.log, install.log, Desktop/LogiSwitch-install-log.txt); PC `%LOCALAPPDATA%\LogiSwitch\watch.log`. Problem reports go to the Desktop.