Repository: pwr-Solaar/Solaar

Issue:
Settings not re-applied after sleep/power-on cycle.
**Information**
- Solaar version (`solaar --version` or `git describe --tags` if cloned from this repository): 1.0.5-17-g6ed09d06
- Distribution: Fedora 33
- Kernel version (ex. `uname -srmo`): Linux 5.10.23-200.fc33.x86_64 x86_64 GNU/Linux
- Output of `solaar show`:

<details>

```
Unifying Receiver
  Device path  : /dev/hidraw2
  USB id       : 046d:C52B
  Serial       : 71ED9940
    Firmware   : 24.11.B0036
    Bootloader : 02.09
    Other      : AA.AC
  Has 1 paired device(s) out of a maximum of 6.
  Notifications: wireless, software present (0x000900)
  Device activity counters: 1=25

  1: MX Anywhere 3
     Device path  : /dev/hidraw3
     WPID         : 4090
     Codename     : MX Anywhere 3
     Kind         : mouse
     Protocol     : HID++ 4.5
     Polling rate : 8 ms (125Hz)
     Serial number: 558DB02C
     Model ID:      B02540900000
     Unit ID:       558DB02C
        Bootloader: BL1 13.00.B0014
          Firmware: MPM 24.00.B0014
             Other: 
     The power switch is located on the base.
     Supports 32 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
            Firmware: Bootloader BL1 13.00.B0014 000095D7D19A
            Firmware: Firmware MPM 24.00.B0014 409095D7D19A
            Firmware: Other   
            Unit ID: 558DB02C  Model ID: B02540900000  Transport IDs: {'btleid': 'B025', 'wpid': '4090'}
         3: DEVICE NAME            {0005}   
            Name: MX Anywhere 3
            Kind: mouse
         4: WIRELESS DEVICE STATUS {1D4B}   
         5: RESET                  {0020}   
         6: CRYPTO ID              {0021}   
         7: DEVICE FRIENDLY NAME   {0007}   
         8: UNIFIED BATTERY        {1004}   
         9: REPROG CONTROLS V4     {1B04}   
            Key/Button Actions (saved): {'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86}
            Key/Button Actions        : {'80': 80, '81': 81, '82': 196, '83': 83, '86': 86, '196': 82}
            Key/Button Diversion (saved): {'196': 0, '215': 0, '82': 0, '83': 1, '86': 1}
            Key/Button Diversion        : {'82': 0, '83': 1, '86': 1, '196': 0, '215': 0}
        10: CHANGE HOST            {1814}   
            Change Host        : 1:dog
        11: XY STATS               {2250}   
        12: ADJUSTABLE DPI         {2201}   
            Sensitivity (DPI) (saved): 1150
            Sensitivity (DPI)        : 1150
        13: SMART SHIFT ENHANCED   {2111}   
            Scroll Wheel Rachet (saved): 50
            Scroll Wheel Rachet        : 50
        14: HIRES WHEEL            {2121}   
            Multiplier: 15
            Has invert: Normal wheel motion
            Has ratchet switch: Normal wheel mode
            Low resolution mode
            HID notification
            Scroll Wheel Direction (saved): False
            Scroll Wheel Direction        : False
            Scroll Wheel Resolution (saved): False
            Scroll Wheel Resolution        : False
        15: WHEEL STATS            {2251}   
        16: DFUCONTROL SIGNED      {00C2}   
        17: DEVICE RESET           {1802}   internal, hidden
        18: unknown:1803           {1803}   internal, hidden
        19: CONFIG DEVICE PROPS    {1806}   internal, hidden
        20: unknown:1812           {1812}   internal, hidden
        21: OOBSTATE               {1805}   internal, hidden
        22: unknown:1830           {1830}   internal, hidden
        23: unknown:1890           {1890}   internal, hidden
        24: unknown:1891           {1891}   internal, hidden
        25: unknown:18A1           {18A1}   internal, hidden
        26: unknown:1E00           {1E00}   hidden
        27: unknown:1EB0           {1EB0}   internal, hidden
        28: unknown:1861           {1861}   internal, hidden
        29: unknown:9001           {9001}   internal, hidden
        30: unknown:9205           {9205}   internal, hidden
        31: unknown:9300           {9300}   internal, hidden
     Has 7 reprogrammable keys:
         0: Left Button               , default: Left Click                  => Left Click                
             mse, analytics key events, pos:0, group:1, group mask:g1
             reporting: default
         1: Right Button              , default: Right Click                 => Right Click               
             mse, analytics key events, pos:0, group:1, group mask:g1
             reporting: default
         2: Middle Button             , default: Mouse Middle Button         => Smart Shift               
             mse, reprogrammable, divertable, raw XY, analytics key events, pos:0, group:2, group mask:g1,g2
             reporting: default
         3: Back Button               , default: Mouse Back Button           => Mouse Back Button         
             mse, reprogrammable, divertable, raw XY, analytics key events, unknown:000800, pos:0, group:2, group mask:g1,g2
             reporting: diverted
         4: Forward Button            , default: Mouse Forward Button        => Mouse Forward Button      
             mse, reprogrammable, divertable, raw XY, analytics key events, unknown:000800, pos:0, group:2, group mask:g1,g2
             reporting: diverted
         5: Smart Shift               , default: Smart Shift                 => Mouse Middle Button       
             mse, reprogrammable, divertable, raw XY, analytics key events, pos:0, group:2, group mask:g1,g2
             reporting: default
         6: Virtual Gesture Button    , default: Virtual Gesture Button      => Virtual Gesture Button    
             divertable, virtual, raw XY, force raw XY, pos:0, group:3, group mask:empty
             reporting: default
     Battery: 90%, discharging.
```
</details>

**Describe the bug**
When the device sleeps then wakes, settings are not re-applied.

**To Reproduce**
Steps to reproduce the behavior:
1. Setup various settings, eg. button modifications.
2. Either wait until device sleeps, or just power off and on again which has the same effect.
3. Settings are not applied.
4. Currently need to restart solaar.


Discussion:
This may be the same as issue #1102 
Nonetheless, your proposed change might be reasonable.   
Should it be possible for me to properly link the PR?
I'm not sure what you were trying to do, but just entering the number of the PR preceeded by # should insert a link.
Can you run as `bin/solaar -d` and post the output when you turn your mouse off and on.  The output should look something like:

```
09:05:20,564     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,728240) for <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)> (mouse)
09:05:20,564     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 3 paired devices. (0) 
09:05:20,566     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: paired offline, {'BATTERY LEVEL': 100} (0) disconnected
09:05:20,566     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: DJ connection: False Notification(20,1,42,01,0000000000000000000000)
09:05:20,567     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: paired offline, {'BATTERY LEVEL': 100} (0) disconnected
09:05:21,534     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,B28240) for <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)> (mouse)
09:05:21,534     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 3 paired devices. (0) 
09:05:21,536     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)> pushing device settings [<Setting([feature:toggle] MX Master 3:hires-smooth-invert=False)>, <Setting([feature:toggle] MX Master 3:hires-smooth-resolution=True)>, <Setting([feature:range] MX Master 3:smart-shift=23)>, <Setting([feature:toggle] MX Master 3:thumb-scroll-mode=False)>, <Setting([feature:toggle] MX Master 3:thumb-scroll-invert=False)>, <Setting([feature:choice] MX Master 3:dpi=1000)>, <Setting([feature:map choice] MX Master 3:reprogrammable-keys={'195': 195, '196': 196, '80': 80, '81': 81, '82': 82, '83': 83, '86': 86})>, <Setting([feature:map choice] MX Master 3:divert-keys={'195': 1, '196': 0, '215': 0, '82': 0, '83': 0, '86': 0})>, <Setting([feature:choice] MX Master 3:change-host=1:idefix)>]
09:05:22,076     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: paired online, {'BATTERY LEVEL': 100, 'LINK ENCRYPTED': True, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': 50, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
09:05:22,076     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: paired online, {'BATTERY LEVEL': 100, 'LINK ENCRYPTED': True, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': 50, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) connected
09:05:22,076     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: DJ connection: True Notification(20,1,42,00,0000000000000000000000)
09:05:22,077     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: paired online, {'BATTERY LEVEL': 100, 'LINK ENCRYPTED': True, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': 50, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) connected
09:05:22,100     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: paired online, {'BATTERY LEVEL': 100, 'LINK ENCRYPTED': True, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': 50, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (1) powered on
09:05:22,101     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4082,MX Master 3 Wireless Mouse,198E3EB8)>: spurious BATTERY status Notification(11,1,08,10,0404C078050000000000000000000000)
```

The important line is the one with "pushing device settings".   That says that Solaar is reapplying device settings.
I did see before making the changes that it logs that message, but the settings were not being applied.
From what I could tell it was due to when the device goes to sleep no notification is raised so solaar things it's was already active before powering on again.
```
14:11:19,779     INFO [MainThread] root: language en_GB (UTF-8), translations path None
14:11:19,969     INFO [MainThread] logitech_receiver.diversion: load rule: Rule(/home/tjones/.config/solaar/rules.yaml)[Rule[Key: Forward Button, Execute: playerctl play-pause], Rule[Key: Back Button, Execute: xdotool set_desktop --relative 1]]
14:11:19,970     INFO [MainThread] logitech_receiver.diversion: loaded 1 rules from /home/tjones/.config/solaar/rules.yaml
14:11:19,987     INFO [MainThread] solaar.upower: connected to system dbus, watching for suspend/resume events
14:11:20,054     INFO [MainThread] solaar.ui.notify: starting desktop notifications
14:11:20,141     INFO [MainThread] solaar.listener: starting receiver listening threads
14:11:20,149     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw2', vendor_id='046D', product_id='C52B', serial='', release=None, manufacturer=None, product=None, interface=2, driver='logitech-djreceiver', bus_id=3, isDevice=None)
14:11:20,160     INFO [ReceiverListener:hidraw2] logitech_receiver.listener: started with <UnifyingReceiver(/dev/hidraw2,18)> (18)
14:11:20,160     INFO [ReceiverListener:hidraw2] solaar.listener: <UnifyingReceiver(/dev/hidraw2,18)>: notifications listener has started (18)
14:11:20,168     INFO [ReceiverListener:hidraw2] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw2,18)>: receiver notifications enabled => ('wireless', 'software present')
14:11:20,174     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, No paired devices. (0) 
14:11:20,184     INFO [ReceiverListener:hidraw2] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw2,18)>: found new device 1 (4090)
14:11:20,184     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,129040) for <Device(1,4090,MX Anywhere 3,558DB02C)> (mouse)
14:11:20,406     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 1 paired device. (0) 
14:11:21,120     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(1,4090,MX Anywhere 3,558DB02C)> pushing device settings [<Setting([feature:toggle] MX Anywhere 3:hires-smooth-invert=None)>, <Setting([feature:toggle] MX Anywhere 3:hires-smooth-resolution=None)>, <Setting([feature:range] MX Anywhere 3:smart-shift=None)>, <Setting([feature:choice] MX Anywhere 3:dpi=None)>, <Setting([feature:map choice] MX Anywhere 3:reprogrammable-keys=None)>, <Setting([feature:map choice] MX Anywhere 3:divert-keys=None)>, <Setting([feature:choice] MX Anywhere 3:change-host=None)>]
14:11:21,524     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'LINK ENCRYPTED': False, 'BATTERY LEVEL': 90, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:11:21,524     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'LINK ENCRYPTED': False, 'BATTERY LEVEL': 90, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:11:21,544     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: WHEEL: ratchet: 0
14:11:21,544  WARNING [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: unknown WHEEL Notification(11,1,0E,20,00000000000000000000000000000000)
14:11:27,322     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,529040) for <Device(1,4090,MX Anywhere 3,558DB02C)> (mouse)
14:11:27,322     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 1 paired device. (0) 
14:11:27,323     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired offline, {'BATTERY LEVEL': 90} (0) 
14:11:27,324     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: DJ connection: False Notification(20,1,42,01,0000000000000000000000)
14:11:27,324     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired offline, {'BATTERY LEVEL': 90} (0) disconnected
14:11:30,262     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,929040) for <Device(1,4090,MX Anywhere 3,558DB02C)> (mouse)
14:11:30,262     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 1 paired device. (0) 
14:11:30,263     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(1,4090,MX Anywhere 3,558DB02C)> pushing device settings [<Setting([feature:toggle] MX Anywhere 3:hires-smooth-invert=False)>, <Setting([feature:toggle] MX Anywhere 3:hires-smooth-resolution=False)>, <Setting([feature:range] MX Anywhere 3:smart-shift=50)>, <Setting([feature:choice] MX Anywhere 3:dpi=1150)>, <Setting([feature:map choice] MX Anywhere 3:reprogrammable-keys={'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86})>, <Setting([feature:map choice] MX Anywhere 3:divert-keys={'196': 0, '215': 0, '82': 0, '83': 1, '86': 1})>, <Setting([feature:choice] MX Anywhere 3:change-host=1:dog)>]
14:11:30,676     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:11:30,676     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:11:30,677     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: DJ connection: True Notification(20,1,42,00,0000000000000000000000)
14:11:30,677     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) connected
14:11:30,702     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(1,4090,MX Anywhere 3,558DB02C)> pushing device settings [<Setting([feature:toggle] MX Anywhere 3:hires-smooth-invert=False)>, <Setting([feature:toggle] MX Anywhere 3:hires-smooth-resolution=False)>, <Setting([feature:range] MX Anywhere 3:smart-shift=50)>, <Setting([feature:choice] MX Anywhere 3:dpi=1150)>, <Setting([feature:map choice] MX Anywhere 3:reprogrammable-keys={'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86})>, <Setting([feature:map choice] MX Anywhere 3:divert-keys={'196': 0, '215': 0, '82': 0, '83': 1, '86': 1})>, <Setting([feature:choice] MX Anywhere 3:change-host=1:dog)>]
14:11:31,112     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (1) powered on
14:11:31,114     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: WHEEL: ratchet: 0
14:11:31,114     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: WHEEL: ratchet: 0
14:11:31,114  WARNING [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: unknown WHEEL Notification(11,1,0E,20,00000000000000000000000000000000)
14:11:31,115  WARNING [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: unknown WHEEL Notification(11,1,0E,20,00000000000000000000000000000000)
```
Pushing device settings should update all the settings.   There was a bug in Solaar that was addressed by PR #1105.  Please try Solaar from this repository without your patch and see whether the problem is still active.   If so, then there is still some problem in pushing settings, which needs to be further addressed.
@pfps , if you mean the pwr-Solaar master branch, that was what I was using prior to my patch. For me at least, latest master still has this issue.
From master (without my patch), solaar -d logs one less "pushing device settings":
```
14:51:15,788     INFO [MainThread] root: language en_GB (UTF-8), translations path None
14:51:15,979     INFO [MainThread] logitech_receiver.diversion: load rule: Rule(/home/tjones/.config/solaar/rules.yaml)[Rule[Key: Forward Button, Execute: playerctl play-pause], Rule[Key: Back Button, Execute: xdotool set_desktop --relative 1]]
14:51:15,979     INFO [MainThread] logitech_receiver.diversion: loaded 1 rules from /home/tjones/.config/solaar/rules.yaml
14:51:15,996     INFO [MainThread] solaar.upower: connected to system dbus, watching for suspend/resume events
14:51:16,062     INFO [MainThread] solaar.ui.notify: starting desktop notifications
14:51:16,151     INFO [MainThread] solaar.listener: starting receiver listening threads
14:51:16,158     INFO [MainThread] solaar.listener: receiver event add DeviceInfo(path='/dev/hidraw2', vendor_id='046D', product_id='C52B', serial='', release=None, manufacturer=None, product=None, interface=2, driver='logitech-djreceiver', bus_id=3, isDevice=None)
14:51:16,170     INFO [ReceiverListener:hidraw2] logitech_receiver.listener: started with <UnifyingReceiver(/dev/hidraw2,18)> (18)
14:51:16,170     INFO [ReceiverListener:hidraw2] solaar.listener: <UnifyingReceiver(/dev/hidraw2,18)>: notifications listener has started (18)
14:51:16,178     INFO [ReceiverListener:hidraw2] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw2,18)>: receiver notifications enabled => ('wireless', 'software present')
14:51:16,184     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, No paired devices. (0) 
14:51:16,194     INFO [ReceiverListener:hidraw2] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw2,18)>: found new device 1 (4090)
14:51:16,194     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,129040) for <Device(1,4090,MX Anywhere 3,558DB02C)> (mouse)
14:51:17,328     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 1 paired device. (0) 
14:51:18,066     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(1,4090,MX Anywhere 3,558DB02C)> pushing device settings [<Setting([feature:toggle] MX Anywhere 3:hires-smooth-invert=None)>, <Setting([feature:toggle] MX Anywhere 3:hires-smooth-resolution=None)>, <Setting([feature:range] MX Anywhere 3:smart-shift=None)>, <Setting([feature:choice] MX Anywhere 3:dpi=None)>, <Setting([feature:map choice] MX Anywhere 3:reprogrammable-keys=None)>, <Setting([feature:map choice] MX Anywhere 3:divert-keys=None)>, <Setting([feature:choice] MX Anywhere 3:change-host=None)>]
14:51:18,468     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'LINK ENCRYPTED': False, 'BATTERY LEVEL': 90, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:51:18,468     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'LINK ENCRYPTED': False, 'BATTERY LEVEL': 90, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:51:18,488     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: WHEEL: ratchet: 0
14:51:18,488  WARNING [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: unknown WHEEL Notification(11,1,0E,20,00000000000000000000000000000000)
14:51:23,064     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,529040) for <Device(1,4090,MX Anywhere 3,558DB02C)> (mouse)
14:51:23,064     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 1 paired device. (0) 
14:51:23,064     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired offline, {'BATTERY LEVEL': 90} (0) 
14:51:23,066     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: DJ connection: False Notification(20,1,42,01,0000000000000000000000)
14:51:23,066     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired offline, {'BATTERY LEVEL': 90} (0) disconnected
14:51:25,870     INFO [ReceiverListener:hidraw2] solaar.listener: connection Notification(10,1,41,04,929040) for <Device(1,4090,MX Anywhere 3,558DB02C)> (mouse)
14:51:25,870     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <UnifyingReceiver(/dev/hidraw2,18)>: present, 1 paired device. (0) 
14:51:25,871     INFO [ReceiverListener:hidraw2] logitech_receiver.status: <Device(1,4090,MX Anywhere 3,558DB02C)> pushing device settings [<Setting([feature:toggle] MX Anywhere 3:hires-smooth-invert=False)>, <Setting([feature:toggle] MX Anywhere 3:hires-smooth-resolution=False)>, <Setting([feature:range] MX Anywhere 3:smart-shift=50)>, <Setting([feature:choice] MX Anywhere 3:dpi=1150)>, <Setting([feature:map choice] MX Anywhere 3:reprogrammable-keys={'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86})>, <Setting([feature:map choice] MX Anywhere 3:divert-keys={'196': 0, '215': 0, '82': 0, '83': 1, '86': 1})>, <Setting([feature:choice] MX Anywhere 3:change-host=1:dog)>]
14:51:26,290     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:51:26,290     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) 
14:51:26,290     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: DJ connection: True Notification(20,1,42,00,0000000000000000000000)
14:51:26,290     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (0) connected
14:51:26,314     INFO [ReceiverListener:hidraw2] solaar.listener: status_changed <Device(1,4090,MX Anywhere 3,558DB02C)>: paired online, {'BATTERY LEVEL': 90, 'LINK ENCRYPTED': False, 'BATTERY STATUS': NamedInt(0, 'discharging'), 'BATTERY NEXT LEVEL': None, 'BATTERY VOLTAGE': None, 'BATTERY CHARGING': False, 'ERROR': None} (1) powered on
14:51:26,314     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: WHEEL: ratchet: 0
14:51:26,315     INFO [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: WHEEL: ratchet: 0
14:51:26,315  WARNING [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: unknown WHEEL Notification(11,1,0E,20,00000000000000000000000000000000)
14:51:26,315  WARNING [ReceiverListener:hidraw2] logitech_receiver.notifications: <Device(1,4090,MX Anywhere 3,558DB02C)>: unknown WHEEL Notification(11,1,0E,20,00000000000000000000000000000000)
```
Please try with `-dd` and provide output after the first 'pushing device settings' line until the next 'status changed' line.  If you are pushing settings twice then the interactions should look quite similar.
Attaching logs for solaar -dd.

* [solaar.log](https://github.com/pwr-Solaar/Solaar/files/6249844/solaar.log) - with my patch
* [solaar.pwr.log](https://github.com/pwr-Solaar/Solaar/files/6249845/solaar.pwr.log) - master
With your changes the two pushes appear to be pushing the same values.

Which setting is not retained?  All of them or just one?  If just one, is it the scroll wheel resolution?
I also noticed the bug in the debugging statements.  That's being fixed.
The setting I'm most noticing that's not re-applied is the 'Key/Button Actions' ([Smart Shift] -> [Mouse Middle Button]). This is never re-applied on the first settings push. I'm not sure what other settings might be affected at the moment.
I just took a closer look at your log with the patch.  Something strange is going on.   Is there another copy of Solaar running on your computer?   Is there some other software running that might be trying to control your mouse?

<details>

Before first push: line 124.   This is getting the setup for the feature.  All is as expected.  The first interaction asks for how many  reprogrammable keys there are and the next ones ask for the capabilities of each key.

```
15:05:31,390    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 090B 00000000000000000000000000000000]
15:05:31,409    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 090B 07000000000000000000000000000000]
15:05:31,410    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 0919 00000000000000000000000000000000]
15:05:31,429    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0919 00500038010001010400000000000000]
15:05:31,430    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 091D 01000000000000000000000000000000]
15:05:31,457    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 091D 00510039010001010400000000000000]
15:05:31,458    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 091D 02000000000000000000000000000000]
15:05:31,481    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 091D 0052003A310002030500000000000000]
15:05:31,482    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 0919 03000000000000000000000000000000]
15:05:31,505    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0919 0053003C310002030D00000000000000]
15:05:31,506    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 091E 04000000000000000000000000000000]
15:05:31,529    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 091E 0056003E310002030D00000000000000]
15:05:31,530    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 091B 05000000000000000000000000000000]
15:05:31,553    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 091B 00C4009D310002030500000000000000]
15:05:31,554    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 0918 06000000000000000000000000000000]
15:05:31,579    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0918 00D700B4A00003000300000000000000]
15:05:31,580    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings_templates: check_feature[REPROG CONTROLS V4] detected None
```

First push: line 197.  This is pushing your actions.  Five of the keys go to themselves and two are swapped.

```
15:05:32,038    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: apply None (<Device(1,4090,MX Anywhere 3,558DB02C)>)
15:05:32,038    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings read None from <Device(1,4090,MX Anywhere 3,558DB02C)>
15:05:32,038    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings write {'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86} to <Device(1,4090,MX Anywhere 3,558DB02C)>
15:05:32,038    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(196,82) => b'\x00\x00R'
15:05:32,038    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093F 00C40000520000000000000000000000]
15:05:32,061    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093F 00C40000520000000000000000000000]
15:05:32,062    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(80,80) => b'\x00\x00P'
15:05:32,062    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093E 00500000500000000000000000000000]
15:05:32,085    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093E 00500000500000000000000000000000]
15:05:32,086    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(81,81) => b'\x00\x00Q'
15:05:32,086    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093B 00510000510000000000000000000000]
15:05:32,109    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093B 00510000510000000000000000000000]
15:05:32,110    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(82,196) => b'\x00\x00\xc4'
15:05:32,110    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093C 00520000C40000000000000000000000]
15:05:32,133    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093C 00520000C40000000000000000000000]
15:05:32,134    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(83,83) => b'\x00\x00S'
15:05:32,134    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093F 00530000530000000000000000000000]
15:05:32,159    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093F 00530000530000000000000000000000]
15:05:32,160    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(86,86) => b'\x00\x00V'
15:05:32,160    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093C 00560000560000000000000000000000]
15:05:32,183    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093C 00560000560000000000000000000000]
```

Before second push: line 359.  This is unexpected.  The device should not be sending all these (and other) unrequested messages to be read by Solaar.  The last seven messages are responses from commands to reprogram keys.

```
15:05:32,432    DEBUG [AsyncUI] logitech_receiver.settings: divert-keys: settings read {'196': 0, '215': 0, '82': 0, '83': 1, '86': 1} from <Device(1,4090,MX Anywhere 3,558DB02C)>
15:05:32,432    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 000A 00000000000000000000000000000000]
15:05:32,432    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 000A 00000000000000000000000000000000]
15:05:32,433    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0009 0A000100000000000000000000000000]
15:05:32,433    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0A0E 03000000000000000000000000000000]
15:05:32,433    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0008 00000000000000000000000000000000]
15:05:32,433    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 000A 00000000000000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0E1E 00000000000000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0E18 00000000000000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0D2B 02FF3C00000000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 0C3E 00047E00000000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 093F 00C40000520000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 093E 00500000500000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 093B 00510000510000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 093C 00520000C40000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 093F 00530000530000000000000000000000]
15:05:32,434    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (18) => r[11 01 093C 00560000560000000000000000000000]
```


Second push: line 467.  This is as expected, with the same commands being sent and the device responding as expected.  There are again unexpected messages being sent from the device.

```
15:05:39,810    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: apply {'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86} (<Device(1,4090,MX Anywhere 3,558DB02C)>)
15:05:39,810    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings read {'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86} from <Device(1,4090,MX Anywhere 3,558DB02C)>
15:05:39,810    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings write {'196': 82, '80': 80, '81': 81, '82': 196, '83': 83, '86': 86} to <Device(1,4090,MX Anywhere 3,558DB02C)>
15:05:39,810    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(196,82) => b'\x00\x00R'
15:05:39,810    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093C 00C40000520000000000000000000000]
15:05:39,826    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0000 05000000000000000000000000000000]
15:05:39,834    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093C 00C40000520000000000000000000000]
15:05:39,834    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(80,80) => b'\x00\x00P'
15:05:39,834    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093C 00500000500000000000000000000000]
15:05:39,850    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0000 05000000000000000000000000000000]
15:05:39,858    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093C 00500000500000000000000000000000]
15:05:39,858    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(81,81) => b'\x00\x00Q'
15:05:39,858    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093E 00510000510000000000000000000000]
15:05:39,874    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0500 00000000000000000000000000000000]
15:05:39,882    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093E 00510000510000000000000000000000]
15:05:39,882    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(82,196) => b'\x00\x00\xc4'
15:05:39,882    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093A 00520000C40000000000000000000000]
15:05:39,898    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0500 00000000000000000000000000000000]
15:05:39,906    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093A 00520000C40000000000000000000000]
15:05:39,906    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(83,83) => b'\x00\x00S'
15:05:39,906    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093D 00530000530000000000000000000000]
15:05:39,922    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0510 00000000000000000000000000000000]
15:05:39,930    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093D 00530000530000000000000000000000]
15:05:39,930    DEBUG [ReceiverListener:hidraw2] logitech_receiver.settings: reprogrammable-keys: settings prepare map write(86,86) => b'\x00\x00V'
15:05:39,930    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) <= w[11 01 093C 00560000560000000000000000000000]
15:05:39,946    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 0510 00000000000000000000000000000000]
15:05:39,954    DEBUG [ReceiverListener:hidraw2] logitech_receiver.base: (19) => r[11 01 093C 00560000560000000000000000000000]
```

</details>

Aside from the place shown above there are other places where unexpected responses to commands are coming from the device.  This strongly indicates that some other program is controlling the device.




Your other log also has evidence that some other program is controlling the device.
Hmm. I've just re-tried with the only obvious one, xfce4-mouse-settings, killed. No change, still the settings are not re-applied (from unpatched solaar master). There's no extra udev rules regarding any HID devices or mice other than solaars.
Something is sending the mouse commands.  I'm going to check one other possibility.
Argh.  My mistake.  Because  your mouse is connected via a receiver there are two hidraw nodes where its responses show up.   Solaar hears both of these but only responds to one.  So please ignore my comments from earlier today.

But there is still the issue of why your settings are not setup up correctly.   Please try changing some other settings and see whether they persist.  I suggest Sensitivity (DPI).

Good deduction :)

You're suspicion's correct, DPI changes are re-applied, I also tried the rachet level, that also is re-applied correctly.

Out of curiosity, I just tried various modifications to the 'Key/Button Actions'. Looks like none of these are re-applied either, for any of the key/button mappings.
This is even more curious.   I could understand only remappings not holding, perhaps because your mouse has a slightly different version of the feature.  But then why does sending the commands twice work?

For now, I don't think it is correct to apply your patch.   I'll think further on the problem.
Makes sense; let me know if I can look at anything else my end.
For the record, I'm running 1.06rc2 on Fedora 33, pulled from sources.

The issue is still present.

My mouse, MX Anywhere 2S, sometimes fails to restore the scroll wheel's high resolution setting, this is after a sleep / wakeup cycle.

If I manually open Solaar and click "Scroll Wheel Resolution" off and on - it is set correctly, scrolling is fast again just how I prefer.
If the only problem is with the Scroll Wheel Resolution then what is happening is a Linux driver is changing the setting to get better scrolling.   This is a recent enhancement of the driver.  The solution, as mentioned in  https://pwr-solaar.github.io/Solaar/ under Known Issues is to make this setting be ignored.  

Eventually this setting should be removed, I guess, but lots of machines don't yet have the enhanced driver and the setting is useful for them.
Thank you @pfps I will try ignoring.
I'm seeing this issue on my MX Vertical. I've remapped the backward and forward keys, and they stopped working as described here. I have to manually change their setting to something else and back to what I want, for them to work. The same happens to my DPI key, even though that key is not remapped, I just can't switch between DPI profiles and have to disable and then re-enable "DPI  Sliding Adjustment" to get back the normal functionality.
I'm using the stable PPA because I thought it would be more production-ready, but the problem is still found on master. I can switch to using the master branch if you guys need logs or something else to help fix this problem.
Yes, please run from a clone of the GitHub master.  Start Solaar from there as `bin/solaar -dd` first ensuring that no other copies of Solaar are running.  That will produce a lot of output.  Post the part from just before the power-on to after all the settings a pushed by Solaar.

But I have an MX Vertical and I've never seen the problem.
I'm sorry it's taken so long, but it's very hard to come up with logs for this bug. This bug only happens after the mouse goes to sleep or some certain amount of time has passed, which makes it hard for me to get logs. I'm usually using my computer/mouse, and when I come back after a sleep cycle, the command line has reached way more lines than it can handle.
I can say that this bug is still present. I'm going to have to dedicate some proper time in the next days to make sure the mouse doesn't move so the command line doesn't get flooded with unneeded lines.

So, I have an update. Because of the amount of data that debugging was throwing on the terminal, it made it really hard to find out what was going on. So I did something else... I decided to narrow down to which commit introduced this bug and I think I found the culprit. I believe this commit, https://github.com/pwr-Solaar/Solaar/commit/3969472dd3ec18d1d72454431803aadcee3ceb97, is the one that introduced the issue. Everything works without any problem before.
To provide a little more detail on how my system is configured, I have changed my backward and forward keys to do the opposite. (i.e. backward goes forward, and vice-versa). After letting the mouse go to sleep, these keys no longer work as configured.
Here's my config file for this commit:

```json
{
  "407B:9E0FBE51": {
    "_dpi-sliding": 2,
    "_modelId": "B020407BC08A",
    "_name": "MX Vertical Wireless Mouse",
    "_sensitive": {
      "divert-keys": false,
      "dpi": false,
      "dpi-sliding": true,
      "reprogrammable-keys": false
    },
    "_serial": "9E0FBE51",
    "_unitId": "99EB2180",
    "divert-keys": {
      "215": 0,
      "253": 1,
      "82": 0,
      "83": 0,
      "86": 0
    },
    "dpi": 2800,
    "dpi-sliding": "253",
    "lowres-smooth-scroll": false,
    "mouse-gestures": 0,
    "reprogrammable-keys": {
      "253": 253,
      "80": 80,
      "81": 81,
      "82": 82,
      "83": 86,
      "86": 83
    }
  },
  "_version": "1.0.5"
}
```
@fcastilloec It is possible that that commit is involved, but I don't deem it very likely.  Even looking for a problem with this code, I can't see anything going wrong with my MX Master 3, which has many of the same features.
Are you connecting the mouse via Bluetooth or via a receiver?  If the latter then this commit should not be involved, as it is not invoked when a receiver-connected device reconnects.
If the former, then the code is invoked.  To see whether it is responsible comment out the line that makes DPI_SLIDING a feature.  The line is 
```
   _S(_DPI_SLIDING, _F.REPROG_CONTROLS_V4, _feature_dpi_sliding),
```
about line 855 in lib/logitech_receiver/settings_templates.py
@fcastilloec Hi, I prefer flip back<->forward too and expirienced exactly same problem with MX Master 3. Sometimes after mouse wake this keys not flipped anymore, but configuring for gesture button works fine.
I'll try suggested commit/changes.

I connect mouse via receiver via usb-hub in KVM switch.
@iglooom I just connected my MX Master 3 via a receiver (but not through a switch).  I tried about five power cycles and didn't experience any problems.  Have you ever experienced the problem when the receiver is directly connected to your machine?
@pfps I've tried for a couple of days running that commit and that line commented. I haven't experienced any problems anymore. I can't use the DPI button for obvious reasons. I was using my mouse with a receiver, never used it with Bluetooth, neither USB cable.
I'm going to revert back to the previous commit so I can use all my keys.
Another thing I've noticed is that the bug is not consistent. The longer you wait while the mouse is sleeping the more likely you'll experience the issue. Another thing that's key for reproducing is having DPI sliding adjustments enable, which makes sense given the line I had to comment. If DPI sliding is disabled, I haven't been able to reproduce the bug reliably.
@fcastilloec iglooom is connecting via receiver so this code is not invoked when the mouse reconnects - only when Solaar starts up, the receiver is plugged in, or a device is paired.  I'm not sure what happens if the receiver is connected via a hub and the hub goes into power-saving mode, but turning a receiver-connected mouse off and on will not run this code.
USB-Hub seems to be not an issue. I have run solaar -d and wait while bug is happend again. It is very inconsistant and often happend after long sleep periods. In attached file there are two files, one with normal wakeup and one with this bug.
After bug happens I've power cycle mouse and log was excatly like solaar_norm.log from archive. 

[log.zip](https://github.com/pwr-Solaar/Solaar/files/6771719/log.zip)

My config.json just In case 
 `````
{
  "4082:FA443C43": {
    "_modelId": "B02340820000",
    "_name": "MX Master 3 Wireless Mouse",
    "_sensitive": {
      "divert-keys": false,
      "dpi": false,
      "hires-smooth-resolution": true,
      "mouse-gestures": false,
      "reprogrammable-keys": true,
      "smart-shift": false
    },
    "_serial": "FA443C43",
    "_unitId": "FA443C43",
    "divert-keys": {
      "195": 1,
      "196": 0,
      "215": 0,
      "82": 0,
      "83": 0,
      "86": 0
    },
    "dpi": "1000",
    "dpi-sliding": 0,
    "hires-smooth-invert": false,
    "hires-smooth-resolution": true,
    "mouse-gestures": "195",
    "reprogrammable-keys": {
      "195": 195,
      "196": 196,
      "80": 80,
      "81": 81,
      "82": 82,
      "83": 86,
      "86": 83
    },
    "smart-shift": 14,
    "thumb-scroll-invert": false,
    "thumb-scroll-mode": false
  },
  "_version": "1.0.6"
}

I think I am seeing this problem.   It occurs when the mouse is active when the receiver becomes active while Solaar is running.  Somehow in this situation communications with the mouse do not always succeed.  The solution is likely to be to retry the communications that fail.  However, I don't want to always do this so I need to figure out just when to retry.
@pfps if it can help, I've catched bug with verbose logging
[solaar_err_verbose.log](https://github.com/pwr-Solaar/Solaar/files/6777820/solaar_err_verbose.log)

The problem is not the error - although that needs to be fixed, it is the timeout at least as far as I can tell.  I've fixed the error but need to figure out what to do when a timeout is encountered in this kind of situation.
Just some extra info, I decided to use the latest commit on the master branch and disable "DPI Sliding Adjustment" and now the bug is gone. Of course, I've lost functionality of the DPI key but the remapping of the keys always stays.
This doesn't sound like some communications failed and need to be retried, but I wouldn't know for sure.
DPI sliding is the key to solving this, at least for the MX Vertical.
DPI sliding causes more communication with the mouse early on, which may exacerbate the problem, but it looks to me as if the problem may occur (possibly at a lesser frequency) for other information that it pushed to the device at startup.
I took a close look at the log from @iglooom 
It really looks like the culprit there is two threads trying to talk to the device at the same time.  This will have to be solved by adding some locking code.
@pfps sorry for bothering you, just a question, do you plan to try fix it any time soon?
Sometime soon,  Hopefully in a week.

Resolving patch:
diff --git a/lib/logitech_receiver/base.py b/lib/logitech_receiver/base.py
--- a/lib/logitech_receiver/base.py
+++ b/lib/logitech_receiver/base.py
@@ -22,8 +22,12 @@
 
 from __future__ import absolute_import, division, print_function, unicode_literals
 
+import threading as _threading
+
 from collections import namedtuple
+from contextlib import contextmanager
 from logging import DEBUG as _DEBUG
+from logging import INFO as _INFO
 from logging import getLogger
 from random import getrandbits as _random_bits
 from time import time as _timestamp
@@ -350,6 +354,31 @@ def make_notification(report_id, devnumber, data):
 #
 #
 
+request_lock = _threading.Lock()  # serialize all requests
+handles_lock = {}
+
+
+def handle_lock(handle):
+    with request_lock:
+        if handles_lock.get(int(handle)) is None:
+            if _log.isEnabledFor(_INFO):
+                _log.info('New lock %s', int(handle))
+            handles_lock[int(handle)] = _threading.Lock()  # Serialize requests on the handle
+    return handles_lock[int(handle)]
+
+
+# context manager for locks with a timeout
+@contextmanager
+def acquire_timeout(lock, handle, timeout):
+    result = lock.acquire(timeout=timeout)
+    try:
+        if not result:
+            _log.error('lock on handle %d not acquired, probably due to timeout', int(handle))
+        yield result
+    finally:
+        if result:
+            lock.release()
+
 
 # a very few requests (e.g., host switching) do not expect a reply, but use no_reply=True with extreme caution
 def request(handle, devnumber, request_id, *params, no_reply=False, return_error=False, long_message=False):
@@ -364,119 +393,113 @@ def request(handle, devnumber, request_id, *params, no_reply=False, return_error
     # import inspect as _inspect
     # print ('\n  '.join(str(s) for s in _inspect.stack()))
 
-    assert isinstance(request_id, int)
-    if devnumber != 0xFF and request_id < 0x8000:
-        # For HID++ 2.0 feature requests, randomize the SoftwareId to make it
-        # easier to recognize the reply for this request. also, always set the
-        # most significant bit (8) in SoftwareId, to make notifications easier
-        # to distinguish from request replies.
-        # This only applies to peripheral requests, ofc.
-        request_id = (request_id & 0xFFF0) | 0x08 | _random_bits(3)
-
-    timeout = _RECEIVER_REQUEST_TIMEOUT if devnumber == 0xFF else _DEVICE_REQUEST_TIMEOUT
-    # be extra patient on long register read
-    if request_id & 0xFF00 == 0x8300:
-        timeout *= 2
-
-    if params:
-        params = b''.join(_pack('B', p) if isinstance(p, int) else p for p in params)
-    else:
-        params = b''
-    # if _log.isEnabledFor(_DEBUG):
-    #     _log.debug("(%s) device %d request_id {%04X} params [%s]", handle, devnumber, request_id, _strhex(params))
-    request_data = _pack('!H', request_id) + params
+    with acquire_timeout(handle_lock(handle), handle, 10.):
+        assert isinstance(request_id, int)
+        if devnumber != 0xFF and request_id < 0x8000:
+            # For HID++ 2.0 feature requests, randomize the SoftwareId to make it
+            # easier to recognize the reply for this request. also, always set the
+            # most significant bit (8) in SoftwareId, to make notifications easier
+            # to distinguish from request replies.
+            # This only applies to peripheral requests, ofc.
+            request_id = (request_id & 0xFFF0) | 0x08 | _random_bits(3)
+
+        timeout = _RECEIVER_REQUEST_TIMEOUT if devnumber == 0xFF else _DEVICE_REQUEST_TIMEOUT
+        # be extra patient on long register read
+        if request_id & 0xFF00 == 0x8300:
+            timeout *= 2
+
+        if params:
+            params = b''.join(_pack('B', p) if isinstance(p, int) else p for p in params)
+        else:
+            params = b''
+        # if _log.isEnabledFor(_DEBUG):
+        #     _log.debug("(%s) device %d request_id {%04X} params [%s]", handle, devnumber, request_id, _strhex(params))
+        request_data = _pack('!H', request_id) + params
 
-    ihandle = int(handle)
-    notifications_hook = getattr(handle, 'notifications_hook', None)
-    try:
-        _skip_incoming(handle, ihandle, notifications_hook)
-    except NoReceiver:
-        _log.warn('device or receiver disconnected')
-        return None
-    write(ihandle, devnumber, request_data, long_message)
-
-    if no_reply:
-        return None
-
-    # we consider timeout from this point
-    request_started = _timestamp()
-    delta = 0
-
-    while delta < timeout:
-        reply = _read(handle, timeout)
-
-        if reply:
-            report_id, reply_devnumber, reply_data = reply
-            if reply_devnumber == devnumber:
-                if report_id == HIDPP_SHORT_MESSAGE_ID and reply_data[:1] == b'\x8F' and reply_data[1:3] == request_data[:2]:
-                    error = ord(reply_data[3:4])
-
-                    # if error == _hidpp10.ERROR.resource_error: # device unreachable
-                    #     _log.warn("(%s) device %d error on request {%04X}: unknown device", handle, devnumber, request_id)
-                    #     raise DeviceUnreachable(number=devnumber, request=request_id)
-
-                    # if error == _hidpp10.ERROR.unknown_device: # unknown device
-                    #     _log.error("(%s) device %d error on request {%04X}: unknown device", handle, devnumber, request_id)
-                    #     raise NoSuchDevice(number=devnumber, request=request_id)
-
-                    if _log.isEnabledFor(_DEBUG):
-                        _log.debug(
-                            '(%s) device 0x%02X error on request {%04X}: %d = %s', handle, devnumber, request_id, error,
-                            _hidpp10.ERROR[error]
+        ihandle = int(handle)
+        notifications_hook = getattr(handle, 'notifications_hook', None)
+        try:
+            _skip_incoming(handle, ihandle, notifications_hook)
+        except NoReceiver:
+            _log.warn('device or receiver disconnected')
+            return None
+        write(ihandle, devnumber, request_data, long_message)
+
+        if no_reply:
+            return None
+
+        # we consider timeout from this point
+        request_started = _timestamp()
+        delta = 0
+
+        while delta < timeout:
+            reply = _read(handle, timeout)
+
+            if reply:
+                report_id, reply_devnumber, reply_data = reply
+                if reply_devnumber == devnumber:
+                    if report_id == HIDPP_SHORT_MESSAGE_ID and reply_data[:1] == b'\x8F' and reply_data[1:3] == request_data[:2
+                                                                                                                             ]:
+                        error = ord(reply_data[3:4])
+
+                        if _log.isEnabledFor(_DEBUG):
+                            _log.debug(
+                                '(%s) device 0x%02X error on request {%04X}: %d = %s', handle, devnumber, request_id, error,
+                                _hidpp10.ERROR[error]
+                            )
+                        return _hidpp10.ERROR[error] if return_error else None
+                    if reply_data[:1] == b'\xFF' and reply_data[1:3] == request_data[:2]:
+                        # a HID++ 2.0 feature call returned with an error
+                        error = ord(reply_data[3:4])
+                        _log.error(
+                            '(%s) device %d error on feature request {%04X}: %d = %s', handle, devnumber, request_id, error,
+                            _hidpp20.ERROR[error]
                         )
-                    return _hidpp10.ERROR[error] if return_error else None
-                if reply_data[:1] == b'\xFF' and reply_data[1:3] == request_data[:2]:
-                    # a HID++ 2.0 feature call returned with an error
-                    error = ord(reply_data[3:4])
-                    _log.error(
-                        '(%s) device %d error on feature request {%04X}: %d = %s', handle, devnumber, request_id, error,
-                        _hidpp20.ERROR[error]
-                    )
-                    raise _hidpp20.FeatureCallError(number=devnumber, request=request_id, error=error, params=params)
-
-                if reply_data[:2] == request_data[:2]:
-                    if request_id & 0xFE00 == 0x8200:
-                        # long registry r/w should return a long reply
-                        assert report_id == HIDPP_LONG_MESSAGE_ID
-                    elif request_id & 0xFE00 == 0x8000:
-                        # short registry r/w should return a short reply
-                        assert report_id == HIDPP_SHORT_MESSAGE_ID
-
-                    if devnumber == 0xFF:
-                        if request_id == 0x83B5 or request_id == 0x81F1:
-                            # these replies have to match the first parameter as well
-                            if reply_data[2:3] == params[:1]:
-                                return reply_data[2:]
+                        raise _hidpp20.FeatureCallError(number=devnumber, request=request_id, error=error, params=params)
+
+                    if reply_data[:2] == request_data[:2]:
+                        if request_id & 0xFE00 == 0x8200:
+                            # long registry r/w should return a long reply
+                            assert report_id == HIDPP_LONG_MESSAGE_ID
+                        elif request_id & 0xFE00 == 0x8000:
+                            # short registry r/w should return a short reply
+                            assert report_id == HIDPP_SHORT_MESSAGE_ID
+
+                        if devnumber == 0xFF:
+                            if request_id == 0x83B5 or request_id == 0x81F1:
+                                # these replies have to match the first parameter as well
+                                if reply_data[2:3] == params[:1]:
+                                    return reply_data[2:]
+                                else:
+                                    # hm, not matching my request, and certainly not a notification
+                                    continue
                             else:
-                                # hm, not matching my request, and certainly not a notification
-                                continue
+                                return reply_data[2:]
                         else:
                             return reply_data[2:]
-                    else:
-                        return reply_data[2:]
-            else:
-                # a reply was received, but did not match our request in any way
-                # reset the timeout starting point
-                request_started = _timestamp()
-
-            if notifications_hook:
-                n = make_notification(report_id, reply_devnumber, reply_data)
-                if n:
-                    notifications_hook(n)
+                else:
+                    # a reply was received, but did not match our request in any way
+                    # reset the timeout starting point
+                    request_started = _timestamp()
+
+                if notifications_hook:
+                    n = make_notification(report_id, reply_devnumber, reply_data)
+                    if n:
+                        notifications_hook(n)
+                    # elif _log.isEnabledFor(_DEBUG):
+                    #     _log.debug("(%s) ignoring reply %02X [%s]", handle, reply_devnumber, _strhex(reply_data))
                 # elif _log.isEnabledFor(_DEBUG):
                 #     _log.debug("(%s) ignoring reply %02X [%s]", handle, reply_devnumber, _strhex(reply_data))
-            # elif _log.isEnabledFor(_DEBUG):
-            #     _log.debug("(%s) ignoring reply %02X [%s]", handle, reply_devnumber, _strhex(reply_data))
 
-        delta = _timestamp() - request_started
-        # if _log.isEnabledFor(_DEBUG):
-        #     _log.debug("(%s) still waiting for reply, delta %f", handle, delta)
+            delta = _timestamp() - request_started
+            # if _log.isEnabledFor(_DEBUG):
+            #     _log.debug("(%s) still waiting for reply, delta %f", handle, delta)
 
-    _log.warn(
-        'timeout (%0.2f/%0.2f) on device %d request {%04X} params [%s]', delta, timeout, devnumber, request_id,
-        _strhex(params)
-    )
-    # raise DeviceUnreachable(number=devnumber, request=request_id)
+        _log.warn(
+            'timeout (%0.2f/%0.2f) on device %d request {%04X} params [%s]', delta, timeout, devnumber, request_id,
+            _strhex(params)
+        )
+        # raise DeviceUnreachable(number=devnumber, request=request_id)
 
 
 def ping(handle, devnumber, long_message=False):
@@ -494,58 +517,61 @@ def ping(handle, devnumber, long_message=False):
     assert devnumber >= 0x00
     assert devnumber < 0x0F
 
-    # randomize the SoftwareId and mark byte to be able to identify the ping
-    # reply, and set most significant (0x8) bit in SoftwareId so that the reply
-    # is always distinguishable from notifications
-    request_id = 0x0018 | _random_bits(3)
-    request_data = _pack('!HBBB', request_id, 0, 0, _random_bits(8))
+    with acquire_timeout(handle_lock(handle), handle, 10.):
 
-    ihandle = int(handle)
-    notifications_hook = getattr(handle, 'notifications_hook', None)
-    try:
-        _skip_incoming(handle, ihandle, notifications_hook)
-    except NoReceiver:
-        _log.warn('device or receiver disconnected')
-        return
+        # randomize the SoftwareId and mark byte to be able to identify the ping
+        # reply, and set most significant (0x8) bit in SoftwareId so that the reply
+        # is always distinguishable from notifications
+        request_id = 0x0018 | _random_bits(3)
+        request_data = _pack('!HBBB', request_id, 0, 0, _random_bits(8))
 
-    write(ihandle, devnumber, request_data, long_message)
+        ihandle = int(handle)
+        notifications_hook = getattr(handle, 'notifications_hook', None)
+        try:
+            _skip_incoming(handle, ihandle, notifications_hook)
+        except NoReceiver:
+            _log.warn('device or receiver disconnected')
+            return
 
-    # we consider timeout from this point
-    request_started = _timestamp()
-    delta = 0
+        write(ihandle, devnumber, request_data, long_message)
 
-    while delta < _PING_TIMEOUT:
-        reply = _read(handle, _PING_TIMEOUT)
+        # we consider timeout from this point
+        request_started = _timestamp()
+        delta = 0
 
-        if reply:
-            report_id, reply_devnumber, reply_data = reply
-            if reply_devnumber == devnumber:
-                if reply_data[:2] == request_data[:2] and reply_data[4:5] == request_data[-1:]:
-                    # HID++ 2.0+ device, currently connected
-                    return ord(reply_data[2:3]) + ord(reply_data[3:4]) / 10.0
+        while delta < _PING_TIMEOUT:
+            reply = _read(handle, _PING_TIMEOUT)
 
-                if report_id == HIDPP_SHORT_MESSAGE_ID and reply_data[:1] == b'\x8F' and reply_data[1:3] == request_data[:2]:
-                    assert reply_data[-1:] == b'\x00'
-                    error = ord(reply_data[3:4])
+            if reply:
+                report_id, reply_devnumber, reply_data = reply
+                if reply_devnumber == devnumber:
+                    if reply_data[:2] == request_data[:2] and reply_data[4:5] == request_data[-1:]:
+                        # HID++ 2.0+ device, currently connected
+                        return ord(reply_data[2:3]) + ord(reply_data[3:4]) / 10.0
 
-                    if error == _hidpp10.ERROR.invalid_SubID__command:  # a valid reply from a HID++ 1.0 device
-                        return 1.0
+                    if report_id == HIDPP_SHORT_MESSAGE_ID and reply_data[:1] == b'\x8F' and reply_data[1:3] == request_data[:2
+                                                                                                                             ]:
+                        assert reply_data[-1:] == b'\x00'
+                        error = ord(reply_data[3:4])
 
-                    if error == _hidpp10.ERROR.resource_error:  # device unreachable
-                        return
+                        if error == _hidpp10.ERROR.invalid_SubID__command:  # a valid reply from a HID++ 1.0 device
+                            return 1.0
 
-                    if error == _hidpp10.ERROR.unknown_device:  # no paired device with that number
-                        _log.error('(%s) device %d error on ping request: unknown device', handle, devnumber)
-                        raise NoSuchDevice(number=devnumber, request=request_id)
+                        if error == _hidpp10.ERROR.resource_error:  # device unreachable
+                            return
 
-            if notifications_hook:
-                n = make_notification(report_id, reply_devnumber, reply_data)
-                if n:
-                    notifications_hook(n)
-                # elif _log.isEnabledFor(_DEBUG):
-                #     _log.debug("(%s) ignoring reply %02X [%s]", handle, reply_devnumber, _strhex(reply_data))
+                        if error == _hidpp10.ERROR.unknown_device:  # no paired device with that number
+                            _log.error('(%s) device %d error on ping request: unknown device', handle, devnumber)
+                            raise NoSuchDevice(number=devnumber, request=request_id)
+
+                if notifications_hook:
+                    n = make_notification(report_id, reply_devnumber, reply_data)
+                    if n:
+                        notifications_hook(n)
+                    # elif _log.isEnabledFor(_DEBUG):
+                    #     _log.debug("(%s) ignoring reply %02X [%s]", handle, reply_devnumber, _strhex(reply_data))
 
-        delta = _timestamp() - request_started
+            delta = _timestamp() - request_started
 
-    _log.warn('(%s) timeout (%0.2f/%0.2f) on device %d ping', handle, delta, _PING_TIMEOUT, devnumber)
-    # raise DeviceUnreachable(number=devnumber, request=request_id)
+        _log.warn('(%s) timeout (%0.2f/%0.2f) on device %d ping', handle, delta, _PING_TIMEOUT, devnumber)
+        # raise DeviceUnreachable(number=devnumber, request=request_id)
diff --git a/lib/logitech_receiver/listener.py b/lib/logitech_receiver/listener.py
--- a/lib/logitech_receiver/listener.py
+++ b/lib/logitech_receiver/listener.py
@@ -129,7 +129,7 @@ def __bool__(self):
 # a while for it to acknowledge it.
 # Forcibly closing the file handle on another thread does _not_ interrupt the
 # read on Linux systems.
-_EVENT_READ_TIMEOUT = 0.4  # in seconds
+_EVENT_READ_TIMEOUT = 1.  # in seconds
 
 # After this many reads that did not produce a packet, call the tick() method.
 # This only happens if tick_period is enabled (>0) for the Listener instance.
@@ -174,7 +174,7 @@ def run(self):
             if self._queued_notifications.empty():
                 try:
                     # _log.debug("read next notification")
-                    n = _base.read(ihandle, _EVENT_READ_TIMEOUT)
+                    n = _base.read(self.receiver.handle, _EVENT_READ_TIMEOUT)
                 except _base.NoReceiver:
                     _log.warning('receiver disconnected')
                     self.receiver.close()


Test patch: