mathiasbynens / dotfiles

:wrench: .files, including ~/.macos — sensible hacker defaults for macOS
https://mths.be/dotfiles
MIT License
30.2k stars 8.74k forks source link

kDim not working on mavericks #327

Open benoitgrelard opened 10 years ago

benoitgrelard commented 10 years ago
# Automatically illuminate built-in MacBook keyboard in low light
defaults write com.apple.BezelServices kDim -bool true

# Turn off keyboard illumination when computer is not used for 5 minutes
defaults write com.apple.BezelServices kDimTime -int 300

This doesn't seem to work on Mavericks. I've tried to modify the setting manually and do a diff in defaults read and there are no changes, so I'm guessing the change is somewhere else.

Anybody?

alrra commented 10 years ago

This doesn't seem to work on Mavericks.

+1

mathiasbynens commented 10 years ago

Thanks.

jfelchner commented 10 years ago

Hey all, I don't have time to submit a pull request but this is now being stored in /Library/Preferences/com.apple.iokit.AmbientLightSensor.plist as far as I can tell.

mathiasbynens commented 10 years ago

Seems legit:

$ defaults read /Library/Preferences/com.apple.iokit.AmbientLightSensor.plist
{
    "Automatic Keyboard Enabled" = 1;
    "Backlight 1" = "0.1751009";
    "Backlight 2" = "1.428571";
    "Keyboard Dim Time" = "-1";
    "Keyboard Manual Brightness" = 1;
    "Keyboard Muted" = 1;
    "Keyboard User Offset" = "-0.162";
    "Lux 1" = 0;
    "Lux 2" = 765;
    "Lux Threshold" = "106.8651";
    "LuxSensor 1" = 14;
    "LuxSensor 2" = 765;
}
OliverJAsh commented 6 years ago

This seems to have moved again in High Sierra. It no longer seems to be reflected in /Library/Preferences/com.apple.iokit.AmbientLightSensor.plist.

chdiza commented 6 years ago

This seems to have moved again in High Sierra. It no longer seems to be reflected in /Library/Preferences/com.apple.iokit.AmbientLightSensor.plist.

Hmm, modifying that file worked for me on High Sierra.

chdiza commented 6 years ago

@OliverJAsh You're right, I can now reproduce in High Sierra. I don't know where that stuff has moved to.

thegranddesign commented 6 years ago

This is now stored in:

/private/var/db/hidd/Library/Preferences/ByHost/com.apple.iokit.AmbientLightSensor.<host_uuid>.plist

Where host_uuid is your machine's unique identifier.

While changing the checkbox in the Display preferences changes this file, manually changing this file and restarting appears to have no effect. I'm curious how Apple has changed how the defaults mechanisms work in High Sierra.

If you want to contribute multiple defaults write solutions in one location, you can check out my fork of m-cli here.

thegranddesign commented 6 years ago

This will be added to m-cli soon, but just for reference, the AppleScript version of this is:

tell application "System Preferences"
  close
  activate

  set current pane to pane "com.apple.preference.displays"
end tell

tell application "System Events"
  tell application process "System Preferences"
    repeat with theWindow in windows
      tell theWindow
        click

        tell tab group 1
          click radio button "Display"

          set theCheckbox to checkbox "Automatically adjust brightness" of group 1

          tell theCheckbox
            set checkboxStatus to value of theCheckbox as boolean

            if checkboxStatus is true then click theCheckbox
          end tell
        end tell
      end tell
    end
  end tell
end tell

With m-cli you'll be able to do m display autobrightness NO as normal and it'll run the AppleScript for you behind the scenes.