# Magic Device

**Know when it is safe to run the heavy job.**

Whether the device is on mains power, whether the viewer is away and whether the macOS window is fullscreen. One import, no setup, no Runner edits.

## One import. Three signals.

Run the heavy job only when nobody will notice. Magic Device reads mains power, viewer idle and window fullscreen behind one small API.

### Mains power

`charging` is true on mains power, read through `battery_plus`. A platform without an implementation answers `false`.

[Learn more about Mains power](https://anilcancakir.com/magic_device/docs/basics/device-power.md)

### Viewer idle

macOS and Windows read the system input clock and report away after two minutes without input. Everywhere else it follows the app lifecycle.

[Learn more about Viewer idle](https://anilcancakir.com/magic_device/docs/basics/device-power.md)

### Window fullscreen

Follow the macOS window as it changes and flip it with one `toggle()` call.

[Learn more about Window fullscreen](https://anilcancakir.com/magic_device/docs/basics/window-fullscreen.md)

### Honest on every platform

A native read where one exists, a clear fallback where it does not. Its only native code is a macOS plugin.

[Learn more about Honest on every platform](https://anilcancakir.com/magic_device/docs/getting-started/installation.md)

### Idle until you start it

Nothing is collected until `start()`: an instance that never starts holds no channel, no timer and no lifecycle observer.

[Learn more about Idle until you start it](https://anilcancakir.com/magic_device/docs/basics/device-power.md)

### Test without a device

Every `DevicePower` read except the app lifecycle is a constructor parameter, so a test needs no mocking library.

[Learn more about Test without a device](https://anilcancakir.com/magic_device/docs/guides/testing.md)

## Your agent speaks Magic Device.

The Magic Device skill teaches your coding assistant when to gate background work and how to wire `DevicePower` and `WindowFullscreen` before the first line. One command wires it up.

```bash
npx skills add anilcancakir/ai --skill magic-device
```

[other editors](https://github.com/anilcancakir/ai)

## And checks the docs.

Skills teach the API. The MCP server at `mcp.anilcancakir.com/magic_device` gives your agent live docs lookup while it edits, so it never guesses a signature.

```bash
claude mcp add --transport http magic_device https://mcp.anilcancakir.com/magic_device
```

```bash
npx -y mcp-remote https://mcp.anilcancakir.com/magic_device
```

## Add it in seconds

```bash
flutter pub add magic_device
```

Or add to `pubspec.yaml`:

```yaml
dependencies:
  magic_device: ^0.0.2
```

Or give your AI agent this prompt:

```text
Read https://anilcancakir.com/magic_device/docs/llms.txt and install the Magic Device package in this project.
```

## Docs

### Getting Started

- [Installation](https://anilcancakir.com/magic_device/docs/getting-started/installation.md)

### The Basics

- [DevicePower](https://anilcancakir.com/magic_device/docs/basics/device-power.md)
- [WindowFullscreen](https://anilcancakir.com/magic_device/docs/basics/window-fullscreen.md)

### Guides

- [Testing](https://anilcancakir.com/magic_device/docs/guides/testing.md)
