Repository: pwr-Solaar/Solaar

Issue:
swap Fx function incorrect after k750 is turned off/on, or intermittently 
first of all thanks for this tool, very helpful.

on the k750, when the 'swap Fx function' is set, it seems to work fine until i turn the keyboard off/on, then the toggle button in Solaar stays set 'ON' but the Fx keys no longer are switched > pressing F11 toggles full-screen instead of rising the volume. This also seems to happen occasionally without reason, not sure if it has to do with power management or there is another reason. This is particularly stressful on my setup as the Fx-F12 key is set to switch between soundcard outputs. then the above mentioned bug happens, i press F12 and the computer goes to sleep instead of the expected switching of sound output :D 

next, when i try to re-enable the 'swap Fx funcion' switch, i run into bug  #252 and need to restart Solaar.



Discussion:
is nobody experiencing this behavior ? i should have mentioned that this happens on Fedora23 with GNOME 3.18. Very annoying that this setting isn't permanent

@corebots ,

Could you please use latest master commit and try again? If it still happens, could please post debug output?

Thanks.
Hello I've sold the k750 recently and have acquired a k800. I don't use the SwapFx function anymore but I shell test it to see how it works with this keyboard yet. Will let you know. 
It might be worth to note that on the k800 the function keys in F24 also stop working intermittently, but that shouldn't be Solaar related. Thanks for following up btw.
@corebots,

Where you able to try it?

Thanks.
There have been quite a few changes to solaar over the past few years so this issue may have already been addressed. If you are still using solaar and this issue has not been resolved please download and run the current version from this github repository. If the problem still persists add a new comment here, providing the output of `solaar -V` and `solaar show` and any new information about the issue.

If you are still running solaar you should be able to download and run its current version (in Linux) as follows:

1. Install git on your machine if it is not already installed. This is generally done via `sudo apt install git` or `sudo dnf install git`
2. Change to a directory where you want the code.
3. Download solaar via `git clone https://github.com/pwr-Solaar/Solaar.git`
4. Run solaar via `Solaar/bin/solaar`

For more information on installing solaar from github see https://github.com/pwr-Solaar/Solaar/blob/master/docs/installation.md

I don't have this precise behaviour when the keyboard is turned on/off, but I indeed experience this intermittently, or after my session awakes from suspend-mode. I have K780, and Ubuntu 20.04 LTS.
This looks as if your keyboard is not correctly set up by Solaar when the keyboard reconnects.  To diagnose you will have to run with `-dd` and provide the output from when your system wakes up.

Resolving patch:
diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py
--- a/lib/logitech_receiver/status.py
+++ b/lib/logitech_receiver/status.py
@@ -20,6 +20,7 @@
 from __future__ import absolute_import, division, print_function, unicode_literals
 
 from logging import DEBUG as _DEBUG
+from logging import INFO as _INFO
 from logging import getLogger
 from time import time as _timestamp
 
@@ -303,8 +304,8 @@ def changed(self, active=None, alert=ALERT.NONE, reason=None, timestamp=None):
 
                     # Devices lose configuration when they are turned off,
                     # make sure they're up-to-date.
-                    if _log.isEnabledFor(_DEBUG):
-                        _log.debug('%s pushing device settings %s', d, d.settings)
+                    if _log.isEnabledFor(_INFO):
+                        _log.info('%s pushing device settings %s', d, d.settings)
                     for s in d.settings:
                         s.apply()
 
diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py
--- a/lib/solaar/listener.py
+++ b/lib/solaar/listener.py
@@ -323,11 +323,14 @@ def stop_all():
 # after a resume, the device may have been off
 # so mark its saved status to ensure that the status is pushed to the device when it comes back
 def ping_all(resuming=False):
+    if _log.isEnabledFor(_INFO):
+        _log.info('ping all devices%s', ' when resuming' if resuming else '')
     for l in _all_listeners.values():
         if l.receiver.isDevice:
             if resuming:
                 l.receiver.status._active = False
-            l.receiver.ping()
+            if l.receiver.ping():
+                l.receiver.status.changed(active=True)
             l._status_changed(l.receiver)
         else:
             count = l.receiver.count()
@@ -335,7 +338,8 @@ def ping_all(resuming=False):
                 for dev in l.receiver:
                     if resuming:
                         dev.status._active = False
-                    dev.ping()
+                    if dev.ping():
+                        dev.status.changed(active=True)
                     l._status_changed(dev)
                     count -= 1
                     if not count:


Test patch: