8

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?

2 Answers 2

0

Read the current setting

defaults read com.apple.BezelServices dAuto

Write

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

2
  • 2
    Doesn't work for me: The domain/default pair of (.../com.apple.BezelServices, dAuto) does not exist
    – mbeasley
    Sep 10, 2014 at 12:46
  • com.apple.BezelServices exists but dAuto does not. dAuto being boolean suggests that this setting is to turn automatic light sensing off or on rather than to read the value of the sensor.
    – Freiheit
    Jul 27, 2016 at 13:00
0

You can't get the value of ambient light sensor from ioreg. For that, first you should install the system management controller smc .exec then run it using terminal. After that run this command:

./smc -l 

It shows the list of all sensors which exist on your Mac. After that try to find the key which is ALSL - this key has the actual value of light ambient sensor of every mac.

3
  • 1
    Where do you get smc from?
    – mmmmmm
    Jul 27, 2021 at 19:02
  • github.com/hholtmann/smcFanControl here is the link install it and then go to app content and find smc.exec there
    – Malik Ejay
    Jul 28, 2021 at 20:07
  • Please improve your answer by editing that information into your answer
    – mmmmmm
    Jul 28, 2021 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .