Comprehensive Apple TV CLI & TUI remote control powered by pyatv
Project description
๐ pyatv-cli
The ultimate Apple TV remote control for your terminal
50+ commands ยท Full-screen TUI ยท Rich output ยท JSON scripting
Control your Apple TV entirely from the terminal. Power, remote, media, apps, audio, streaming, touch gestures โ everything your Siri Remote can do, atv can do better. Built on pyatv with gorgeous Rich output and a full-screen Textual TUI.
๐ Table of Contents
- โจ Feature Highlights
- ๐ค Why pyatv-cli?
- ๐ Preview
- ๐ฆ Installation
- ๐ Quick Start
- ๐ Complete Command Reference
- ๐ฅ๏ธ TUI Mode
- ๐ง JSON Scripting
- โ๏ธ Configuration
- ๐ก Protocol Support
- ๐ Troubleshooting
- ๐ค Contributing
- ๐ License
- ๐ Credits
โจ Feature Highlights
- ๐ฎ 50+ commands across 13 command groups โ power, remote, media, apps, audio, keyboard, touch, stream, system, accounts, monitor, settings, shell
- ๐ฅ๏ธ Full-screen TUI โ A beautiful Textual-based terminal UI with live-updating now-playing, volume control, and remote buttons
- ๐ Auto-discovery โ Find every Apple TV on your network with one command
- ๐ Interactive pairing โ Guided PIN-based pairing flow, credentials saved automatically
- ๐ Rich terminal output โ Beautiful tables, panels, and formatted text via Rich
- ๐ค JSON mode โ Pipe
--jsonoutput tojqfor scripting and automation - ๐บ Real-time monitor โ Live-updating now-playing display with Rich Live
- ๐ Interactive shell โ REPL mode for rapid-fire commands
- ๐ AirPlay streaming โ Stream URLs and local files to your TV
- ๐ Touch gestures โ Swipes, taps, double-taps, and long presses
- โจ๏ธ Virtual keyboard โ Type text directly into Apple TV search fields
- ๐พ Multi-device support โ Pair and switch between multiple Apple TVs
- ๐ Python 3.10โ3.14 โ Runs on modern Python with zero configuration
๐ค Why pyatv-cli?
If you've used atvremote (the built-in CLI from pyatv), you'll appreciate what pyatv-cli brings to the table:
| Feature | atvremote |
pyatv-cli |
|---|---|---|
| Beautiful Rich output | โ | โ |
| Full-screen TUI | โ | โ |
| Credential persistence | โ | โ |
| Multi-device management | โ | โ |
| JSON output for scripting | โ | โ |
| Interactive shell (REPL) | โ | โ |
| Touch gesture commands | โ | โ |
| Organized command groups | โ | โ |
One-word atv command |
โ | โ |
๐ Preview
Scan Output
$ atv scan
โน Scanning for Apple TVs (timeout: 5s)...
๐ Discovered Apple TVs
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ Name โ Address โ Model โ Services โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโค
โ Living Room โ 192.168.1.50 โ AppleTV4Kโ MRP, AirPlay โ
โ Bedroom TV โ 192.168.1.51 โ AppleTV4Kโ MRP, AirPlay โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโ
Found 2 device(s). Use atv pair to pair.
Now Playing
$ atv media info
โญโโโโโโโโโโโโโโโโ ๐ต Now Playing โโโโโโโโโโโโโโโโโโฎ
โ Title: Bohemian Rhapsody โ
โ Artist: Queen โ
โ Album: A Night at the Opera โ
โ State: โถ๏ธ Playing โ
โ Position: 2:31 / 5:55 โ
โ App: Apple Music โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
TUI Mode
$ atv tui
โญโโโโโโโโโโโโโโโโโโโ ๐ Apple TV Remote โโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ ๐ต Bohemian Rhapsody โถ๏ธ Playing โ
โ ๐ค Queen โ
โ ๐ฟ A Night at the Opera โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโ 2:31 / 5:55 โ
โ โ
โ โโโโโโโโ โ
โ โ โฒ โ โ
โ โโโโโโค OK โโโโโโ โ
โ โ โ โ โ โถ โ โ
โ โโโโโโค โผ โโโโโโ โ
โ โโโโโโโโ โ
โ โ
โ [โฎ] [โช] [โฏ] [โฉ] [โญ] ๐ โโโโโโโโโโโโ 72% โ
โ โ
โฐโโโ q:Quit Space:Play/Pause h:Home Esc:Menu โโโโโโโโโโโฏ
๐ฆ Installation
From PyPI (recommended)
pip install pyatv-cli
With pipx (isolated install)
pipx install pyatv-cli
From source
git clone https://github.com/yigitkonur/pyatv-cli.git
cd pyatv-cli
pip install -e .
Requires Python 3.10+. Dependencies (
pyatv,click,rich,textual) are installed automatically.
๐ Quick Start
Get up and running in three steps:
1๏ธโฃ Discover Apple TVs on your network
atv scan
2๏ธโฃ Pair with your Apple TV
atv pair
# A PIN will appear on your TV โ enter it when prompted
3๏ธโฃ Start controlling!
# Check power state
atv power status
# Play / pause
atv remote play-pause
# See what's playing
atv media info
# Launch an app
atv apps launch com.apple.TVMusic
# Open the full TUI
atv tui
๐ Complete Command Reference
๐ Discovery & Setup
| Command | Description |
|---|---|
atv scan |
Discover Apple TVs on your network |
atv scan --host 192.168.1.50 |
Scan a specific IP address |
atv scan --timeout 10 |
Custom scan timeout (default: 5s) |
atv pair |
Pair with an Apple TV (interactive PIN flow) |
atv pair --protocol airplay |
Pair using a specific protocol |
atv unpair --protocol companion |
Remove credentials for a protocol |
atv unpair --all |
Remove device entirely |
atv devices |
List all paired devices |
atv default <id> |
Set the default device |
atv default |
Show current default device |
โก Power Control
| Command | Description |
|---|---|
atv power status |
Show current power state |
atv power on |
Turn on |
atv power off |
Turn off |
atv power toggle |
Toggle power state |
๐ฎ Remote Control
Full Siri Remote emulation with 27 commands:
| Command | Description |
|---|---|
atv remote up |
Navigate up |
atv remote down |
Navigate down |
atv remote left |
Navigate left |
atv remote right |
Navigate right |
atv remote select |
Confirm selection (OK) |
atv remote menu |
Menu / Back |
atv remote home |
Home button |
atv remote home-hold |
Long-press Home |
atv remote top-menu |
Top menu |
atv remote play |
Play |
atv remote pause |
Pause |
atv remote stop |
Stop |
atv remote play-pause |
Toggle play/pause |
atv remote next |
Next track |
atv remote previous |
Previous track |
atv remote skip-forward |
Skip forward |
atv remote skip-backward |
Skip backward |
atv remote volume-up |
Volume up |
atv remote volume-down |
Volume down |
atv remote channel-up |
Channel up |
atv remote channel-down |
Channel down |
atv remote screensaver |
Activate screensaver |
atv remote guide |
Open guide |
atv remote control-center |
Open Control Center |
atv remote set-position <sec> |
Seek to position (seconds) |
atv remote set-shuffle off|songs|albums |
Set shuffle mode |
atv remote set-repeat off|track|all |
Set repeat mode |
๐ต Media / Now Playing
| Command | Description |
|---|---|
atv media info |
Show current track info (title, artist, album, state, position) |
atv media artwork -o cover.png |
Download current artwork to a file (-w/--width, --height to resize) |
๐ฑ App Management
| Command | Description |
|---|---|
atv apps list |
List installed apps (name + bundle ID) |
atv apps launch <bundle_id> |
Launch an app by bundle identifier |
๐ Audio Control
| Command | Description |
|---|---|
atv audio get |
Show current volume level |
atv audio set <0-100> |
Set volume to a specific level |
atv audio up |
Increase volume |
atv audio down |
Decrease volume |
atv audio devices |
List audio output devices |
โจ๏ธ Virtual Keyboard
| Command | Description |
|---|---|
atv keyboard status |
Check if keyboard is focused |
atv keyboard get |
Get current text in the field |
atv keyboard set <text> |
Replace text in the field |
atv keyboard append <text> |
Append text to the field |
atv keyboard clear |
Clear the text field |
๐ Touch Gestures
| Command | Description |
|---|---|
atv touch swipe up|down|left|right |
Directional swipe gesture |
atv touch swipe-custom <x1> <y1> <x2> <y2> |
Custom swipe between coordinates |
atv touch tap |
Single tap |
atv touch double-tap |
Double tap |
atv touch hold |
Long press |
๐ Streaming
| Command | Description |
|---|---|
atv stream url <url> |
Stream media from a URL |
atv stream file <path> |
Stream a local file via AirPlay |
๐ป System Information
| Command | Description |
|---|---|
atv system info |
Show device info (model, OS, version) |
atv system features |
List supported features with status table |
๐ค User Accounts
| Command | Description |
|---|---|
atv accounts list |
List user accounts on the device |
atv accounts switch <id> |
Switch to a different account |
๐ Live Monitoring
| Command | Description |
|---|---|
atv monitor |
Real-time now-playing display with Rich Live (Ctrl+C to stop) |
โ๏ธ Settings
| Command | Description |
|---|---|
atv settings show |
Show current configuration |
atv settings set <key> <value> |
Change a setting |
atv settings remove <key> |
Remove a setting |
๐ Interactive Shell
| Command | Description |
|---|---|
atv shell |
Launch interactive REPL for rapid-fire commands |
๐ Global Options
| Option | Description |
|---|---|
--json |
Output in JSON format for scripting and piping |
--version |
Show version number |
Note:
--device <id>and--host <ip>are not global options โ they are available on most subcommands to target a specific paired device or connect by IP address.
๐ฅ๏ธ TUI Mode
Launch a full-screen interactive terminal UI to control your Apple TV:
atv tui
The TUI provides:
- ๐ต Live now-playing panel โ Title, artist, album, progress bar updated in real-time
- ๐ฎ Visual remote control โ On-screen directional pad and media buttons
- ๐ Volume control โ Real-time volume indicator
- ๐ฑ App info โ See which app is currently running
- ๐จ Dark/light theme โ Toggle with
d
โจ๏ธ Keyboard Shortcuts
| Key | Action |
|---|---|
โ โ โ โ |
Navigate |
Enter |
Select / OK |
Space |
Play / Pause |
Esc or m |
Menu / Back |
h |
Home |
n |
Next track |
p |
Previous track |
] |
Volume up |
[ |
Volume down |
d |
Toggle dark/light theme |
q |
Quit TUI |
๐ง JSON Scripting
Every command supports --json for easy scripting and automation:
# Get all device names on your network
atv --json scan | jq '.[].name'
# Get the currently playing song title
atv --json media info | jq -r '.Title'
# Get volume as a number
atv --json audio get | jq '.volume'
# List all app bundle IDs
atv --json apps list | jq '.[].identifier'
# Check if the TV is on
atv --json power status | jq -r '.power_state'
Automation Examples
# Turn off TV at midnight (cron)
0 0 * * * /usr/local/bin/atv power off
# Play/pause from a Stream Deck or shortcut
atv remote play-pause
# Build a dashboard with watch
watch -n 2 'atv --json media info | jq "{title: .Title, artist: .Artist, state: .State}"'
# Notify when song changes (macOS)
while true; do
TITLE=$(atv --json media info | jq -r '.Title // empty')
[ -n "$TITLE" ] && osascript -e "display notification \"$TITLE\" with title \"Now Playing\""
sleep 10
done
โ๏ธ Configuration
Config File Location
Credentials and device settings are persisted at:
~/.config/pyatv-cli/config.json
Config Structure
{
"default_device": "AA:BB:CC:DD:EE:FF",
"devices": {
"AA:BB:CC:DD:EE:FF": {
"name": "Living Room",
"address": "192.168.1.50",
"identifier": "AA:BB:CC:DD:EE:FF",
"credentials": {
"companion": "...",
"airplay": "..."
}
}
}
}
Multi-Device Support
# Pair multiple devices
atv pair --host 192.168.1.50
atv pair --host 192.168.1.51
# Switch default device
atv default <device-id>
# Target a specific device for one command
atv --device <device-id> power on
atv --host 192.168.1.51 remote play
๐ก Protocol Support
pyatv-cli supports all four Apple TV protocols via pyatv:
| Protocol | What It Unlocks |
|---|---|
| Companion | Remote control commands, app launching, power management, keyboard input โ the primary protocol for tvOS control |
| AirPlay | Media streaming (URLs, local files), artwork, audio routing |
| MRP (Media Remote Protocol) | Now-playing info, playback control, volume, media metadata |
| RAOP (Remote Audio Output Protocol) | Audio-only streaming to AirPlay speakers and Apple TVs |
Pairing by Protocol
# Pair Companion (recommended first)
atv pair --protocol companion
# Pair AirPlay (for streaming)
atv pair --protocol airplay
# Check which protocols are paired
atv devices
Tip: Pair with Companion first โ it covers most commands. Add AirPlay if you need streaming.
๐ Troubleshooting
Device not found during scan
โ No Apple TVs found.
- Ensure your Apple TV and computer are on the same network and subnet
- Check that your Apple TV is powered on (not just in standby for first-time discovery)
- Try scanning a specific IP:
atv scan --host 192.168.1.50 - Increase timeout:
atv scan --timeout 15 - Make sure multicast/mDNS traffic isn't blocked by your router or firewall
Pairing fails or PIN not appearing
- Restart the pairing:
atv pair - Try a different protocol:
atv pair --protocol airplay - On your Apple TV: Settings โ Remotes and Devices โ Remote App and Devices โ ensure it's set to allow pairing
- Restart your Apple TV and try again
"Feature unavailable" errors
- Some features require specific protocols โ pair with Companion and AirPlay
- Check supported features:
atv system features - Certain features only work while media is actively playing
Connection drops or timeouts
- Apple TVs can be slow to respond from standby โ try
atv power onfirst - Ensure no other remote apps are conflicting
- Re-pair if credentials become stale:
atv unpair --all && atv pair
๐ค Contributing
Contributions are welcome! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Found a bug or have a feature request? Open an issue.
๐ License
MIT License โ see MIT for details.
๐ Credits
Built on the shoulders of these excellent projects:
| Project | Role |
|---|---|
| pyatv | Core Apple TV protocol library โ the engine behind everything |
| Click | CLI framework powering all 50+ commands |
| Rich | Beautiful terminal output โ tables, panels, colors |
| Textual | Full-screen TUI framework for the interactive mode |
Made with โค๏ธ by Yigit Konur
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyatv_cli-1.0.2.tar.gz.
File metadata
- Download URL: pyatv_cli-1.0.2.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ba399da6e638c6632c6d497d4cb767274e20f08c3a186d1170e4b6ca0ccd01a
|
|
| MD5 |
b3305ff7c3360062592d0a8247d4cff5
|
|
| BLAKE2b-256 |
988221b8ea6d982da18c0fd64dc390c6506f013de46d39445d5d2a8100abae91
|
File details
Details for the file pyatv_cli-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pyatv_cli-1.0.2-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdb16ce0429c624cce53a4f8e1d98052d6d36e2fc02ada8a656db451a38e8611
|
|
| MD5 |
59d6b9396fe45c608a9e821c30dd1cc6
|
|
| BLAKE2b-256 |
3759fcd4366e6423c338527feb630aae33d231ad5589016b54968dc33fc31e66
|