Skip to content

Instantly share code, notes, and snippets.

@samhenrigold
Created September 6, 2025 23:21
Show Gist options
  • Select an option

  • Save samhenrigold/42b5a92d1ee8aaf2b840be34bff28591 to your computer and use it in GitHub Desktop.

Select an option

Save samhenrigold/42b5a92d1ee8aaf2b840be34bff28591 to your computer and use it in GitHub Desktop.
#!/bin/bash
# MacBook Lid Angle Sensor Diagnostic Script
# This script helps identify the lid angle sensor on different MacBook models
echo "=============================================="
echo "MacBook Lid Angle Sensor Diagnostic Tool"
echo "=============================================="
echo ""
# Get system info
echo "System Information:"
echo "- Model: $(system_profiler SPHardwareDataType | grep 'Model Name' | cut -d: -f2 | xargs)"
echo "- Chip: $(system_profiler SPHardwareDataType | grep 'Chip' | cut -d: -f2 | xargs)"
echo "- macOS: $(sw_vers -productVersion)"
echo ""
echo "Step 1: Looking for exact expected sensor..."
echo "Command: hidutil list --matching '{\"VendorID\":0x5ac,\"ProductID\":0x8104,\"PrimaryUsagePage\":32,\"PrimaryUsage\":138}'"
EXACT_MATCH=$(hidutil list --matching '{"VendorID":0x5ac,"ProductID":0x8104,"PrimaryUsagePage":32,"PrimaryUsage":138}')
if [ ! -z "$EXACT_MATCH" ]; then
echo "βœ… FOUND EXACT MATCH:"
echo "$EXACT_MATCH"
echo ""
echo "Your sensor should work!"
exit 0
else
echo "❌ Exact match not found. Continuing diagnostics..."
fi
echo ""
echo "Step 2: Looking for any Apple sensors..."
echo "Command: hidutil list --matching '{\"VendorID\":0x5ac,\"PrimaryUsagePage\":32}'"
APPLE_SENSORS=$(hidutil list --matching '{"VendorID":0x5ac,"PrimaryUsagePage":32}')
if [ ! -z "$APPLE_SENSORS" ]; then
echo "πŸ“± Found Apple sensor devices:"
echo "$APPLE_SENSORS"
echo ""
else
echo "❌ No Apple sensors found with UsagePage 32"
fi
echo ""
echo "Step 3: Looking for orientation sensors with any ProductID..."
echo "Command: hidutil list --matching '{\"VendorID\":0x5ac,\"PrimaryUsagePage\":32,\"PrimaryUsage\":138}'"
ORIENTATION_SENSORS=$(hidutil list --matching '{"VendorID":0x5ac,"PrimaryUsagePage":32,"PrimaryUsage":138}')
if [ ! -z "$ORIENTATION_SENSORS" ]; then
echo "🧭 Found orientation sensors:"
echo "$ORIENTATION_SENSORS"
echo ""
else
echo "❌ No orientation sensors found"
fi
echo ""
echo "Step 4: Looking for all Apple 0x8104 devices..."
echo "Command: hidutil list --matching '{\"VendorID\":0x5ac,\"ProductID\":0x8104}'"
APPLE_8104=$(hidutil list --matching '{"VendorID":0x5ac,"ProductID":0x8104}')
if [ ! -z "$APPLE_8104" ]; then
echo "πŸ” Found Apple 0x8104 devices (different usage pages):"
echo "$APPLE_8104"
echo ""
else
echo "❌ No Apple 0x8104 devices found"
fi
echo ""
echo "Step 5: Looking for similar ProductIDs..."
echo "Command: hidutil list --matching '{\"VendorID\":0x5ac}' | grep -E '0x810[0-9A-F]'"
SIMILAR_PRODUCTS=$(hidutil list --matching '{"VendorID":0x5ac}' | grep -E "0x810[0-9A-F]")
if [ ! -z "$SIMILAR_PRODUCTS" ]; then
echo "πŸ” Found similar Apple ProductIDs (0x810X):"
echo "$SIMILAR_PRODUCTS"
echo ""
else
echo "❌ No similar ProductIDs found"
fi
echo ""
echo "Step 6: All Apple HID devices (filtered for potential sensors)..."
echo "Command: hidutil list --matching '{\"VendorID\":0x5ac}' | grep -i -E '(sensor|orientation|32|138)'"
ALL_APPLE_FILTERED=$(hidutil list --matching '{"VendorID":0x5ac}' | grep -i -E "(sensor|orientation|32|138)")
if [ ! -z "$ALL_APPLE_FILTERED" ]; then
echo "πŸ“Š Found potential sensor-related Apple devices:"
echo "$ALL_APPLE_FILTERED"
echo ""
else
echo "❌ No sensor-related Apple devices found"
fi
echo ""
echo "=============================================="
echo "Diagnostic Summary:"
echo "=============================================="
if [ ! -z "$EXACT_MATCH" ]; then
echo "βœ… STATUS: Sensor should work (exact match found)"
elif [ ! -z "$ORIENTATION_SENSORS" ]; then
echo "⚠️ STATUS: Different ProductID - code needs updating"
echo " Found orientation sensor with different ProductID"
elif [ ! -z "$APPLE_SENSORS" ]; then
echo "⚠️ STATUS: Different Usage - code needs updating"
echo " Found Apple sensors but different Usage value"
elif [ ! -z "$APPLE_8104" ]; then
echo "⚠️ STATUS: Different UsagePage - check other usage pages"
echo " Found Apple 0x8104 devices but different usage pages"
else
echo "❌ STATUS: No compatible sensor found"
echo " This MacBook model may not have an accessible lid angle sensor"
fi
echo ""
echo "Please share this entire output for troubleshooting!"
echo "=============================================="
@matsahm
Copy link

matsahm commented Feb 5, 2026

==============================================
MacBook Lid Angle Sensor Diagnostic Tool

System Information:

  • Model: MacBook Pro
  • Chip: Apple M2
  • macOS: 26.2

Step 1: Looking for exact expected sensor...
Command: hidutil list --matching '{"VendorID":0x5ac,"ProductID":0x8104,"PrimaryUsagePage":32,"PrimaryUsage":138}'
❌ Exact match not found. Continuing diagnostics...

Step 2: Looking for any Apple sensors...
Command: hidutil list --matching '{"VendorID":0x5ac,"PrimaryUsagePage":32}'
❌ No Apple sensors found with UsagePage 32

Step 3: Looking for orientation sensors with any ProductID...
Command: hidutil list --matching '{"VendorID":0x5ac,"PrimaryUsagePage":32,"PrimaryUsage":138}'
❌ No orientation sensors found

Step 4: Looking for all Apple 0x8104 devices...
Command: hidutil list --matching '{"VendorID":0x5ac,"ProductID":0x8104}'
πŸ” Found Apple 0x8104 devices (different usage pages):
Services:
VendorID ProductID LocationID UsagePage Usage RegistryID Transport Class Product UserClass Built-In
0x5ac 0x8104 0x0 65280 3 0x100000815 SPU AppleSPUHIDDriver (null) (null) 1
0x5ac 0x8104 0x0 65280 9 0x100000841 SPU AppleSPUHIDDriver (null) (null) 1

Devices:
VendorID ProductID LocationID UsagePage Usage RegistryID Transport Class Product UserClass Built-In
0x5ac 0x8104 0x0 65280 9 0x1000007a0 SPU AppleSPUHIDDevice (null) (null) 1
0x5ac 0x8104 0x0 65280 3 0x1000007c8 SPU AppleSPUHIDDevice (null) (null) 1

Step 5: Looking for similar ProductIDs...
Command: hidutil list --matching '{"VendorID":0x5ac}' | grep -E '0x810[0-9A-F]'
πŸ” Found similar Apple ProductIDs (0x810X):
0x5ac 0x8104 0x0 65280 3 0x100000815 SPU AppleSPUHIDDriver (null) (null) 1
0x5ac 0x8104 0x0 65280 9 0x100000841 SPU AppleSPUHIDDriver (null) (null) 1
0x5ac 0x8104 0x0 65280 3 0x1000007c8 SPU AppleSPUHIDDevice (null) (null) 1
0x5ac 0x8104 0x0 65280 9 0x1000007a0 SPU AppleSPUHIDDevice (null) (null) 1

Step 6: All Apple HID devices (filtered for potential sensors)...
Command: hidutil list --matching '{"VendorID":0x5ac}' | grep -i -E '(sensor|orientation|32|138)'
❌ No sensor-related Apple devices found

==============================================
Diagnostic Summary:

⚠️ STATUS: Different UsagePage - check other usage pages
Found Apple 0x8104 devices but different usage pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment