Skip to content

About

Minimal macOS global hotkey cursor hider

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cursor-hider

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.

Requirements

  • macOS
  • Xcode Command Line Tools

Install the command line tools if needed:

xcode-select --install

Install

Clone or copy this repo, then run:

cd cursor-hider
./scripts/install.sh

This 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.

Uninstall

cd cursor-hider
./scripts/uninstall.sh

Build Without Installing

make

The local binary will be created at:

./hide-cursor-optshiftk

Change The Shortcut

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
shiftKey

Useful letter key codes:

kVK_ANSI_A
kVK_ANSI_B
kVK_ANSI_C
...
kVK_ANSI_Z

After editing, reinstall:

./scripts/install.sh

Status

Check whether the LaunchAgent is running:

launchctl print gui/$(id -u)/com.vivanvv.cursor-hider

Check the running process:

pgrep -fl hide-cursor-optshiftk

Methodology

The 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.

Tradeoffs

This uses private macOS APIs:

  • CGSMainConnectionID
  • CGSSetConnectionProperty
  • SLCursorIsVisible
  • SLSHideCursor / CGSHideCursor
  • SLSShowCursor / CGSShowCursor
  • SLSSetCursorScale / CGSSetCursorScale
  • SetsCursorInBackground

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.

Troubleshooting

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

References

About

Minimal macOS global hotkey cursor hider

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages