# Osascript Sysinfo

> Read macOS system state. Use when checking battery percentage and charge state, getting OS version and hardware specs, listing startup login items, or reading macOS user defaults (NSUserDefaults / plist app preferences).

- Skill: `damionrashford/osascript-sysinfo` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx skillmds@latest add damionrashford/osascript-sysinfo`
- Raw SKILL.md: https://api.skillmd.com/api/skills/damionrashford/osascript-sysinfo/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: damionrashford (https://skillmd.com/u/damionrashford)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/damionrashford/osascript-sysinfo

---


# 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):
```bash
uv run scripts/battery.py
```

OS version, hostname, CPU count, RAM, username — via `NSProcessInfo` ObjC bridge:
```bash
uv run scripts/system-info.py
```

List, add, or remove apps that launch at login via System Events:
```bash
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:
```bash
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, autohide
- `com.apple.finder` — Finder view, hidden files (`AppleShowAllFiles`)
- `NSGlobalDomain` — Dark mode (`AppleInterfaceStyle`), key repeat, scroll direction

## Reference

- [reference/03-jxa-objc-bridge.md](reference/03-jxa-objc-bridge.md) — NSProcessInfo, NSUserName, NSHomeDirectory, ObjC.unwrap() rule
- [reference/05-system-events.md](reference/05-system-events.md) — Login items, current user via System Events

