Last active
October 18, 2024 15:19
-
-
Save alimbada/cfc47de8a1fa8a7c68bf760f5499fdbc to your computer and use it in GitHub Desktop.
Configure the TV input type to "PC" using LGWebOSRemote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
TODO: set up a Hammerspoon script to run this automatically when HDMI is connected to the Macbook.
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
This requires https://github.com/klattimer/LGWebOSRemote (latest as of Jan 2024)