Repository: pwr-Solaar/Solaar

Issue:
Use Host Switch buttons to alternate between receivers for both Keyboard and Mouse
**Information**
- Solaar version: 1.0.4+git1275-8fccd84-202102090518~ubuntu20.04.1
- Distribution: KUbuntu 20.04
- Kernel version: Linux 5.10.15-xanmod1 x86_64 GNU/Linux
- Output of `solaar show` for the target device (if applicable):
```
Unifying Receiver
  Device path  : /dev/hidraw0
  USB id       : 046d:C52B
  Serial       : E1F970EB
    Firmware   : 24.11.B0036
    Bootloader : 02.09
    Other      : AA.AC
  Has 2 paired device(s) out of a maximum of 6.
  Notifications: wireless, software present (0x000900)
  Device activity counters: 1=207, 2=99

  1: MX Keys Keyboard
     Device path  : /dev/hidraw2
     WPID         : 408A
     Codename     : MX Keys
     Kind         : keyboard
     Protocol     : HID++ 4.5
     Polling rate : 20 ms (50Hz)
     Serial number: B95E6F62
     Model ID:      B35B408A0000
     Unit ID:       B95E6F62
        Bootloader: BL1 08.00.B0011
          Firmware: MPK 12.00.B0011
             Other: 
     The power switch is located on the edge of top right corner.
     Supports 33 HID++ 2.0 features:
         0: ROOT                   {0000}   
         1: FEATURE SET            {0001}   
         2: DEVICE FW VERSION      {0003}   
            Firmware: Bootloader BL1 08.00.B0011 00008169E8BB
            Firmware: Firmware MPK 12.00.B0011 408A8169E8BB
            Firmware: Other   
            Unit ID: B95E6F62  Model ID: B35B408A0000  Transport IDs: {'btleid': 'B35B', 'wpid': '408A'}
         3: DEVICE NAME            {0005}   
            Name: MX Keys Wireless Keyboard
            Kind: keyboard
         4: WIRELESS DEVICE STATUS {1D4B}   
         5: RESET                  {0020}   
         6: DEVICE FRIENDLY NAME   {0007}   
         7: BATTERY STATUS         {1000}   
            Battery: 100%, discharging, next level 50%.
         8: REPROG CONTROLS V4     {1B04}   
            Key/Button Diversion: {'209': 0, '210': 0, '211': 0, '199': 0, '200': 0, '224': 0, '225': 0, '110': 0, '226': 0, '227': 0, '228': 0, '229': 0, '230': 0, '231': 0, '232': 0, '233': 0, '10': 0, '191': 0, '234': 0, '111': 0, '236': 0, '235': 0}
         9: CHANGE HOST            {1814}   
            Change Host: 1:W10MASTER
        10: HOSTS INFO             {1815}   
            Host 0 (paired): W10MASTER
            Host 1 (paired): W10MASTER
            Host 2 (unpaired): 
        11: BACKLIGHT2             {1982}   
            Backlight: True
        12: K375S FN INVERSION     {40A3}   
            Swap Fx function: False
        13: ENCRYPTION             {4100}   
        14: LOCK KEY STATE         {4220}   
        15: KEYBOARD DISABLE KEYS  {4521}   
            Disable keys: {'1': False, '2': False, '4': False, '8': False, '16': False}
        16: MULTIPLATFORM          {4531}   
            Set OS: Android
        17: DFUCONTROL SIGNED      {00C2}   
        18: DEVICE RESET           {1802}   internal, hidden
        19: unknown:1803           {1803}   internal, hidden
        20: CONFIG DEVICE PROPS    {1806}   internal, hidden
        21: unknown:1813           {1813}   internal, hidden
        22: OOBSTATE               {1805}   internal, hidden
        23: unknown:1830           {1830}   internal, hidden
        24: unknown:1890           {1890}   internal, hidden
        25: unknown:1891           {1891}   internal, hidden
        26: unknown:18A1           {18A1}   internal, hidden
        27: unknown:1DF3           {1DF3}   internal, hidden
        28: unknown:1E00           {1E00}   hidden
        29: unknown:1EB0           {1EB0}   internal, hidden
        30: unknown:1861           {1861}   internal, hidden
        31: unknown:1A20           {1A20}   internal, hidden
        32: unknown:18B0           {18B0}   internal, hidden
     Has 24 reprogrammable keys:
         0: Host Switch Channel 1     , default: HostSwitch Channel 1        => HostSwitch Channel 1      
             nonstandard, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
         1: Host Switch Channel 2     , default: HostSwitch Channel 2        => HostSwitch Channel 2      
             nonstandard, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
         2: Host Switch Channel 3     , default: HostSwitch Channel 3        => HostSwitch Channel 3      
             nonstandard, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
         3: Brightness Down           , default: Brightness Down             => Brightness Down           
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:1, group:0, group mask:empty
             reporting: default
         4: Brightness Up             , default: Brightness Up               => Brightness Up             
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:2, group:0, group mask:empty
             reporting: default
         5: Mission Control/Task View , default: Mission Control/Task View   => Mission Control/Task View 
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:3, group:0, group mask:empty
             reporting: default
         6: Dashboard Launchpad/Action Center, default: Dashboard Launchpad/Action Center => Dashboard Launchpad/Action Center
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:4, group:0, group mask:empty
             reporting: default
         7: Show Desktop              , default: Show Desktop                => Show Desktop              
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:5, group:0, group mask:empty
             reporting: default
         8: Backlight Down            , default: Backlight Down              => Backlight Down            
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:6, group:0, group mask:empty
             reporting: default
         9: Backlight Up              , default: Backlight Up                => Backlight Up              
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:7, group:0, group mask:empty
             reporting: default
        10: Previous Fn               , default: Previous                    => Previous                  
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:8, group:0, group mask:empty
             reporting: default
        11: Play/Pause Fn             , default: Play/Pause                  => Play/Pause                
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:9, group:0, group mask:empty
             reporting: default
        12: Next Fn                   , default: Next                        => Next                      
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:10, group:0, group mask:empty
             reporting: default
        13: Mute Fn                   , default: Mute                        => Mute                      
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:11, group:0, group mask:empty
             reporting: default
        14: Volume Down Fn            , default: Volume Down                 => Volume Down               
             is FN, FN sensitive, reprogrammable, divertable, persistently divertable, analytics key events, pos:12, group:0, group mask:empty
             reporting: default
        15: Volume Up Fn              , default: Volume Up                   => Volume Up                 
             nonstandard, reprogrammable, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        16: Calculator                , default: Calculator                  => Calculator                
             nonstandard, reprogrammable, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        17: Screen Capture/Print Screen, default: Screen Capture              => Screen Capture            
             nonstandard, reprogrammable, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        18: App Contextual Menu/Right Click, default: Right Click/App Contextual Menu => Right Click/App Contextual Menu
             nonstandard, reprogrammable, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        19: Lock PC                   , default: WindowsLock                 => WindowsLock               
             nonstandard, reprogrammable, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        20: Left Arrow                , default: Keyboard Left Arrow         => Keyboard Left Arrow       
             nonstandard, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        21: Right Arrow               , default: Keyboard Right Arrow        => Keyboard Right Arrow      
             nonstandard, divertable, persistently divertable, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        22: F Lock                    , default: Do Nothing One              => Do Nothing One            
             is FN, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
        23: unknown:0034              , default: Do Nothing One              => Do Nothing One            
             nonstandard, analytics key events, pos:0, group:0, group mask:empty
             reporting: default
     Battery: 100%, discharging, next level 50%.

  2: Wireless Mouse MX Master 2S
     Device path  : /dev/hidraw3
     WPID         : 4069
     Codename     : MX Master 2S
     Kind         : mouse
     Protocol     : HID++ 4.5
     Polling rate : 8 ms (125Hz)
     Serial number: BA8626F9
     Model ID:      B01940690000
     Unit ID:       93AD7592
        Bootloader: BOT 56.01.B0006
          Firmware: MPM 12.01.B0006
          Firmware: MPM 12.01.B0006
             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 BOT 56.01.B0006 406916A9FC5401
            Firmware: Firmware MPM 12.01.B0006 B01916A9FC5401
            Firmware: Firmware MPM 12.01.B0006 406916A9FC5401
            Firmware: Other   
            Unit ID: 93AD7592  Model ID: B01940690000  Transport IDs: {'btleid': 'B019', 'wpid': '4069'}
         3: DEVICE NAME            {0005}   
            Name: Wireless Mouse MX Master 2S
            Kind: mouse
         4: WIRELESS DEVICE STATUS {1D4B}   
         5: RESET                  {0020}   
         6: CRYPTO ID              {0021}   
         7: BATTERY STATUS         {1000}   
            Battery: 90%, discharging, next level 50%.
         8: CONFIG DEVICE PROPS    {1806}   internal, hidden
         9: CHANGE HOST            {1814}   
            Change Host: 1:hermes
        10: REPROG CONTROLS V4     {1B04}   
            Key/Button Actions: {'80': 80, '81': 81, '82': 82, '83': 83, '86': 86, '195': 195, '196': 196}
            Key/Button Diversion: {'82': 0, '83': 0, '86': 0, '195': 0, '196': 0, '215': 0}
        11: ADJUSTABLE DPI         {2201}   
            Sensitivity (DPI): 1000
        12: VERTICAL SCROLLING     {2100}   
            Roller type: 3G
            Ratchet per turn: 24
            Scroll lines: 0
        13: SMART SHIFT            {2110}   
            Scroll Wheel Rachet: 16
        14: HIRES WHEEL            {2121}   
            Multiplier: 8
            Has invert: Normal wheel motion
            Has ratchet switch: Normal wheel mode
            High resolution mode
            HID notification
            Scroll Wheel Direction: False
            Scroll Wheel Resolution: True
        15: GESTURE 2              {6501}   
            Gestures: {'46': True, '45': True}
        16: DFUCONTROL SIGNED      {00C2}   
        17: unknown:1813           {1813}   internal, hidden
        18: unknown:1830           {1830}   internal, hidden
        19: unknown:1890           {1890}   internal, hidden
        20: unknown:1891           {1891}   internal, hidden
        21: unknown:18A1           {18A1}   internal, hidden
        22: unknown:18C0           {18C0}   internal, hidden
        23: unknown:1DF3           {1DF3}   internal, hidden
        24: unknown:1E00           {1E00}   hidden
        25: unknown:1EB0           {1EB0}   internal, hidden
        26: unknown:1803           {1803}   internal, hidden
        27: unknown:1861           {1861}   internal, hidden
        28: unknown:9001           {9001}   internal, hidden
        29: unknown:9200           {9200}   internal, hidden
        30: unknown:9202           {9202}   internal, hidden
        31: OOBSTATE               {1805}   internal, hidden
     Has 8 reprogrammable keys:
         0: Left Button               , default: Left Click                  => Left Click                
             mse, pos:0, group:1, group mask:g1
             reporting: default
         1: Right Button              , default: Right Click                 => Right Click               
             mse, pos:0, group:1, group mask:g1
             reporting: default
         2: Middle Button             , default: Mouse Middle Button         => Mouse Middle Button       
             mse, reprogrammable, divertable, raw XY, pos:0, group:3, group mask:g1,g2,g3
             reporting: default
         3: Back Button               , default: Mouse Back Button           => Mouse Back Button         
             mse, reprogrammable, divertable, raw XY, pos:0, group:2, group mask:g1,g2
             reporting: default
         4: Forward Button            , default: Mouse Forward Button        => Mouse Forward Button      
             mse, reprogrammable, divertable, raw XY, pos:0, group:2, group mask:g1,g2
             reporting: default
         5: App Switch Gesture        , default: Gesture Button Navigation   => Gesture Button Navigation 
             mse, reprogrammable, divertable, raw XY, pos:0, group:3, group mask:g1,g2,g3
             reporting: default
         6: Smart Shift               , default: Smart Shift                 => Smart Shift               
             mse, reprogrammable, divertable, raw XY, pos:0, group:3, group mask:g1,g2,g3
             reporting: default
         7: Virtual Gesture Button    , default: Virtual Gesture Button      => Virtual Gesture Button    
             divertable, virtual, raw XY, force raw XY, pos:0, group:4, group mask:empty
             reporting: default
     Has 2 gesture(s), 0 param(s) and 4 spec(s):
        Thumbwheel                 Enabled (   0): True
        NaturalScrolling           Enabled (   1): True
        period unit                Spec    (   3): 800
        DVI field width            Spec    (   1): 8
        field widths               Spec    (   2): 8
        resolution                 Spec    (   4): 2048
     Battery: 90%, discharging, next level 50%.

```

**Is your feature request related to a problem? Please describe.**
I would like to have the possibility to associate the Host Switch buttons on my MX Keys keyboard with the Change Host feature of the MX Master 2s, thus using the keyboard as some sort of KVM device.
Usually both the keyboard and the mouse are paired with at least 2 receivers and it would be great to be able to go from one receiver to another by using the keyboard's Host Switch buttons.

**Describe the solution you'd like**
Usually both the keyboard and the mouse are paired with at least 2 receivers and it would be great to be able to go from one receiver to another by using the keyboard's Host Switch buttons.

**Describe alternatives you've considered**
None that I could find.

**Additional context**
Nothing in particular, but I could provide extra information if needed.

It would be a great feature to be able to define a Custom Rule to trigger the Host switch of the mouse when the keyboard is being switched.

Thank you in advance!

Best regards,
SoftExpert



Discussion:
See #1067 for a solution that uses Solaar's new (not in any release yet) rule functionality.
Hello,

Thank you for the hint; it almost works - the issue being that as soon as I switch the mouse to the other receiver, I cannot switch back to the original one.

```
⋄⋄⋄/> solaar config "MX Master 2S" change-host "1"
Setting change-host to NamedInt(1, '2')

⋄⋄⋄/> solaar config "MX Master 2S" change-host "0"
solaar: error: Traceback (most recent call last):
  File "/usr/share/solaar/lib/solaar/cli/__init__.py", line 199, in run
    m.run(c, args, _find_receiver, _find_device)
  File "/usr/share/solaar/lib/solaar/cli/config.py", line 57, in run
    raise Exception('%s is offline' % dev.name)
Exception: Wireless Mouse MX Master 2S is offline

```
Is this something related to my configuration or there is a more generic problem, related to the way the hardware works ?

It looks as if you want to yank the mouse back to one machine when it is connected to another.  This won't work, even if done within Solaar because as soon as the mouse is connected to the other machine messages cannot be sent to it from the first machine.  You would have to have software running on the other machine that would switch it back.
What I have is two Linux machines, both running Solaar with the same set of rules and configuration.  I have diverted `Host Switch Channel 2` and `Host Switch Channel 3`.  One switches to one machine and the other switches to the other.   The rules are 
```
   Rule
	Key	Host Switch Channel 2
	Execute	solaar config Craft change-host 2:idefix
	Execute	solaar config MX change-host 2
   Rule
	Key	Host Switch Channel 3
	Execute	solaar config Craft change-host 3:ppslaptop
	Execute	solaar config MX change-host 3
```
The set values are different because my Craft remembers the name of machines it connects to but my MX Master 3 doesn't, and Solaar (helpfully) adds this information to the host-switch values it uses.
Is this workaround of any help if you have MAC/WIN/Linux and like to shift with the 1,2,3 key between the PC's mouse and keyboard at the same time?
Well it would work, except that the Logitech software uses a different mechanism to set up the switching (which is unknown and guaranteed to be much harder to implement).   Alternatively Solaar could be ported to Windoze or MacO$.  Neither is likely to happen.

Even if Solaar did the switch internally (which would be non-trivial but is possible) it there would be no mechanism to switch back.    

I don't run the Logitech software, so just maybe there is a way to set it up to just switch devices to a different connection.   But I don't think so, as I didn't see any hint of this capability in the (minimal) user documentation.
The use of rules and `solaar config` just gets around the reprogramming that would be needed to force a change on multiple devices.
Hmm, that's a unfortunate surprise a Logitech advertised multi OS support but it's only a kind of that.

But anyway is there a possibility to use external commands/scripts inside the rules like  ddccontrol (for input switching displays), and if not could this be added?

btw I have a MX Craft and a MX Master 3
The rules can execute arbitrary programs, so yes.   In fact that is what the host switching rules do - they call solaar as an external program.

for the windows issue do you think Solaar could be used under Windows WSL2
Almost certainly not.  WSL2 doesn't include udev, which Solaar uses.   
But it might not be too hard to make Solaar work under WSL2.   It's not on the roadmap, though
would https://github.com/awelkie/pyhidapi a possible way to port Solaar also to Windows, MacOS and Android
That would certainly help, but there is gong to be quite a bit more required.
If someone is interested in trying to port Solaar to other OSes then I could help.
I'm going to close this issue, as porting to other OSes should be a separate issue whenever someone wants to take it on.
hi  pfps and a big thk for solaar.
go to point: how to proceed so as to alternate with keys for both device?
i have 2 PC (Manjaro fresh install) + 1 MX master3 + 1 MX Key +1 receveir logitech (BT connection on the other PC) + last solaar version.

i have tested multi-times & multi-ways yours settings (adapted)
```
 Rule
Key	Host Switch Channel 2
Execute	solaar config Craft change-host 2:idefix
Execute	solaar config MX change-host 2

   Rule
Key	Host Switch Channel 3
Execute	solaar config Craft change-host 3:ppslaptop
Execute	solaar config MX change-host 3
```

without success

So, can i achieve to setup my MX with only one receiver?
if yes , why these lines does not do the trick:
 ```
  Rule
Key	Host Switch Channel 1
Execute	solaar config MX KEY change-host 1:PC1
Execute	solaar config MX MASTER 3 change-host 1

   Rule
Key	Host Switch Channel 2
Execute	solaar config MX KEY change-host 2:PC2
Execute	solaar config MX MASTER 3 change-host 2
``` 

thank 
I see one potential problem - make sure the MX Key and MX MASTER 3 are one argument.  Otherwise that should work.

I'm assuming that you can switch both devices manually, i.e., you can change hosts by just pressing the host change keys on your keyboard and the button on your mouse.  I'm also assuming that you have diverted the keys on your keyboard (Key/Button Diversion setting).  Solaar rules only respond to diverted keys.

You should run solaar with the `-d` switch on both machines and look at the output.  On the host you are switching from you should see output from each call to solaar config - something like Setting change-host to NamedInt(.....).  If not, the rule isn't being triggered.  When switching to the bluetooth host you should see a bunch of lines, including two lines containing `solaar.listener:  receiver event add`.  If not, Solaar isn't seeing the newly-connected devices.


ok thank;
i have some line of error:


```
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/logitech_receiver/listener.py", line 193, in run
self._notifications_callback(n)
File "/usr/lib/python3.9/site-packages/solaar/listener.py", line 246, in _notifications_handler
_notifications.process(dev, n)
File "/usr/lib/python3.9/site-packages/logitech_receiver/notifications.py", line 62, in process
return _process_device_notification(device, status, notification)
File "/usr/lib/python3.9/site-packages/logitech_receiver/notifications.py", line 138, in _process_device_notification
return _process_feature_notification(device, status, n, feature)
File "/usr/lib/python3.9/site-packages/logitech_receiver/notifications.py", line 388, in _process_feature_notification
_diversion.process_notification(device, status, n, feature)
File "/usr/lib/python3.9/site-packages/logitech_receiver/diversion.py", line 649, in process_notification
rules.evaluate(feature, notification, device, status, True)
File "/usr/lib/python3.9/site-packages/logitech_receiver/diversion.py", line 195, in evaluate
result = component.evaluate(feature, notification, device, status, result)
File "/usr/lib/python3.9/site-packages/logitech_receiver/diversion.py", line 195, in evaluate
result = component.evaluate(feature, notification, device, status, result)
File "/usr/lib/python3.9/site-packages/logitech_receiver/diversion.py", line 195, in evaluate
result = component.evaluate(feature, notification, device, status, result)
File "/usr/lib/python3.9/site-packages/logitech_receiver/diversion.py", line 570, in evaluate
subprocess.Popen(self.args)
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] Aucun fichier ou dossier de ce type: "solaar config 'MX Master 3' change-host 2:legiontux"
```

i tried 3 type of settings, which one is the good one?(on the same PC)
1) one line 'execute' and one argument:
```
- Key: Host Switch Channel 2                                                                                                                                                             
 'Execute: solaar config 'MX Master 3' change-host 2:legiontux solaar config 'MX Keys' change-host 2:legiontux
```                                                                                                    
2) one line 'execute' and two argument:                                                                                                                       
 ```
- Key: Host Switch Channel 2  
'Execute: solaar config 'MX Master 3' change-host 2:legiontux' 'solaar config 'MX Keys' change-host 2:legiontux' 
```              
3) two line 'execute' with one argument each:

```
Key: Host Switch Channel 2                                                                                                                                                             
  Execute: solaar config 'MX Master 3' change-host 2:legiontux                                                                                                                           
  Execute: solaar config 'MX Keys' change-host 2:legiontux
```

thank
How are you creating the rules (editing the rules.yaml file or via the GUI)?

Your error appears to be that Solaar cannot be run just as `solaar`.  You might have to put the actual location of the Solaar executable there.

You need to have two actions, one for the mouse and one for the keyboard.  The Solaar config command can't change settings for two devices.


Here are the rules that I actually use.  (I want to run out of my clone directory, not whatever Solaar I've installed, so I need the explicit location.)   That's option 3 from your message.  I've included all the necessary YAML syntax from my rules file.

```
---
- Key: Host Switch Channel 2
- Execute: [/home/local/SoftwareDownloads/Solaar/bin/solaar, config, MX, change-host,
    '2']
- Execute: [/home/local/SoftwareDownloads/Solaar/bin/solaar, config, Craft, change-host,
    '2:idefix']
...
---
- Key: Host Switch Channel 3
- Execute: [/home/local/SoftwareDownloads/Solaar/bin/solaar, config, MX, change-host,
    '3']
- Execute: [/home/local/SoftwareDownloads/Solaar/bin/solaar, config, Craft, change-host,
    '3:ppslaptop']
...
```



> How are you creating the rules (editing the rules.yaml file or via the GUI)?
via the GUI

> Your error appears to be that Solaar cannot be run just as solaar. You might have to put the >actual location of the Solaar executable there.

thx, i didn't know it.

an other thing is the fact to put each "argument" to an "argument  case" (rules editor) what i didn't

> You need to have two actions, one for the mouse and one for the keyboard. The Solaar config >command can't change settings for two devices.
like i thought

> Here are the rules that I actually use. (I want to run out of my clone directory, not whatever  
> Solaar I've installed, so I need the explicit location.) That's option 3 from your message. 
> I've included all the necessary YAML syntax from my rules file.

my final setting should be conforme PC1:
`- Key: Host Switch Channel 2                                           
- Execute: [/usr/bin/solaar, config, MX Keys, change-host, '2:PC2']        
 - Execute: [/usr/bin/solaar, config, MX Master 3, change-host, '2']
`
so the setting on PC1 (the one with receiver) works.

 But about PC2 (bluetooth) the setting do not works. 
when i hit the 'key1' the debug screen do not give me anymore error but the command give the same lines those PC1:
`Setting change-host of MX Master 3 Wireless Mouse to 2:legiontux
Setting change-host of MX Keys Keyboard to 2:legiontux`

my setting is conforme:
`- Key: Host Switch Channel 1                                           
- Execute: [/usr/bin/solaar, config, MX Keys, change-host, '1']        
- Execute: [/usr/bin/solaar, config, MX Master 3, change-host, '1']`
-
about the 'MX Keys' line i cannot paste the host name cause solaar do not know it...
Please provide output of Solaar with `-d` flag when you are trying to switch.
ok, all information that i will provide wil concerne PC2 = legiontux (the bluetooth one). PC1 is working.

when i switch PC2 -> PC1 i get these outputs:
```
07:25:39,109     INFO [ReceiverListener:hidraw7] logitech_receiver.diversion: Execute action: ['/usr/bin/solaar', 'config', 'MX Keys', 'change-host', '1']

07:25:39,117     INFO [ReceiverListener:hidraw7] logitech_receiver.diversion: Execute action: ['/usr/bin/solaar', 'config', 'MX Master 3', 'change-host', '1']

Setting change-host of MX Master 3 Wireless Mouse to 2:legiontux
Setting change-host of MX Keys Keyboard to 2:legiontux
```
the two first lines state my settings. however the two last lines state that solaar change PC2 for PC2 instead of PC1
OK, let me look into that.
It looks as if `solaar config` is trying to be smart, and failing.   You need to find the values that Solaar has for the change-host setting and make sure that you are using these values.   This is made "worse" because Solaar tries to be helpful for devices that don't keep track of host names so the values for these devices will be different on different machines.

So on machine A you want to use the value on machine A for the entry that is for machine B.   For devices that remember names this will be of the form `N:machinename`.   For devices that don't remember names this will just be `N`.

Solaar config also tries to be helpful by switching to entry N if N is not a value and is an integer so `solar config MX change-host 2` will switch to entry N, which in Python is the third entry.  In your case it appears that there is no entry with value `1` so the devices are being switched to entry 1 (the second entry).

I may upgrade config a bit to make this somewhat easier.
You can also run `solaar config "MX Master" XX`.  This will produce an error that has the possible values in it.
rue `solaar config "MX Master" XX`
give me:
```
`solaar: error: Traceback (most recent call last):

File "/usr/lib/python3.9/site-packages/solaar/cli/__init__.py", line 207, in run
m.run(c, args, _find_receiver, _find_device)

File "/usr/lib/python3.9/site-packages/solaar/cli/config.py", line 140, in run
raise Exception("no setting '%s' for %s" % (args.setting, dev.name))

Exception: no setting 'XX' for MX Master 3 Wireless Mouse`
```
Hmm.  I just tried `solaar config` and got a strange result.  I'm investigating.
There is a stupid bug in the code that is causing your strange results.  I'll fix it.


Oops,  `solaar config "MX Master 3" change-host XX`

ok ;)
solaar config "MX Master 3" change-host XX
give me:
```
`solaar: error: Traceback (most recent call last):

File "/usr/lib/python3.9/site-packages/solaar/cli/__init__.py", line 207, in run
m.run(c, args, _find_receiver, _find_device)

File "/usr/lib/python3.9/site-packages/solaar/cli/config.py", line 159, in run
value = select_choice(args.value_key, setting.choices, setting, None)

File "/usr/lib/python3.9/site-packages/solaar/cli/config.py", line 82, in select_choice
raise Exception('%s: possible values are [%s]' % (setting.name, ', '.join(str(v) for v in choices)))

Exception: change-host: possible values are [1, 2:legiontux, 3]
```
`
OK, let me fix the code.  You'll have to download and run from this repository.

ok no problem

Resolving patch:
diff --git a/lib/solaar/cli/config.py b/lib/solaar/cli/config.py
--- a/lib/solaar/cli/config.py
+++ b/lib/solaar/cli/config.py
@@ -58,12 +58,13 @@ def select_choice(value, choices, setting, key):
     ivalue = to_int(value)
     val = None
     for choice in choices:
-        if value == choice or ivalue is not None and ivalue == choice:
+        if value == str(choice):
             val = choice
+            break
     if val is not None:
         value = val
-    elif ivalue is not None and ivalue >= 0 and ivalue < len(choices):
-        value = choices[ivalue]
+    elif ivalue is not None and ivalue >= 1 and ivalue <= len(choices):
+        value = choices[ivalue - 1]
     elif lvalue in ('higher', 'lower'):
         old_value = setting.read() if key is None else setting.read_key(key)
         if old_value is None:


Test patch: