pwr-Solaar / Solaar

Linux device manager for Logitech devices
https://pwr-solaar.github.io/Solaar
GNU General Public License v2.0
5.18k stars 397 forks source link

Turning off a host makes diverted host change keys unusable #1727

Closed jeblad closed 1 year ago

jeblad commented 1 year ago

Information

If a Host Switch Channel on a device (keyboard) is diverted to local rule handling on a host that goes dead, typically by turning it off, then the device can't be switched to another host. The diverted state stays, it is set in the device, while the rule that should handle the keypress goes away, as it is done in the now dead host.

MX Keys detects the current host goes offline and switches to the first host that is online. The MX Anywhere are not able to handle the situation and just hangs on the dead host. A previous keyboard had an awfully long timeout when the host went dead. Haven't tested MX Mech mini, as I have only one Bolt dongle. I believe the M590 mouse switched after a rather short timeout.

Somehow the troublesome diverted key should be reset at shutdown. That to could be cumbersome as it is not given that solaar is still running. A simple solution could be to have a "shutdown" conditional that is triggered by a signal (i.e. SIGTERM). As signals are often abused it is not a given that this gives a good or even workable solution.

In this particular case it is not critical to me, because the MX Anywhere mouse has accessible buttons underneath to manually switch the host.

pfps commented 1 year ago

What could be done is to reset active devices when Solaar is terminated or the machine is suspending provided the device has a reset feature. This would mean, however, that it would not be possible to use the Solaar GUI to modify the state of a device and have that modification persist when Solaar stops. But this is rather a silly thing to do in the GUI.

jeblad commented 1 year ago

I only observe the problem, I don't have any good solution.

jeblad commented 1 year ago

Just wondering, … The #1732 change, it seems like it resets the devices when solaar exits? I believe it is common to use solaar to set some config and then terminate the program. Would this change block such use cases? Perhaps this is a kind of behavior that should be explicitly set?

(Note that for my purpose it is good enough to reset the device when solaar is terminated, but I'm not sure that would be the general case. I'm not sure what would be the general case at all…)

pfps commented 1 year ago

If the Solaar GUI is run it should be run all the time. If a device is disconnected its state may not persist and Solaar has to be running to reestablish the desired state.

The Solaar CLI also can be used to change device state but to keep device state requires some sort of scripting so that the commands are rerun when required.

jeblad commented 1 year ago

I wonder whether users have just adapted the use of solaar from learned behavior from the Gnome Settings editor (not sure what is the real name of this app) and/or Gnome Tweak. Perhaps it should be written out somewhere that the program manipulate states, and that such states could become inconsistent if the program is terminated early.

This is a kind of information that is probably pretty obvious for the developers, but it is not obvious for the casual user.

pfps commented 1 year ago

PR #1736 adds wording to the documentation saying that Solaar should be run continuously.

pfps commented 1 year ago

I just realized that PR #1732 is not a good idea as it will undo the high-resolution scrolling that is used by the Linux input system. The resolution of this issue will be to list it in the known issues.