pwr-Solaar / Solaar

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

Rules help #2639

Open scarlion1 opened 2 weeks ago

scarlion1 commented 2 weeks ago

Hi sorry if this is not the place for help let me know if there is a forum or something, but...

I'd like to manipulate the middle button on my M705.  I've had some minor success with the rules but not exactly what I wanted, but then I realized there are some things the middle button did that I took for granted, like opening links in new tabs and closing tabs.

What I would like is for the middle button, when clicked, presses the Super_L key, so I can manipulate a window with left click (move) or right-click (resize).  Then, when middle button clicked again, releases Super_L.  I guess that's pretty complicated because I realized there needs to be conditions to check if Super_L is already pressed or not.  Currently, I was able to make rules so that middle button pressed presses Super_L and when released releases Super_L.  In this way I can move a window around by pressing middle button and left button and then dragging the window.  This is awkward with pressing both middle and left mouse buttons, since I usually use my index finger for both and they are so close, but it works (these are actually sub-rules but the YAML just says "Rule"):

---
- Rule:
  - Key: [Middle Button, pressed]
  - KeyPress:
    - Super_L
    - depress
- Rule:
  - Key: [Middle Button, released]
  - KeyPress:
    - Super_L
    - release
...

Secondly, since I still want the original middle click function, I thought I could make a rule that, for example, when I hold Shift_L and use the middle button, it does the normal middle function.  I tried the following rule (again with sub-rules) but it has no effect:

---
- Rule:
  - And:
    - KeyIsDown: Left Shift
    - Key: [Middle Button, pressed]
  - MouseClick: [middle, depress]
- Rule:
  - And:
    - KeyIsDown: Left Shift
    - Key: [Middle Button, released]
  - MouseClick: [middle, release]
...

So how's it possible to achieve what I'd like? Thanks

pfps commented 2 weeks ago

From https://pwr-solaar.github.io/Solaar/rules:

Key is down

KeyIsDown conditions are true if the diverted key or button that is their string argument is currently down. Note that this only works for diverted keys or buttons, including diverted Gn, Mn, and MR keys.

So unless you can divert Left Shift, this rule will not work.

From https://pwr-solaar.github.io/Solaar/rules:

Key modifiers

Modifiers conditions take either a string or a sequence of strings, which can only be Shift, Control, Alt, and Super. Modifiers conditions are true if their argument is the current keyboard modifiers.

But this only works on X11 due to the stringent security characteristics of Wayland.