vaken 0.1.0

Tiny macOS menu bar utility to keep your Mac awake — Rust wrapper around `caffeinate`.
<p align="center">
  <img src="icons/icon-256.png" alt="Vaken icon" width="96">
</p>

# Vaken

[![CI](https://github.com/GnomesOfZurich/vaken/actions/workflows/ci.yml/badge.svg)](https://github.com/GnomesOfZurich/vaken/actions/workflows/ci.yml)
![Version](.github/badges/version.svg)
![Platform](.github/badges/platform.svg)
![License](.github/badges/license.svg)

A tiny macOS menu-bar utility for keeping your Mac awake on demand.

> *Vaken* is Swedish for **awake**.

[crates.io](https://crates.io/crates/vaken) · [GitHub](https://github.com/GnomesOfZurich/vaken)

## Why

Most of the time you want closing the lid to mean sleep. Occasionally
you don't — an overnight build, a long SSH session, a local agent
chewing through a queue, a `cargo test` you want to finish on
battery. Vaken adds a single menu-bar toggle for those moments,
without permanently changing your sleep settings.

When enabled, Vaken keeps display, idle, disk, and system asleep
states all suppressed. Toggle off (or quit the app) and your Mac
goes back to normal sleep behaviour.

## What it isn't

- No Dock icon, no Cmd-Tab presence — menu bar only (`LSUIElement = true`).
- No Electron, no webview, no JavaScript.
- No telemetry, no network calls, no settings file, no auto-update.
- A single Rust binary (~few MB), backed by macOS `caffeinate`.

## Install

### From GitHub Release (recommended)

Download `Vaken.app.zip` from [the latest release](https://github.com/GnomesOfZurich/vaken/releases),
unzip, drag into `/Applications/`, launch.

First launch hits Gatekeeper ("Apple cannot check it for malicious
software") because the binary isn't signed with an Apple Developer ID.
Bypass it once:

- Right-click `Vaken.app`**Open** → confirm in the dialog, **or**
- `xattr -dr com.apple.quarantine /Applications/Vaken.app`

After that it launches normally.

### From crates.io

```bash
cargo install vaken
vaken &
```

This drops a bare binary at `~/.cargo/bin/vaken`. It works, but
without the `.app` bundle's `Info.plist` it'll appear in the Dock
and Cmd-Tab switcher and may exit when its terminal session ends.
Prefer the GitHub Release for daily use.

### From source

Requires macOS, the [Rust toolchain](https://www.rust-lang.org/tools/install), and Cargo.

```bash
git clone https://github.com/GnomesOfZurich/vaken.git
cd vaken
cargo run                              # quick try
cargo install cargo-bundle --locked    # one-time
cargo bundle --release                 # produces target/release/bundle/osx/Vaken.app
```

## macOS sleep caveat

Apple increasingly enforces hardware sleep when the lid closes.
Vaken works best with one of:

- plugged into power, **or**
- an external display attached, **or**
- the lid kept open.

Closed-lid behaviour varies by chip (Apple Silicon vs Intel), macOS
version, and battery state — sometimes Vaken can keep the Mac up,
sometimes the kernel sleeps anyway. Not a Vaken bug; it's the
hardware policy.

## How it works

When toggled on, Vaken spawns:

```
caffeinate -dimsu -w <vaken_pid>
```

`-dimsu` suppresses display, idle, disk, and system sleep, and asserts
user-active. `-w <vaken_pid>` is the safety net: it tells `caffeinate`
to watch Vaken's own PID, and the kernel terminates `caffeinate` the
moment Vaken exits — clean quit, panic, Force Quit, `kill -9`,
whatever. No orphan `caffeinate` lingering past Vaken's death; no
user-space cleanup hook to fail.

Toggle off, and Vaken sends `kill` to the `caffeinate` child
directly.

## Contributing

Issues and PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). The
project scope is deliberately narrow (one toggle, no settings, no
networking); please open an issue before sending PRs that grow the
surface area.

## License

Dual-licensed under either of:

- [MIT]LICENSE-MIT
- [Apache License 2.0]LICENSE-APACHE

at your option.