Created
September 6, 2025 23:21
-
-
Save samhenrigold/42b5a92d1ee8aaf2b840be34bff28591 to your computer and use it in GitHub Desktop.
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 | |
# 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 "==============================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
==============================================
MacBook Lid Angle Sensor Diagnostic Tool
System Information:
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}'
β No Apple 0x8104 devices found
Step 5: Looking for similar ProductIDs...
Command: hidutil list --matching '{"VendorID":0x5ac}' | grep -E '0x810[0-9A-F]'
β No similar ProductIDs found
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: No compatible sensor found
This MacBook model may not have an accessible lid angle sensor
Please share this entire output for troubleshooting!