Skip to content

Instantly share code, notes, and snippets.

View carlashley's full-sized avatar

Carl carlashley

View GitHub Profile
@carlashley
carlashley / power_adaptor.py
Last active November 14, 2016 10:46
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.
@carlashley
carlashley / current_power.py
Last active April 3, 2017 06:25
Current power settings
#!/usr/bin/python
# A dictionary of current power settings from various system configurations
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'power', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/IOKit/PowerManagement/CurrentSettings')
@carlashley
carlashley / system_load.py
Last active November 14, 2016 10:48
Detailed system load
#!/usr/bin/python
# A dictionary of system load information.
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'power', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/IOKit/PowerManagement/SystemLoad/Detailed')
@carlashley
carlashley / cpu_power.py
Last active August 25, 2021 05:05
CPU Power
#!/usr/bin/python
# A dictionary of available CPU's, COU scheduler limit, and CPU speed limit
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'power', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/IOKit/Power/CPUPower') # returns nothing on Apple Silicon
@carlashley
carlashley / smb.py
Last active November 14, 2016 10:50
Apple SMB
#!/usr/bin/python
# A dictionary of SMB server configuration settings
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'smb', None, None)
result = SCDynamicStoreCopyValue(ds, 'com.apple.smb')
@carlashley
carlashley / mdns_debug_state.py
Last active November 14, 2016 10:51
mDSN Debug states
#!/usr/bin/python
# A dictionary detailing what logging is configured for mDNS debugging
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'mDNS', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/Network/mDNSResponder/DebugState')
@carlashley
carlashley / global_proxy.py
Last active November 14, 2016 10:52
Global proxies
#!/usr/bin/python
# A dictionary of detailed proxy information as seen in the Network system preference pane.
from SystemConfiguration import (
SCDynamicStoreCreate,
SCDynamicStoreCopyValue,
)
ds = SCDynamicStoreCreate(None, 'global_proxies', None, None)
result = SCDynamicStoreCopyValue(ds, 'State:/Network/Global/Proxies')
@carlashley
carlashley / list_users.sh
Created November 25, 2016 10:47
List all local users and exclude system accounts and dump out as CSV
#!/bin/sh
# This will also work with /Search/Users instead of /Local/Users
/usr/bin/dscl localhost -list /Local/Users UniqueID | awk '$2 >= 100 { print $1 "," }' | grep -v "^_" > users.csv
@carlashley
carlashley / fix_promethean.sh
Created November 27, 2016 23:30
Fix issues with Promethean drivers & ActivInspire not running properly in Mac OS X El Capitan and macOS Sierra
#!/bin/sh
/bin/chmod -R 755 /usr/local/share/promethean
/bin/chmod -R 644 /Library/LaunchAgents/com.promethean.*
/bin/chmod -R 755 /usr/local/lib
@carlashley
carlashley / hardware.py
Created December 21, 2016 03:39
Mac Hardware Info
#!/usr/bin/python
# Use system_profiler output in XML to get information about Mac hardware
import plistlib
import subprocess
cmd = ['system_profiler', '-xml', 'SPHardwareDataType']
(results, error) = subprocess.Popen(cmd,