LG WebOS TV and GNU Emacs
Modern LG TVs with WebOS allow remote control via websockets. Since this is a web technology, you might want to automate this using Node JS [1]. However, if you want a fair balance between scripting and interactive use, Emacs will serve you better.
Toast (top right) sent from Emacs |
Completing LG TV commands in Emacs |
Steps
- Install package websocket from ELPA.
M-x package-install RET websocket RET
- Download tv.el and pairing.json
- Load tv.el
M-x load-library RET tv RET
- Ensure variable lgtv--pairing-json is pointing to pairing.json file.
- Run M-x lgtv-command
- Enter a command for LG TV. Use TAB for completion.
- Enter a JSON object for command parameter. Leave empty if the command doesn't require a parameter. (Note: Remember to quote the keys in JSON.)
;; Sample payload passed to TV. You need to provide URI (without ssap://) and payload parts
;; Show toast
{ "id": "0c8b18a10002", "type": "request", "uri": "ssap://system.notifications/createToast","payload": {"message":"TV is being controlled by Emacs"} }
;; Play youtube video. Note - some content might not work
{ "id": "0c8b18a10002", "type": "request", "uri": "ssap://system.launcher/launch","payload": {"contentId":"dQw4w9WgXcQ", "id": "youtube.leanback.v4"} }
Code
https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/tv.el
https://gitlab.com/atamariya/emacs/-/blob/dev/etc/tv/pairing.json
References
Comments
Post a Comment