Эта процедура позволяет заменять одну или обе кнопки Netflix и Amazon пульта дистанционного управления Magic на другие приложения или меню управления телевизором LG TV с webOS.
Предполагается, что для этой процедуры вы соглашаетесь удалить приложения, связанные с заменяемыми ключами. Пример: если вы хотите заменить ключ Netflix, вам необходимо удалить Netflix (возможно, вы не используете Netflix, если вам не нужен такой ключ).
Далее рецепт на английском, исходник здесь.
Replacing Netflix and Amazon keys of the webOS LG TV LG Magic Remote with other apps
This procedure allows substituting one or both Netflix and Amazon keys of the Magic Remote Control Unit with other apps or TV control menus of the webOS LG TV.
Netflix and Amazon keys can be found just over the Red-Green-Yellow-Blue color buttons of such remote.
Assumption for this procedure is that you accept to uninstall the apps related to the keys to be substituted. Example: if you want to replace the Netflix key, you need to uninstall Netflix (possibly, you are not using Netflix if you do not need such key).
To uninstall Netflix or Amazon Prime, press the Home key of the Magic Remote, select the "LG Content Store" app, press "APP" at the top of the screen, press "My Apps", press the "Remove" button at the top-right corner and select the apps you want to remove.
Also, you need to setup your LG TV in developer mode. If the service you need to start is a webOS App that you already can recompile, simply change its "id" in appinfo.json. Otherwise, you have to install specific webOS apps that launch the features that you need to activate by pressing the keys. The following steps help to setup the environment, develop the launcher apps, compile and install them on the TV.
Follow the instructions in App Testing page to:
- Prepare a LG developer site login account
- Install the Developer mode app on the TV from the LG Content Store
- Turn Developer mode on with the "Developer mode" app (by logging in and setting related options)
- Connect the PC to the TV with CLI via the webOS TV CLI (IDE is not necessary)
Follow Deploying a Web App page to get acquainted with the CLI usage.
At the end of the previous steps, open the "webOS TV CLI" app on your PC. The following procedure is tested with Windows 10. The apps are tested on webOS TV release 4.1.4, API 4.1.0.
To connect to your TV, you might want to get your passphrase; this can be done through the "Developer mode" app on the TV or with the following command:
- Код: Выделить всё
ares-setup-device -listfull | findstr "passphrase"
Notice that the passphrase is case sensitive.
With the following command, check the configured name of your TV device (deviceinfo: prisoner@...):
- Код: Выделить всё
ares-setup-device -list
this is the same as:
- Код: Выделить всё
ares-device-info --device-list
The output should be:
- Код: Выделить всё
namedeviceinfoconnectionprofile----------------------------------------------------oledprisoner@<ip address>:9922sshtvemulatordeveloper@<ip address>:6622sshtv
We suppose that the label used to reach your TV is "oled".
Check proper connection by retrieving the system information of your TV:
- Код: Выделить всё
ares-device-info --device oled
You need to have developer mode active to connect (run the "Developer Mode" app and check that Dev Mode Status is ON). Also check your IP address. If it needs to be changed, run ares-setup-device and modify your TV configuration (oled).
First you need to discover the App ID of the applications you need to connect to the keys. Run the app you want to start. The following command allows to discover most of the appIds running on your TV.
- Код: Выделить всё
ares-novacom --device oled --run "ps -ef|sed -n '/sed -n/d;/appId/{s/.*appId.:\([^,]*\).*/\1/;p;}'"
After discovering the ID, use the command ares-launch --device oled <appid> to test launching the app from your PC.
Here are some app ID that you can check:
- Код: Выделить всё
ares-launch --device oled com.webos.app.livetvares-launch --device oled com.webos.app.hdmi1ares-launch --device oled com.palm.app.settingsares-launch --device oled com.webos.app.browserares-launch --device oled com.webos.app.photovideoares-launch --device oled com.webos.app.discoveryares-launch --device oled com.webos.app.connectionwizardares-launch --device oled com.webos.app.miracastares-launch --device oled com.webos.app.notificationcenterares-launch --device oled com.webos.app.tvuserguideares-launch --device oled com.webos.app.schedulerares-launch --device oled com.webos.app.channelsettingares-launch --device oled spotify-beehiveares-launch --device oled amazonares-launch --device oled netflix
Notice that the last two ones, amazon and netflix, should not be installed.
There are configuration files like this one in webOS, that are references for the OS action of WebOS.Key_webOS_Netflix and WebOS.Key_webOS_Amazon keys, that by default run appId = "netflix" and appId = "amazon" respectively. Check this for instance:
- Код: Выделить всё
ares-novacom --device oled --run "cat /usr/lib/qt5/qml/KeyFilters/appLaunch.js"|clip
The previous command copies the file to the clipboard. Paste it to an editor (e.g., Notepad++) to inspect the file. All OS files are readonly and cannot be changed. Anyway, if amazon and netflix apps are not installed, the related appIds can be resused by app launchers.
Let us consider you want to substitute netflix with youtube, so that when pressing the netflix key, youtube is launched.
Test launching Youtube from your PC:
- Код: Выделить всё
ares-launch --device oled youtube.leanback.v4
You can discover "youtube.leanback.v4" appId with the previously described method.
Now we need to create the launcher app. Read Build Your First App for webOS TV to understand how to create an app using the CLI.
Change directory to your local development path (let us consider Downloads for instance):
- Код: Выделить всё
cd %HOMEPATH%\Downloads
Use ares-generate to create the basic Web App template for webOS TV. Let us call it "launcher". We need to set the custom property id to the name of the key. netflix in our case. Title should be set to a description name related to the launched app:
- Код: Выделить всё
ares-generate -t basic -p "id=netflix" -p "title=YouTube App Launcher with the Netflix key" -p "vendor=open source" -p "transparent=true" launcher
The previous command creates the launcher directory, including a working source.
Edit appinfo.json in the launcher directory and remove the double quotes from the true value of transparent parameter, so that it is set as follows:
- Код: Выделить всё
"transparent": true
Other App Metadata can be optionally set, but are not strictly necessary.
Replace the index.html file in the launcher directory with the following:
- Код: Выделить всё
<!DOCTYPE html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=1920, user-scalable=no"><script src="webOSTVjs-1.2.0/webOSTV.js" charset="utf-8"></script><script src="webOSTVjs-1.2.0/webOSTV-dev.js" charset="utf-8"></script><script type="text/javascript">(function() {/ Launching app without parametervar request = webOS.service.request("luna:/com.webos.applicationManager", {method: "launch",parameters: { "id": "youtube.leanback.v4" },onSuccess(response) {window.close();},onFailure(error) {window.close();},});})();</script></head><body></body></html>
We use the webOS.service.request LS2 API to call a webOS Service from the Web App, including the appropriate URI (e.g., luna:/com.webos.applicationManager), method (launch), parameters ({ "id": "<appId>" }) and setting up callbacks to close the application.
The id parameter in the javascript shall be assigned to the feature or the app to launch; in our case, YouTube is youtube.leanback.v4:
- Код: Выделить всё
parameters: { "id": "youtube.leanback.v4" },
Create a package with the name of the original ID (in our case, netflix):
- Код: Выделить всё
ares-package launcher
The local directory will include a file named with the original ID of the application, followed by the version and "_all.ipk" (netflix_0.0.1_all.ipk in our case).
Install the created app to the TV:
- Код: Выделить всё
ares-install --device oled netflix_0.0.1_all.ipk
Done.
Note. Connecting your TV via SSH is not needed. In case you have SSH installed and you want to test it, use the following command:
- Код: Выделить всё
ssh -i %HOMEPATH%\.ssh\oled_webos prisoner@<ip address> -p 9922 "/bin/bash -i"
Custom installed applications are stored in folder /media/developer/apps/usr/palm/applications/. Files can be edited online.
Notice that luna-send is protected and luna-send-pub should be used instead:
- Код: Выделить всё
# Get TV data:luna-send-pub -n 1 -f luna:/com.palm.systemservice/osInfo/query '{ "subscribe": false }'cat /var/run/nyx/device_info.jsoncat /var/run/nyx/os_info.json# Start YouTube applicationluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{ "id": "youtube.leanback.v4" }'# Run Netflix applicationluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "netflix", "params":{}}'# Welcome popup luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.mystarter", "params": {}}'# Configuration menu:luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.palm.app.settings", "params": {"target":"picture"}}'luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.palm.app.settings", "params": {"target":"sound"}}'luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.palm.app.settings", "params": {"target":"channel"}}'luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.palm.app.settings", "params": {"target":"network"}}'luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.palm.app.settings", "params": {"target":"general"}}'luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.palm.app.settings", "params": {"target":"accessibility"}}'# Show TV User Guide:luna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.tvuserguide"}'# Switch to TVluna-send-pub -n 1 "luna:/com.webos.applicationManager/launch" '{ "id": "com.webos.app.livetv" }'# Toggle TV/Radioluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.livetv", "params": {"id":"tvKey"}}'# Subtitle menuluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.tvhotkey", "params": {"activateType":"subtitle"}}'# Multi-sound menuluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.tvhotkey", "params": {"activateType":"multi-sound-setting"}}'# Audio-descriptionluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.tvhotkey", "params": {"activateType":"audio-description"}}'# Channel menuluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.livemenu", "params": {"activateType":"channels"}}'# Virtual keyboard Searchluna-send-pub -n 1 -f "luna:/com.webos.applicationManager/launch" '{"id": "com.webos.app.voice", "params": {"activateType":"mrcu", "launchMode":"vkb"}}'# listing launch points is not allowed:luna-send-pub -n 1 "luna:/com.palm.applicationManager/listLaunchPoints" "{}"# Also, closing an application or getting app info is denied:luna-send-pub -n 1 -f "luna:/com.webos.service.applicationmanager/closeByAppId" '{"id":"youtube.leanback.v4"}'luna-send-pub -n 1 -f "luna:/com.webos.service.applicationmanager/getAppInfo" '{"id":"youtube.leanback.v4"}'luna-send-pub -n 1 -f "luna:/com.webos.service.applicationmanager/getForegroundAppInfo" '{}'