This script allows you to remotely control Roku devices on your local network using bash. It provides functions to send keypresses, launch apps, and perform other Roku remote actions, such as volume control, text input, and scanning for devices.
Script requires ECP commands enabled, these can be set like so:
Settings -> System -> Advanced System Settings -> "Control by mobile apps" -> Set to "Enabled"
- Automatically discovers Roku devices on your network.
- Send remote control keypresses (e.g., navigation, play/pause, volume control).
- Launch apps installed on your Roku device.
- Easily switch between multiple Roku devices.
- Text input functionality to send characters or strings to the Roku device.
Before running this script, ensure you have the following utilities installed:
- nmap
- curl
- sed
- grep
- ifconfig
- awk
- dd
- (Optional) xmlstarlet for XML parsing (currently not used).
On most systems, you can install the dependencies with the following commands:
Ubuntu/Debian:
sudo apt update sudo apt install nmap curl sed grep net-tools gawk coreutilsmacOS (with Homebrew):
brew install nmap curl gawk coreutils- Make the script executable:
chmod +x roku.sh- Add the script to your system's PATH (optional): You can create a symbolic link to make it easier to run the script from anywhere:
sudo ln -s /path/to/roku.sh /usr/local/bin/roku
roku- Run the script:
./roku.sh-
Select a Roku device: The script will scan for Roku devices on your network. If any are found, you will be prompted to select a device.
-
Control the Roku: Once a device is selected, you can use the following commands to control the Roku device:
- Arrow Keys: Navigate
- Enter or
e: Select - Space: Play/Pause
p: Power toggle+or=: Volume Up-: Volume Downm: Muter: Rewindf: Fast Forwarda: List installed appst: Send text inputd: Switch to a different Roku devicexorq: Exit
- App Shortcuts: Quick launch popular apps using number keys.
1: Plex2ory: YouTube3orn: Netflix4: Max5: Apple TV
- Launching Apps:
You can launch apps on the selected Roku by typing their corresponding key after listing apps (
acommand).
The script uses a configuration file roku_config.txt to remember the last selected device and save its details. When a device is selected, its IP and name are stored, making it easy to reconnect to the same device on future runs.
- The script assumes the Roku device uses port 8060 for communication (default for Roku devices).
- The device must be on the same local network for it to be discovered.
- Some apps may not generate a unique key for launching due to name conflicts or special characters.
- If no Roku devices are found, ensure your device is powered on and connected to the same network.
- Ensure the required dependencies are installed and available in your system's PATH.
Enjoy your new Roku remote control! If you encounter any issues, feel free to check the script's error messages for guidance on missing dependencies or unreachable devices.