JPersson77 / LGTVCompanion

Power On and Off WebOS LG TVs together with your PC
MIT License
958 stars 40 forks source link

[OTH] External KVM support / question #244

Open hakamairi opened 22 hours ago

hakamairi commented 22 hours ago

I have the following setup. LG C4 connected to external KVM on HDMI 4, external KVM switches between a PC and a laptop. I've installed and configured LGTVCompanion on both devices.

The issue is that when one goes to sleep after switching then it turns off the TV off as well, the one currently connected is not handling this in any way.

I think it's more or less similar to https://github.com/JPersson77/LGTVCompanion/issues/158 but I'm not quite sure, hence the new issue created.

Is this setup anyhow supported? How could I configure LGTVCompanion to have it working without interruptions?

JPersson77 commented 21 hours ago

Hi,

Yeah it is not straightforward. By default the two apps will send power commands to the TV based on the power state of the PC, regardless of whether the TV is connected via HDMI.

The Multi monitor support option in the app will recognise when a TV is attached/detached from the active desktop and turn the TV on/off respectively, but it's still a conflict between the two apps.

So the most straightforeard way is probably to ensure that automatic management of the TV is only enabled on the laptop or the stationary, exclusively.

This can be done manually, via the gui or a script.

Or it can be done automatically, by having a script running on both PCs to detect the presence of certain usb accessorirs (mouse/keyboard) and/or HDMI devices and toggle automatic management in the app on/off respectively.

Let me know your thoughts

hakamairi commented 20 hours ago

Hi, Thanks for your quick answer. Any examples or pointers how such script would look like? If that works for me I'm happy to share to have it as example for others in the same situation.

JPersson77 commented 19 hours ago

I usually point towards autohotkey scripts but it can be done in other scripting languages ofcourse.

It involves hooking and waiting for a windows message and parsing the results, looking for a specific usb device id, and then send the appropriate command line to lgtv companion to enable/disable automatic management.

Here is a discussion on how to run X when usb device Y is detected as a start

https://www.autohotkey.com/boards/viewtopic.php?t=98931

Edit: more relevant link: https://www.autohotkey.com/boards/viewtopic.php?t=76221

Let me know on how you would like to proceed from here and I can probably help