Skip to content

Instantly share code, notes, and snippets.

@carlashley
Last active November 14, 2016 10:46
Show Gist options
  • Save carlashley/58472dd02c0a0bd192fb48fd079a5f6f to your computer and use it in GitHub Desktop.
Save carlashley/58472dd02c0a0bd192fb48fd079a5f6f to your computer and use it in GitHub Desktop.
Power adaptor info
#!/usr/bin/python
# A dictionary of information about connected AC adaptor for Mac laptops
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'power', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/IOKit/PowerAdapter')
# Returns nothing if no adaptor connected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment