{"id":18983758,"url":"https://github.com/dechamps/lgtvdevicelistener","last_synced_at":"2025-04-19T20:11:20.704Z","repository":{"id":65543750,"uuid":"480097496","full_name":"dechamps/LGTVDeviceListener","owner":"dechamps","description":"Switch LGTV inputs based on Windows device changes","archived":false,"fork":false,"pushed_at":"2023-01-28T12:48:57.000Z","size":74,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T10:15:33.398Z","etag":null,"topics":["lgtv","remote-control","webos","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dechamps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-10T17:58:40.000Z","updated_at":"2024-02-15T08:43:48.000Z","dependencies_parsed_at":"2023-02-15T16:16:10.204Z","dependency_job_id":null,"html_url":"https://github.com/dechamps/LGTVDeviceListener","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dechamps%2FLGTVDeviceListener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dechamps%2FLGTVDeviceListener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dechamps%2FLGTVDeviceListener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dechamps%2FLGTVDeviceListener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dechamps","download_url":"https://codeload.github.com/dechamps/LGTVDeviceListener/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223713605,"owners_count":17190531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lgtv","remote-control","webos","windows"],"created_at":"2024-11-08T16:18:25.340Z","updated_at":"2024-11-08T16:18:26.096Z","avatar_url":"https://github.com/dechamps.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LGTVDeviceListener: switch LGTV inputs based on Windows device changes\n*Brought to you by [Etienne Dechamps][] - [GitHub][]*\n\n**If you are looking for executables, see the [GitHub releases page][].**\n\n## Description\n\nLGTVDeviceListener is a small Windows tool that makes it possible to switch\ninputs on a networked WebOS LG TV (e.g. G1), in response to a hardware device\nappearing or disappearing from the system.\n\nThis is especially useful to build a poor man's [KVM switch][], by combining\nLGTVDeviceListener with a USB switch. In this way the TV can be made to follow\nthe presence of the USB device and automatically switch video inputs in lockstep\nwhen the USB device is switched.\n\n## Requirements\n\n- Windows Vista or greater\n- A WebOS LG TV that is accessible over the network (wired or WiFi)\n\n## How to use\n\nLGTVDeviceListener is a command-line application. Pass `--help` to see all\navailable options.\n\n### Preparation\n\nAfter downloading the executable, run it with `--url` first. For example, if\nyour TV is listening on `192.168.42.42`:\n\n```\nLGTVDeviceListener.exe --url wss://192.168.42.42:3001\n```\n\nThis will do two things:\n\n1. A new client key will be registered with the TV if not done already. Your TV\n   will ask you to confirm the registration.\n2. LGTVDeviceListener will then start listening for device events and log them\n   to the console.\n\nWhile listening, add and remove the device you want to use as the trigger. (For\nexample, if it's a USB device, disconnect/reconnect it.) You will see\nLGTVDeviceListener logging \"Device added\" and \"Device removed\" events. Take a\nnote of the *device name* - the identifier that normally starts with `\\\\?\\`.\n\nIn some cases there could be many devices shown, especially for composite\ndevices such as USB hubs. In that case you can pick one at random, though it\nusually makes the most sense to use the device with the shortest name because\nthat's typically the \"root\" device (i.e. the hub itself in the case of a USB\nhub).\n\nOnce that's done, kill LGTVDeviceListener by hitting CTRL+C and move on to the\nnext step.\n\n### Running as a console application\n\nFor quick test runs you can run LGTVDeviceListener directly as a console\napplication. You will need to specify the following parameters on the command\nline:\n\n- `--url`: see previous section.\n- `--device-name`: the device name you chose in the previous section.\n- `--add-input`: the input that the TV should switch to when the device is\n  *added*.\n  - This can be anything that the TV's `switchInput` API will accept. For\n    example: `HDMI_3`.\n- `--remove-input`: the input that the TV should switch to when the device is\n  *removed*.\n\nNote that you don't have to specify both `--add-input` and `--remove-input` - it\nis possible to specify only one of them.\n\nHere's an example of a complete LGTVDeviceListener command line:\n\n```\nLGTVDeviceListener.exe --url wss://192.168.42.42:3001 --device-name \\\\?\\USB#VID_1234\u0026PID_5678#foo\u00261\u00262#{bar} --add-input HDMI_1 --remove-input HDMI_2\n```\n\nWith the above command, the TV at `192.168.42.42` will be switched to the HDMI 1\ninput when the `\\\\?\\USB#VID_1234\u0026PID_5678#foo\u00261\u00262#{bar}` device appears, and\nwill be switched to the HDMI 2 input as soon as the same device disappears from\nthe system.\n\nThis will happen for as long as LGTVDeviceListener is running. If you'd like to\nmake this setup permanent, see the next section.\n\n### Running as a Windows service\n\nIf you'd like LGTVDeviceListener to run quietly in the background without having\nto run it as a console application, the cleanest way is to set it up as a\nWindows service:\n\n1. Move `LGTVDeviceListener.exe` to a permanent location that is accessible\n   system-wide (e.g. in `Program Files (x86)`).\n2. Open a command prompt as Administrator.\n3. Run LGTVDeviceListener using the same command you used in the previous\n   section, but add the `--create-service` option.\n\nFor example:\n\n```\nLGTVDeviceListener.exe --url wss://192.168.42.42:3001 --device-name \\\\?\\USB#VID_1234\u0026PID_5678#foo\u00261\u00262#{bar} --add-input HDMI_1 --remove-input HDMI_2 --create-service\n```\n\nLGTVDeviceListener will set itself up as a new Windows service called\n`LGTVDeviceListener` and start it. From this point on, LGTVDeviceListener will\nbe operating silently in the background and will start with Windows. The\nparameters used for the service are the ones you included with the\n`--create-service` command.\n\nWhen running as a service, messages that are normally logged to the console,\nincluding any errors, will be logged to the Windows Event Log (*Application*)\ninstead. You can use the Windows Event Viewer to see them.\n\nTo delete the service, run the following commands:\n\n```\nsc.exe stop LGTVDeviceListener\nsc.exe delete LGTVDeviceListener\n```\n\nYou can then re-create the service with different command-line parameters if you\nso wish.\n\n## See also\n\n- [LGTVCompanion][] is a tool for automatically turning LG TVs on and off in\n  response to Windows power events.\n- [bscpylgtv][] can be used to send arbitrary commands to LG TVs.\n\n[bscpylgtv]: https://github.com/chros73/bscpylgtv\n[Etienne Dechamps]: mailto:etienne@edechamps.fr\n[GitHub]: https://github.com/dechamps/LGTVDeviceListener\n[GitHub releases page]: https://github.com/dechamps/LGTVDeviceListener/releases\n[KVM switch]: https://en.wikipedia.org/wiki/KVM_switch\n[LGTVCompanion]: https://github.com/JPersson77/LGTVCompanion\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdechamps%2Flgtvdevicelistener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdechamps%2Flgtvdevicelistener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdechamps%2Flgtvdevicelistener/lists"}