osascript-sysinfo
System state queries via pmset, NSProcessInfo ObjC bridge, System Events, and defaults.
All scripts are pure Python — mix of subprocess shell and JXA ObjC bridge.
Scripts
Battery percentage, charging state, and time remaining (MacBook only):
uv run scripts/battery.py
OS version, hostname, CPU count, RAM, username — via NSProcessInfo ObjC bridge:
uv run scripts/system-info.py
List, add, or remove apps that launch at login via System Events:
uv run scripts/login-items.py --list
uv run scripts/login-items.py --add /Applications/Spotify.app
uv run scripts/login-items.py --remove Spotify
Read macOS user defaults by domain and optional key — --export for full domain JSON:
uv run scripts/user-defaults.py com.apple.dock
uv run scripts/user-defaults.py com.apple.finder AppleShowAllFiles
uv run scripts/user-defaults.py NSGlobalDomain --export
uv run scripts/user-defaults.py --list-domains
Key Tools / APIs
| Tool | Use case |
|---|---|
pmset -g batt |
Battery percentage, state, time remaining |
NSProcessInfo (JXA ObjC) |
OS version string, hostname, CPU count, RAM |
| System Events login items | Add/remove startup apps |
defaults + plutil CLI |
Read/write NSUserDefaults (Dock, Finder, any app) |
Useful defaults Domains
com.apple.dock— Dock position, tile size, autohidecom.apple.finder— Finder view, hidden files (AppleShowAllFiles)NSGlobalDomain— Dark mode (AppleInterfaceStyle), key repeat, scroll direction
Reference
- reference/03-jxa-objc-bridge.md — NSProcessInfo, NSUserName, NSHomeDirectory, ObjC.unwrap() rule
- reference/05-system-events.md — Login items, current user via System Events