#!/bin/bash # Remap USB Tab Button to F20 (for PTT use with Superwhisper, Discord, etc.) # Works with generic USB tab key (VendorID: 0x8808, ProductID: 0x6600) VID="0x8808" PID="0x6600" PLIST="$HOME/Library/LaunchAgents/com.user.usb-button-remap.plist" # Check if device is connected if ! hidutil list | grep -q "0x8808.*0x6600"; then echo "ERROR: USB button not detected. Plug it in and try again." exit 1 fi echo "Found USB button (VID: $VID, PID: $PID)" # Apply remap now hidutil property \ --matching "{\"VendorID\":$VID,\"ProductID\":$PID}" \ --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x70000002B,"HIDKeyboardModifierMappingDst":0x70000006F}]}' \ > /dev/null echo "Remapped Tab -> F20 on USB button" # Create Launch Agent so it persists across reboots cat > "$PLIST" << 'EOF' Label com.user.usb-button-remap ProgramArguments /usr/bin/hidutil property --matching {"VendorID":0x8808,"ProductID":0x6600} --set {"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x70000002B,"HIDKeyboardModifierMappingDst":0x70000006F}]} RunAtLoad EOF launchctl unload "$PLIST" 2>/dev/null launchctl load "$PLIST" echo "Launch Agent installed -- remap will persist across reboots." echo "" echo "Done! Now set your PTT keybind to F20 in your app."