Last active
January 2, 2026 17:21
-
-
Save robotsquidward/f147b57d404cdc3c885224aa94d0f695 to your computer and use it in GitHub Desktop.
Remap HHKB Pro Eject key to Media Play/Pause setup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script to remap HHKB Pro Eject key to Media Play/Pause and set it up to run on startup | |
| set -e | |
| echo "Setting up HHKB Eject key → Media Play/Pause remap..." | |
| # Apply the key remapping immediately | |
| echo "→ Applying key remap..." | |
| hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0xC000000B8,"HIDKeyboardModifierMappingDst":0xC000000CD}]}' | |
| # Create LaunchAgents directory if it doesn't exist | |
| LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents" | |
| echo "→ Creating LaunchAgents directory if needed..." | |
| mkdir -p "$LAUNCH_AGENTS_DIR" | |
| # Create the LaunchAgent plist file | |
| PLIST_FILE="$LAUNCH_AGENTS_DIR/com.nanoant.KeyRemapping.plist" | |
| echo "→ Creating LaunchAgent plist at $PLIST_FILE..." | |
| cat > "$PLIST_FILE" << 'EOF' | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>com.nanoant.KeyRemapping</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/usr/bin/hidutil</string> | |
| <string>property</string> | |
| <string>--set</string> | |
| <string>{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0xC000000B8,"HIDKeyboardModifierMappingDst":0xC000000CD}]}</string> | |
| </array> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| </dict> | |
| </plist> | |
| EOF | |
| # Validate the plist file | |
| echo "→ Validating plist file..." | |
| plutil "$PLIST_FILE" | |
| # Load the LaunchAgent | |
| echo "→ Loading LaunchAgent..." | |
| launchctl unload "$PLIST_FILE" 2>/dev/null || true | |
| launchctl load "$PLIST_FILE" | |
| echo "✓ Setup complete! The Eject key is now remapped and will persist across reboots." |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See original setup gist: https://gist.github.com/vadikgo/0ec180f8aa3324911c1daea305b92ece