A minimal macOS background utility that toggles the system mouse cursor with a global hotkey.
Default shortcut:
Option + Shift + K
The installed process is a tiny native C binary. It has no menu bar item, no polling loop, no Swift runtime, and no external dependencies beyond Apple's command line tools.
- macOS
- Xcode Command Line Tools
Install the command line tools if needed:
xcode-select --installClone or copy this repo, then run:
cd cursor-hider
./scripts/install.shThis compiles the binary to:
~/.local/bin/hide-cursor-optshiftk
and installs a LaunchAgent at:
~/Library/LaunchAgents/com.vivanvv.cursor-hider.plist
The LaunchAgent starts the utility immediately and again at login.
cd cursor-hider
./scripts/uninstall.shmakeThe local binary will be created at:
./hide-cursor-optshiftk
Edit the constants near the top of src/hide-cursor-optshiftk.c:
#define HOTKEY_KEY_CODE kVK_ANSI_K
#define HOTKEY_MODIFIERS (optionKey | shiftKey)
#define HOTKEY_NAME "Option+Shift+K"Examples:
// Control + Option + K
#define HOTKEY_KEY_CODE kVK_ANSI_K
#define HOTKEY_MODIFIERS (controlKey | optionKey)
#define HOTKEY_NAME "Control+Option+K"
// Command + Shift + H
#define HOTKEY_KEY_CODE kVK_ANSI_H
#define HOTKEY_MODIFIERS (cmdKey | shiftKey)
#define HOTKEY_NAME "Command+Shift+H"Useful modifier names:
cmdKey
controlKey
optionKey
shiftKeyUseful letter key codes:
kVK_ANSI_A
kVK_ANSI_B
kVK_ANSI_C
...
kVK_ANSI_ZAfter editing, reinstall:
./scripts/install.shCheck whether the LaunchAgent is running:
launchctl print gui/$(id -u)/com.vivanvv.cursor-hiderCheck the running process:
pgrep -fl hide-cursor-optshiftkThe goal is the smallest practical global cursor toggle on macOS.
The program uses RegisterEventHotKey from Carbon to register the global keyboard shortcut. This avoids event taps, accessibility permissions, polling, and third-party automation tools.
For cursor visibility, it calls CGDisplayHideCursor and CGDisplayShowCursor. Apple's public cursor API is mostly foreground-app oriented, so a plain background process can be brittle. To make background hiding work more reliably, the utility sets the WindowServer connection property SetsCursorInBackground, the same family of private workaround historically used by Cursorcerer-style utilities.
For the cursor image itself, the utility also applies SkyLight connection-level hide/show and sets the rendered cursor scale to 0.001 while hidden, restoring it to 1.0 when shown. This covers cases where macOS accepts the display hide request but leaves a stale cursor image frozen on screen.
To avoid toggle drift, the utility tries to read the actual cursor visibility state via SkyLight's private SLCursorIsVisible symbol. If that symbol is unavailable, it falls back to its own local state.
The process then blocks in the system application event loop. It does not poll the cursor, monitor mouse movement, inspect windows, or repeatedly re-hide the pointer.
This uses private macOS APIs:
CGSMainConnectionIDCGSSetConnectionPropertySLCursorIsVisibleSLSHideCursor/CGSHideCursorSLSShowCursor/CGSShowCursorSLSSetCursorScale/CGSSetCursorScaleSetsCursorInBackground
That is what makes background cursor control practical, but it also means Apple can change behavior in future macOS releases.
This is intentionally not a game-specific cursor fixer. Some games, fullscreen transitions, resolution switches, Dock/menu-bar hot zones, or display reconfigurations can force the cursor visible again. Handling those cases generally requires heavier heuristics or polling, which this project avoids.
If the shortcut does nothing, another app may already own the same shortcut. Change the key constants and reinstall.
If the cursor hides once and later reappears, macOS or the foreground app may have forced it visible. Press the shortcut again.
If the process is not running, reinstall:
./scripts/install.sh- Apple
CGDisplayHideCursor: https://developer.apple.com/documentation/coregraphics/cgdisplayhidecursor%28_%3A%29 - Cursorcerer: https://doomlaser.com/cursorcerer
- Background cursor hiding discussion: https://stackoverflow.com/questions/3885896/globally-hiding-cursor-from-background-app