Metadata-Version: 2.5
Name: runtfy
Version: 0.1.0
Summary: A CLI tool that wraps terminal commands and notifies your phone when they finish or need input.
Project-URL: Homepage, https://github.com/adilkt16/runtfy
Project-URL: Repository, https://github.com/adilkt16/runtfy
Project-URL: Bug Tracker, https://github.com/adilkt16/runtfy/issues
Project-URL: Changelog, https://github.com/adilkt16/runtfy/blob/main/CHANGELOG.md
Author-email: Adil <adilkt16@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2026 Adil (adilkt16)
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Description-Content-Type: text/markdown

# runtfy

runtfy is an open-source command-line tool. It wraps terminal commands, such as long-running AI coding agent sessions, and sends push notifications to your phone when they complete or when Claude Code requires your input. It also features an opt-in lock-when-away mode that locks your screen while you are away and alerts you if anyone interacts with your machine.

---

## 1. What it does

Developers often launch long AI coding runs and walk away, only to find the run finished in minutes and sat idle, or paused for permissions. runtfy bridges this gap by sending instant push notifications to your phone without requiring accounts, hosted servers, or complex setups. It wraps any command cleanly in a pseudo-terminal and exits with the exact same exit code.

---

## 2. Install

Install with `pipx` (recommended):

```bash
pipx install runtfy
```

Or install with `pip`:

```bash
pip install runtfy
```

---

## 3. Quick start

Initialize your private notification topic:

```bash
runtfy init
```

Wrap any terminal command:

```bash
runtfy <your-command>
```

Examples:

```bash
runtfy sleep 10
runtfy pytest tests/
runtfy claude
```

---

## 4. ntfy setup

runtfy delivers notifications using [ntfy](https://ntfy.sh), an open-source HTTP-based notification service. No account is required.

1. Install the **ntfy** app on your phone:
   - **iOS**: Available on the [App Store](https://apps.apple.com/app/ntfy/id1625396347).
   - **Android**: Available on [Google Play](https://play.google.com/store/apps/details?id=io.heckel.ntfy) or [F-Droid](https://f-droid.org/packages/io.heckel.ntfy/).
2. Open the ntfy app and tap **+** (**Subscribe to topic**).
3. Enter your generated topic name:
   ```
   your-topic-here
   ```
4. Notifications sent by runtfy will immediately appear on your device.

---

## 5. Claude Code hooks

runtfy integrates directly with Claude Code via its built-in lifecycle hooks.

Install the hooks with:

```bash
runtfy install-hooks
```

What this does:
- Locates `~/.claude/settings.json`.
- Displays a unified diff of proposed changes.
- Creates a timestamped backup before writing.
- Adds the `Stop` hook (`runtfy hook-stop`) and `Notification` hook (`runtfy hook-notify`).
- Preserves all pre-existing hooks and is idempotent (safe to run multiple times).

To verify the installation, inspect `~/.claude/settings.json` to confirm `Stop` and `Notification` entries are present under `"hooks"`.

---

## 6. Lock-when-away

Lock your screen while away and alert on unauthorized input:

```bash
runtfy --lock-when-away <command>
```

Example:

```bash
runtfy --lock-when-away claude
```

### Important details:
- **Opt-in only**: Screen locking is never active unless `--lock-when-away` is explicitly provided.
- **macOS**: Locks the display immediately using `pmset displaysleepnow` (requiring zero Accessibility permissions). It then watches the kernel HID idle counter; if someone touches the keyboard or moves the mouse while locked, runtfy sends an input alert to your phone with an enforced 60-second cooldown between notifications.
- **Linux (v0.1)**: Locks the graphical session using `loginctl lock-session` (with fallbacks to `xdg-screensaver` and `gnome-screensaver-command`). In v0.1, input alerts on Linux are out of scope; Linux receives the screen lock only.
- **Resilience**: If screen locking fails, the wrapped command continues to run and a warning notification is sent to your phone.

---

## 7. Configuration

Configuration lives at `~/.config/runtfy/config.toml` with owner-only (`0o600`) permissions:

```toml
[runtfy]
topic = "your-topic-here"  # ntfy topic; generated by runtfy init
summary = false            # opt-in output summary
summary_lines = 5          # number of lines to include when summary = true

[quiet_hours]
enabled = false            # silence notifications during specific hours
start = "22:00"
end = "08:00"

[events]
finish = true              # notify when wrapped command or Claude session ends
waiting = true             # notify when Claude Code needs input or permission
```

---

## 8. Privacy

- **Safe defaults**: Notifications contain only the program name (e.g. `claude`, never its arguments), exit code, duration, and status. Arguments are never included because they can contain secrets.
- **No output leakage**: Command output, file paths, and file contents are never transmitted by default.
- **Opt-in summaries**: Output summaries are strictly opt-in (`summary = true`).
- **Secret topic protection**: Your ntfy topic is generated locally, stored in owner-only configuration files (`chmod 600`), and is never printed in logs or committed to version control.
- **No credential handling**: runtfy never reads, stores, or handles operating system passwords.
- **No telemetry**: runtfy contains no analytics or tracking. All network calls go exclusively to the configured ntfy server.
- **Zero personal data**: The repository and default configurations contain no personal names, emails, usernames, or machine paths.

---

## 9. Self-hosting ntfy

If you prefer not to use the public `ntfy.sh` server or wish to avoid public server rate limits, you can host your own ntfy instance using Docker or official binary distributions. To direct runtfy to your private instance, set `server = "https://ntfy.example.com"` under `[runtfy]` in `~/.config/runtfy/config.toml`. Refer to the [official ntfy documentation](https://docs.ntfy.sh/) for self-hosting instructions.

---

## 10. Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup instructions, implementation rules, and pull request guidelines.

---

## 11. Licence

This project is licensed under the [MIT Licence](https://opensource.org/licenses/MIT).
