A keyboard shortcut for Sidecar which will turn your iPad into a second/extended screen for your Mac.
## What it does
- Installs a tiny toggle script that connects to the first reachable iPad
- Sets up a global hotkey with Hammerspoon
- Tries wired first, then falls back to wireless
- No LaunchAgents, nothing runs at login
## Quick start
Paste this in Terminal
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/raonehere/sidecar-autoconnect/main/install.sh)"During install, macOS will ask you to allow Accessibility for Hammerspoon. Approve it. Then press Command + Option + Control + M to connect. Press the same keys again to disconnect. Press again to reconnect.
- A Mac and an iPad that support Sidecar
- Same Apple ID on both devices
- Bluetooth and Wi Fi on, or a USB C cable
- Internet access during install, the script downloads SidecarLauncher and Hammerspoon for you
-
The installer puts SidecarLauncher at
~/bin/SidecarLauncher -
It creates
~/bin/sidecar_toggle.sh- If a Sidecar session is running, it disconnects
- If not running, it waits for a device, prefers wired, then connects
- It retries a few times and restarts Sidecar agents between attempts
-
It writes
~/.hammerspoon/init.luawith a single hotkey that runs the toggle script
You can remove everything with one command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/raonehere/sidecar-autoconnect/main/uninstall.sh)"This stops old auto connect agents if any, removes the toggle script, and backs up your Hammerspoon config. You can also quit and delete Hammerspoon from Applications if you prefer.
The installer finished but the hotkey does nothing
- Open the Hammerspoon app once. If asked, allow Accessibility in System Settings, Privacy and Security, Accessibility.
- Click the Hammerspoon menu icon and choose Reload Config.
I get Unable to connect, device timed out
-
Unlock the iPad and keep the screen on
-
Use a direct USB C cable and try again
-
Turn Bluetooth off and on on both devices
-
Make sure both devices use the same Apple ID
-
Run this once to clear stale state, then press the hotkey again
pkill -x SidecarDisplayAgent 2>/dev/null pkill -x SidecarRelay 2>/dev/null
I want a different hotkey
Open ~/.hammerspoon/init.lua and change the key.
Example for Ctrl Option Command K
hs.hotkey.bind({"ctrl","alt","cmd"}, "K", function()
hs.task.new("/usr/bin/env", nil, {"bash","-lc","$HOME/bin/sidecar_toggle.sh"}):start()
end)Click the Hammerspoon menu icon, Reload Config.
- The installer downloads SidecarLauncher from the official GitHub release API
- Scripts are plain text, you can read them before running
- No background daemons are installed, no login items are added
- Sidecar control is powered by the community CLI SidecarLauncher by Ocasio J
- Packaging and hotkey toggle by contributors to this repo
MIT
::contentReference[oaicite:0]{index=0}