Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mouse buttons bindings #761

Open
xaltsc opened this issue Oct 26, 2024 · 7 comments · May be fixed by #865
Open

Allow mouse buttons bindings #761

xaltsc opened this issue Oct 26, 2024 · 7 comments · May be fixed by #865
Labels
enhancement New feature or request

Comments

@xaltsc
Copy link

xaltsc commented Oct 26, 2024

From what I can tell, it's currently impossible to bind a mouse button to an action. For my use, I wish to use the next/previous (side/extra, 275, 276 as reported by wev) button (with M+) to focus left/right columns.

The issue seems to be in the Trigger enum which only defines keysyms and scroll triggers.

System Information

  • niri version:
    niri unstable 2024-10-06 (commit 5fc669c)
  • Distro:
    Void Linux + Home-Manager (niri installed through niri.flake)
  • GPU:
    Intel TigerLake-LP GT2
  • CPU:
    Intel i7-1165G7
@xaltsc xaltsc added the bug Something isn't working label Oct 26, 2024
@YaLTeR YaLTeR added enhancement New feature or request and removed bug Something isn't working labels Oct 26, 2024
@Paul-Eau
Copy link

I made a simple script that I'm working on to work around this issue. It uses evtest to read mouse input. But be aware that this may interfere with other shortcuts used by other software (backward / forward in Firefox for example).

#!/bin/bash

MOUSE="/dev/input/event6" 
KEYBOARD="/dev/input/event4"
MOD_STATE_FILE="/tmp/mod_pressed_state"  

echo "false" > "$MOD_STATE_FILE"


evtest "$KEYBOARD" | while read -r line; do
    if [[ "$line" == *"code 125"* && "$line" == *"value 1"* ]]; then
        echo "true" > "$MOD_STATE_FILE"  
        echo "Mod pressed"
    fi

    if [[ "$line" == *"code 125"* && "$line" == *"value 0"* ]]; then
        echo "false" > "$MOD_STATE_FILE"  
        echo "Mod not pressed"
    fi
done &


evtest "$MOUSE" | while read -r line; do
    mod_pressed=$(cat "$MOD_STATE_FILE")

    if [[ "$mod_pressed" == "true" && "$line" == *"code 275"* && "$line" == *"value 1"* ]]; then
        niri msg action focus-column-left
    fi

    if [[ "$mod_pressed" == "true" && "$line" == *"code 276"* && "$line" == *"value 1"* ]]; then
        niri msg action focus-column-right
    fi
done

@salman-farooq-sh
Copy link
Contributor

salman-farooq-sh commented Nov 29, 2024

I also need this as I just got a mouse with these two buttons. Is it a simple change? @YaLTeR

@YaLTeR
Copy link
Owner

YaLTeR commented Nov 29, 2024

It is not a very simple change, a lot of types there are hardcoded for keyboard.

@salman-farooq-sh
Copy link
Contributor

salman-farooq-sh commented Nov 29, 2024

I guess @Paul-Eau's workaround looks good then until this gets done properly.

Edit: I just tested it and it causes firefox to go back and forth in the tab history. Any suggestions to solve this with/without grabbing the mouse exclusively?

@armerpunkt
Copy link

Edit: I just tested it and it causes firefox to go back and forth in the tab history. Any suggestions to solve this with/without grabbing the mouse exclusively?

In about:config set mousebutton.4th.enabled and mousebutton.5th.enabled to false.

@salman-farooq-sh
Copy link
Contributor

bbb651 added a commit to bbb651/niri that referenced this issue Dec 13, 2024
I don't know the history behind `BTN_BACK == BTN_SIDE` and `BTN_FORWARD == BTN_EXTRA`,
but evcompatibilityeryone seems to be doing it so if it's "wrong" it's better for compatability.
It's my fault it's like that on winit too :P

Fixes YaLTeR#761.
bbb651 added a commit to bbb651/niri that referenced this issue Dec 13, 2024
I don't know the history behind `BTN_BACK == BTN_SIDE` and `BTN_FORWARD == BTN_EXTRA`,
but everyone seems to be doing it so if it's "wrong" it's better for compatability.
It's my fault it's like that on winit too :P

Fixes YaLTeR#761.
@bbb651 bbb651 linked a pull request Dec 13, 2024 that will close this issue
@bbb651
Copy link
Contributor

bbb651 commented Dec 14, 2024

If your mouse supports libratbag (which you can use either through ratbagctl or piper) you can also use button remapping as a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants