Home TV Lock: lock TV videos from your phone
Home › Utilities · home_lock.sh 1.1.0

The TV works normally until you tap Lock on your phone. Then YouTube, Hotstar, Netflix and the other video apps are paused, casting from phones stops, and the TV goes to its home screen. It stays that way, even after the TV restarts, until you tap Unlock. No app is installed on the TV; the phone talks to it over your Wi-Fi using Android's own debugging link (ADB).

⬇ home_lock.sh (phone, Termux) ⬇ tv_lock.bat (Windows PC) ⬇ tv_clean.bat (Mi TV clean-up, optional)

What Lock doesThree ways to control itPrepare the TVFix the IP addressesPhone setup with TermuxCommandsAway from homeOther TV brandsLimits

What Lock does

  • Pauses the video apps: YouTube, Hotstar, SonyLIV, Prime Video, ZEE5, JioCinema, Netflix, MX Player, the TV's own video and USB media players. A paused app shows "app paused" and cannot be switched back on from the TV's Settings.
  • Pauses the Play Store, so no new video app can be installed meanwhile.
  • Switches off Chromecast and screen mirroring, so nobody can cast from a phone.
  • Stops whatever is playing and returns to the home screen.

Unlock brings everything back exactly as it was. Apps the TV doesn't have are skipped. If a TV doesn't allow pausing, the script disables the app instead and says so.

Three ways to control it

FromHowNeeds
Phonehome_lock.sh in Termux, with one-tap home-screen buttonsPhone on the home Wi-Fi
Phone browserLock / Unlock on the FocusGuard home pageThe children's PC on, with FocusGuard
Windows PCtv_lock.bat lock or unlockadb (platform-tools) on that PC

If you use FocusGuard too, home_lock.sh goes through the PC when it is on, so the phones and the PC share one lock state. When the PC is off, the phone locks the TV directly. Without FocusGuard, it simply talks to the TV directly every time (TV-only mode).

1 · Prepare the TV (once)

  1. On the TV: Settings › Device Preferences › About, then click Build seven times until it says you are a developer. (On some TVs it is Settings › System › About.)
  2. Go back to Device Preferences › Developer options and turn on USB debugging. On some models there is also Network debugging or ADB over network: turn that on too.
  3. Note the TV's IP address: Settings › Network & Internet › your Wi-Fi.
  4. The first time the phone (or PC) connects, the TV shows Allow USB debugging?. Tick Always allow from this computer and press OK with the remote. Each phone or PC is asked once.
Debugging lets any device on your Wi-Fi that you approve control the TV. Approve only your own phones and PC, keep your Wi-Fi password private, and never forward port 5555 on the router.

2 · Fix the IP addresses on the router

The phone finds the TV (and the children's PC) by IP address, so those must not change after a restart. Instead of setting a static IP on each device, reserve it on the router; nothing changes on the TV or PC.

  1. Open the router page in a browser, usually 192.168.1.1 or 192.168.0.1. The login is often on a sticker under the router.
  2. Find DHCP › Address Reservation (also called Static Lease, DHCP Binding or IP & MAC Binding).
  3. Add the TV's MAC address with its current IP, and the same for the children's PC (on the PC, ipconfig /all shows the Physical Address). Save, and reboot the router if it asks.

Step-by-step guide, with how to read IP and MAC from the router's device list and where the menu sits on common routers: Fixed IP addresses for home devices.

3 · Phone setup with Termux (Android)

Termux is a free Linux terminal app for Android. It runs adb, the same tool a PC uses to talk to the TV, so your phone can lock the TV directly, even with the PC switched off. Termux:Widget turns the commands into one-tap buttons on the home screen, so day to day you never type anything. Do this on each parent's phone.

  1. Install Termux and Termux:Widget from F-Droid (f-droid.org), or both from GitHub releases. Don't mix sources, and don't use the Play Store Termux: it is outdated and will not work with the widget.
  2. Download home_lock.sh on the phone (the button at the top of this page). It lands in Downloads.
  3. Open the script in any text editor app, or in Termux with nano after step 4, and change the two lines under CHANGE THESE TWO LINES: TV="<TV-IP>:5555", and PC="<PC-IP>:8765" if you use FocusGuard.
  4. Open Termux and run these one at a time. Tap Allow when Android asks for storage access:
    pkg update
    pkg install android-tools curl
    termux-setup-storage
    cp ~/storage/downloads/home_lock.sh ~/
    bash ~/home_lock.sh setup
    If cp says the file is missing, run ls ~/storage/downloads | grep -i lock. The phone may have renamed it (for example home_lock.sh.txt); use that name in the cp line.
  5. Setup asks for the FocusGuard parent PIN. With FocusGuard, type it (it is saved in a file only Termux can read). Without FocusGuard, just press Enter: you get TV-only mode.
  6. Pair with the TV: run bash ~/home_lock.sh status. When it says Look at the TV, tick Always allow on the TV and press OK. It waits up to 60 seconds.
  7. Add the buttons: long-press an empty spot on the home screen › Widgets › Termux:Widget. If it asks for permission, open Termux:Widget once from the app list, and allow "Display over other apps" for Termux if Android asks.
ButtonWhat it does
1_TV_Lock / 2_TV_UnlockLock or unlock the TV (through the PC if it is on, otherwise directly). Takes about 30–60 seconds; the TV must be on.
3_PC_Study_30 / 4_PC_Study_60Give each child 30 or 60 minutes of study time on the PC (FocusGuard only)
5_PC_StopEnd the study time now (FocusGuard only)
6_StatusTV locked or not, and each child: signed in, study time left
The window closes 5 seconds after a button finishes; tap Status if you missed the result. If you unlock from the phone while the PC was off and FocusGuard had last locked the TV, the PC locks it again when it starts. Tap Unlock once more after the PC is on.

Typed commands

bash ~/home_lock.sh status
bash ~/home_lock.sh tv lock | tv unlock | tv status
bash ~/home_lock.sh pc give 45          # 45 min for every child
bash ~/home_lock.sh pc give 45 kid1     # one child only
bash ~/home_lock.sh pc stop  |  pc status
bash ~/home_lock.sh setup               # change the PIN, remake buttons

From a Windows PC

Put tv_lock.bat in C:\platform-tools next to adb.exe, set TV= at the top, and run tv_lock.bat lock or tv_lock.bat unlock.

Away from home

Termux reaches the TV on its home-Wi-Fi address, so the buttons work only at home. To use them from outside, install Tailscale (a free private VPN) on the TV and the phones with the same account, while the TV is unlocked. Then put the TV's Tailscale address (100.x.y.z) in the TV= line. Test once from mobile data; some TVs stop background apps in standby.

Never open port 5555 (or FocusGuard's 8765) on your router to the internet. Anyone could then control the TV.

Other TV brands

The app list is for a Xiaomi Mi TV in India, but the method works on most Android TV and Google TV sets (Sony, TCL, OnePlus, Realme, Hisense with Google TV and others). To adjust the lists for your TV, connect from a PC and list its apps:

adb connect <TV-IP>:5555
adb shell pm list packages | findstr /i "video youtube netflix prime hotstar cast"

Add or remove names in the APPS list (video apps) and SERVICES list (casting) near the top of the script. Fire TV sticks also accept adb, but their app names differ. Samsung (Tizen) and LG (webOS) TVs are not Android, so this script does not work on them.

Optional: clean up a Mi TV

tv_clean.bat switches off Xiaomi's clutter and tracking apps (Mi TV+, Mi channels, analytics, auto-install, Mi Music, Gallery, recommendations) over Wi-Fi from a PC. Run tv_clean.bat, then reboot the TV. tv_clean.bat restore turns everything back on.

Leave these alone: com.mi.bluetooth (the remote stops working), mitv.service, droidlogic packages, tv.settings, systemui, and katniss (voice search). A factory reset or big firmware update may bring the clutter back; run it again then.

Limits