Get ambient light sensor value from ioreg

bashcommand linehardware

I'm using the ioreg command line tool to try and read sensor information available on my computer (iMac). Particularly, I'd like to read the current value of the ambient light sensor. So far, I have been able to retrieve some general information regarding the sensor via ioreg -f -b -r -c 'AppleLMUController'. But the value is not there:

+-o AppleLMUController  <class AppleLMUController, id 0x1000002d8, registered, matched, active, busy 0 (0 ms), retain 7>
{
  "IOProbeScore" = 0
  "CFBundleIdentifier" = "com.apple.driver.AppleSMCLMU"
  "IOProviderClass" = "IOService"
  "IOClass" = "AppleLMUController"
  "IOMatchCategory" = "IODefaultMatchCategory"
  "IOCFPlugInTypes" = {"0516B563-B15B-11DA-96EB-0014519758EF"="AppleSMCLMU.kext/Contents/PlugIns/AmbientLightSensorHID.plugin"}
  "IOGeneralInterest" = "IOCommand is not serializable"
  "IONameMatch" = "ACPI0008"
  "IOPowerManagement" = {"MaxPowerState"=1,"CurrentPowerState"=1}
  "HIDServiceSupport" = Yes
  "IONameMatched" = "ACPI0008"
}

I know that there are tools that can use IOKit to access this value using C, ObjC, etc – but I explicitly would like to use a bash one-liner to try and grab the value.

Has anyone been able to successfully do this via the command line and if so, how?

Best Answer

Read the current setting

defaults read com.apple.BezelServices dAuto

Write

defaults write com.apple.BezelServices dAuto -boolean true/false