Skip to content

Instantly share code, notes, and snippets.

@alimbada
Last active October 18, 2024 15:19
Show Gist options
  • Save alimbada/cfc47de8a1fa8a7c68bf760f5499fdbc to your computer and use it in GitHub Desktop.
Save alimbada/cfc47de8a1fa8a7c68bf760f5499fdbc to your computer and use it in GitHub Desktop.
Configure the TV input type to "PC" using LGWebOSRemote
#!/bin/bash
APPID=$(lgtv --name MyTV --ssl getForegroundAppInfo | head -n 1 | python3 -c "import sys, json; print(json.load(sys.stdin)['payload']['appId'])")
lgtv --name MyTV --ssl startApp com.webos.app.homeconnect && sleep 6
lgtv --name MyTV --ssl sendButton up up right enter && sleep 2
lgtv --name MyTV --ssl sendButton enter && sleep 2
# number of `down`s here depends on the input ID; in this case I'm configuring HDMI 3
lgtv --name MyTV --ssl sendButton down down down left enter && sleep 2
lgtv --name MyTV --ssl sendButton down down down down down down down down down enter && sleep 2
# as noted above, number of `up`s here depends on input ID
lgtv --name MyTV --ssl sendButton up up up right enter && sleep 2
lgtv --name MyTV --ssl startApp $APPID
$appid = (lgtv --name MyTV --ssl getForegroundAppInfo | ConvertFrom-Json).payload.appid
lgtv --name MyTV --ssl startApp com.webos.app.homeconnect
Start-Sleep 6
lgtv --name MyTV --ssl sendButton up up right enter
Start-Sleep 2
lgtv --name MyTV --ssl sendButton enter
Start-Sleep 2
lgtv --name MyTV --ssl sendButton down down down left enter
Start-Sleep 2 # number of `down`s here depends on the input ID in this case I'm configuring HDMI 3
lgtv --name MyTV --ssl sendButton down down down down down down down down down enter
Start-Sleep 2
lgtv --name MyTV --ssl sendButton up up up right enter
Start-Sleep 2 # as noted above, number of `up`s here depends on input ID
lgtv --name MyTV --ssl startApp $appid
@alimbada
Copy link
Author

alimbada commented Oct 18, 2024

Linux/macOS version moved to dotfiles repo with better error handling. See https://github.com/alimbada/dotfiles/blob/macos/bin/configure-tv-input.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment