Skip to content

Instantly share code, notes, and snippets.

@AndrewWCarson
Created March 28, 2019 21:01
Show Gist options
  • Save AndrewWCarson/8b3e46d70580f106d75ba2e4154320af to your computer and use it in GitHub Desktop.
Save AndrewWCarson/8b3e46d70580f106d75ba2e4154320af to your computer and use it in GitHub Desktop.
Uses pyobjc and IOKit to check for the BootDriveIsInternalSolidState value.
#!/usr/bin/python
# Based on some nice gists by Mike Lynn (@pudquick)
import objc
from CoreFoundation import NSBundle
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit')
functions = [("IOServiceGetMatchingService", b"II@"),
("IOServiceMatching", b"@*"),
("IORegistryEntryCreateCFProperty", b"@I@@I"),
]
objc.loadBundleFunctions(IOKit_bundle, globals(), functions)
def is_SSD():
x86Platform = IOServiceGetMatchingService(0, IOServiceMatching("X86PlatformPlugin"))
return IORegistryEntryCreateCFProperty(x86Platform, 'BootDriveIsInternalSolidState'.encode("utf-8"), None, 0)
if __name__ == '__main__':
if is_SSD():
print "true"
else:
print "false"
@AndrewWCarson
Copy link
Author

The "true" & "false" output from the main function is just a convention that works well with boolean Custom Facts in Addigy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment