A bash script that provides a user-friendly terminal interface to control LG WebOS TVs. This script uses dialog boxes to present menus and options, making it easy to control your LG TV from your computer.
- Power controls (turn TV on/off, screen on/off)
- Volume controls (up, down, set specific level)
- Media controls (play, pause, rewind)
- Input selection (HDMI, etc.)
- Open URLs (including special handling for YouTube)
- Launch apps installed on the TV
- Send notifications to the TV
The script requires the following dependencies:
lgtv- A command-line tool for controlling LG WebOS TVsdialog- A utility for creating TUI dialog boxesjq- A lightweight and flexible command-line JSON processor
-
Clone or download this repository to your local machine.
-
Make the script executable:
chmod +x lg
-
Install the required dependencies:
-
Install
lgtvusing pipx:pipx install git+https://github.com/klattimer/LGWebOSRemote.git
-
Install
dialogandjqusing your package manager:# For Debian/Ubuntu sudo apt-get install dialog jq # For Fedora sudo dnf install dialog jq # For Arch Linux sudo pacman -S dialog jq
-
Before using the script, you need to set up the connection to your LG TV:
-
Make sure your TV is turned on and connected to the same network as your computer.
-
Scan for available TVs:
lgtv scan
-
Authenticate with your TV (replace
[TV_IP]with the IP address from the scan):lgtv --ssl auth [TV_IP] lgtv
This will display a pairing request on your TV. Accept it using your TV remote.
-
Set the default TV:
lgtv setDefault lgtv
Run the script:
./lgThe script will present a menu with various options:
- Power Controls - Turn the TV on/off or control the screen power
- Volume Controls - Adjust volume or set a specific level
- Media Controls - Play, pause, or rewind media
- Set Input - Select an input source (HDMI, etc.)
- Open URL - Open a URL in the TV's browser (or YouTube app for YouTube URLs)
- Start App - Launch an app installed on the TV
- Send Notification - Display a notification message on the TV
Navigate through the menus using the arrow keys and press Enter to select an option.
- Select "Power Controls" from the main menu
- Select "TV Power"
- Choose "Turn TV On" or "Turn TV Off"
- Select "Set Input" from the main menu
- Choose from the list of available inputs (e.g., "HDMI 1", "HDMI 2")
- Select "Open URL" from the main menu
- Enter a YouTube URL (e.g.,
https://www.youtube.com/watch?v=dQw4w9WgXcQ)
- Select "Start App" from the main menu
- Choose from the list of installed apps
- TV Not Found: Make sure your TV is turned on and connected to the same network as your computer.
- Authentication Failed: Try running the auth command again and make sure to accept the pairing request on your TV.
- Command Failed: Check the error message displayed in the dialog box. It might indicate a connection issue or an invalid command.
- JSON Parsing Error: This usually indicates that the TV is unreachable or the response format has changed.
If you encounter persistent issues, try restarting both your TV and the script.
This script is provided as-is with no warranty. Feel free to modify and distribute it according to your needs.