Automatically close TiviMate on Android TV devices after a period of inactivity to save bandwidth.
The Problem: Non-CEC TVs can't tell apps when they're turned off. TiviMate keeps streaming forever, wasting bandwidth. This tool gives you the classic "Are you still watching?" prompt.
# Clone and configure
git clone <your-repo-url>
cd tivimate-closer
# Edit docker-compose.yml - Set your device IP
nano docker-compose.yml
# Run
docker-compose up -d
# Single check
./tivimate-closer.sh 192.168.1.100
# Run as service (continuous monitoring)
./tivimate-closer.sh -s -i 60 192.168.1.100
Enable ADB debugging on your device:
- Go to Settings → About
- Click on Build 7 times to enable Developer Mode
- Go to Settings → Developer Options
- Enable Network Debugging or ADB Debugging
Onn 4K / Onn 4K Pro: Settings → System → About → Android TV OS build (click 7 times) → Enable USB ADB
Edit docker-compose.yml
:
environment:
# Your device IP(s)
DEVICE_IPS: "192.168.1.100" # Single device
# DEVICE_IPS: "192.168.1.100,192.168.1.101" # Multiple devices
# Timing (in seconds)
DURATION: "10800" # 3 hours until warning
CHECK_INTERVAL: "60" # Check every minute
WAIT_TIME: "30" # Wait 30s for user response
# Android 12+ compatibility
ACTIVITY_RESUME_PATTERN: "ResumedActivity" # Use "mResumedActivity" for Android 11-
- Monitors - Checks if TiviMate is running every
CHECK_INTERVAL
seconds - Tracks - Records when app started running
- Warns - After
DURATION
, displays on-screen message - Waits - Gives user
WAIT_TIME
seconds to respond - Closes - If no response, closes TiviMate
./tivimate-closer.sh [OPTIONS] IP [IP...]
OPTIONS:
-s Service mode (continuous monitoring)
-i seconds Check interval (default: 60)
-t seconds Duration before warning (default: 10800)
-w seconds Wait time for response (default: 30)
-r pattern Android activity pattern (mResumedActivity or ResumedActivity)
-m message Warning message (auto-converts to ADB format)
-p package Package name (default: ar.tvplayer.tv)
docker-compose up -d # Start service
docker-compose logs -f # View logs
docker-compose down # Stop service
# One-time check
./tivimate-closer.sh 192.168.1.100
# Service mode
./tivimate-closer.sh -s -i 60 192.168.1.100
# Custom timing
./tivimate-closer.sh -t 7200 -w 45 192.168.1.100
# Android 12+ device
./tivimate-closer.sh -r ResumedActivity 192.168.1.100
# Check every 5 minutes
*/5 * * * * /path/to/tivimate-closer.sh 192.168.1.100
- First time: Check TV screen for "Allow USB debugging" prompt
- Auth failed: Device needs authorization - check TV screen
- Test connection:
docker-compose exec tivimate-closer adb devices
# or
adb connect 192.168.1.100:5555
Different Android versions use different activity patterns:
- Android 11-:
mResumedActivity
(default) - Android 12+:
ResumedActivity
Test which works:
adb shell dumpsys activity activities | grep mResumedActivity
# or
adb shell dumpsys activity activities | grep ResumedActivity
# Docker
docker-compose down -v
# Standalone
rm -rf ~/.android
- 🐳 Docker Support - Easy deployment with persistent ADB keys
- 📊 Multi-device - Monitor multiple Android TVs
- ⏰ Configurable Timers - Custom inactivity periods
- 🔄 Service Mode - Run continuously or one-time
- 📝 Human-Readable Messages - Auto-converts to ADB format
- 🤖 Android 12+ Support - Compatible with latest Android TV
- Docker & Docker Compose (for Docker mode)
- ADB tools (for standalone mode)
- Android TV with network debugging enabled
- Same network as your Android TV devices
See LICENSE file for details.