Latest 0.0.2
Homepage https://github.com/maxmouchet/LightKit
License BSD
Platforms osx 10.9
Authors

License
CocoaPods compatible
Carthage compatible

Access the ambient light sensors, and control MacBook’s display & keyboard brightness in Swift.

LightKit

Warning: While it should be safe to play with the backlight, I am not responsible for any damages made to a computer using this code.

Installation

# Podfile
pod "LightKit"

# Cartfile
github "maxmouchet/LightKit"

Usage

import LightKit
let lk = LightKit()! // May be nil if it failed to open I/Os.

Note : Most methods and properties are returning optional as I/Os requests may fail if sensors and controllers could not be found.

Ambient light sensors

let lightSensorsReadings = lk.lightSensors
print("Left sensor: (lightSensorsReadings?.left).")
print("Right sensor: (lightSensorsReadings?.right).")

Display

print("Display brightness is (lk.displayBrightness)")
lk.setDisplayBrightness(0.8) // A value between 0 and 1.
lk.setDisplayPower(false) // Put display to sleep
lk.setDisplayPower(true) // Wake up display

Keyboard

print("Keyboard brightness is (lk.keyboardBrightness)")
lk.setKeyboardBrightness(0.8) // A value between 0 and 1.

Latest podspec

{
    "name": "LightKit",
    "version": "0.0.2",
    "summary": "MacBook Light Sensor and Display/Keyboard brightness control",
    "homepage": "https://github.com/maxmouchet/LightKit",
    "license": "BSD",
    "description": "Ambient Light Sensor, Display, and Keyboard brightness control in Swift.",
    "authors": {
        "Maxime Mouchet": "[email protected]"
    },
    "social_media_url": "http://twitter.com/maxmouchet",
    "platforms": {
        "osx": "10.9"
    },
    "source": {
        "git": "https://github.com/maxmouchet/LightKit.git",
        "tag": "0.0.2"
    },
    "source_files": [
        "LightKit",
        "LightKit/**/*.{h,m}"
    ],
    "exclude_files": "LightKit/Exclude",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This