Skip to content

Bind mouse buttons #240

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

Closed
perdakovich opened this issue Mar 30, 2024 · 9 comments
Closed

Bind mouse buttons #240

perdakovich opened this issue Mar 30, 2024 · 9 comments

Comments

@perdakovich
Copy link

perdakovich commented Mar 30, 2024

Add an ability to bind mouse side buttons (button8, button9 and more) in the Keyboard -> Shortcuts settings.

Currently I solve it by running sxhkd with a config like that:

super + button8
	xdotool set_desktop --relative -- -1

super + button9
	xdotool set_desktop --relative -- 1

@SpencerLommel
Copy link
Contributor

So are mouse side buttons 1-7 available and just not 8 and 9? I don't have a mouse with that many buttons but I could look into fixing this!

@perdakovich
Copy link
Author

perdakovich commented Apr 18, 2025

https://wiki.archlinux.org/title/Sxhkd

Mouse hotkeys can be defined by using one of the following special keysym names: button1, button2, button3, ..., button24.

For example, button1 is LMB and button2 is RMB, the side buttons for me are button8 and button9.
Other buttons I don't know.
Perhaps it differs from device to device, no clue

@perdakovich
Copy link
Author

So are mouse side buttons 1-7 available and just not 8 and 9?

You can't bind any mouse button at all in Cinnamon

@SpencerLommel
Copy link
Contributor

@Goosegit11 I was looking into ways this could be implemented and I think in the Keyboard section would probably be the best

Image

Like here you could assign a mouse button as a "keyboard" binding.

I haven't really looked into mouse button bindings much but what do you think of this idea? would there be any missing functionality if it was implemented this way?

@perdakovich
Copy link
Author

perdakovich commented Apr 20, 2025

This is exactly what I am proposing

@claudiux
Copy link
Member

Parts of sound150@claudiux applet, if that can help:

const Applet = imports.ui.applet;
const Cinnamon = imports.gi.Cinnamon;
const Clutter = imports.gi.Clutter;

    _onButtonPressEvent(actor, event) {
        let buttonId = event.get_button();
        let modifiers = Cinnamon.get_event_state(event);
        let shiftPressed = (modifiers & Clutter.ModifierType.SHIFT_MASK);
        let ctrlPressed = (modifiers & Clutter.ModifierType.CONTROL_MASK);

        // 
        if (buttonId === 2) { // middle-click
            if (shiftPressed || ctrlPressed) {
                // Here your code
            } else {
                // Here your code
            }
        } else if (buttonId === 8) { // on mouse button 4 (8 by X11 numbering)
            // Here your code
        } else if (buttonId === 9) { // on mouse button 5 (9 by X11 numbering)
           // Here your code
        } else {
            return Applet.Applet.prototype._onButtonPressEvent.call(this, actor, event);
        }
        return Clutter.EVENT_STOP;
    }

@SpencerLommel
Copy link
Contributor

I started working on this yesterday and actually got it working! I'm just cleaning up my implementation and organizing it a bit before I make a PR.

Also another note, the Keyboard applet and the shortcut logic is actually handled in teh cinnamon repo instead of this cinnamon-desktop one. Here is a link to the file for the Keyboard Applet

I will be opening an issue there to track my progress and I'll put a link to it here just so everything stays in the correct place

@SpencerLommel
Copy link
Contributor

Here is the issue opened in the correct spot! linuxmint/cinnamon#12840

@claudiux I'm not sure if you can close issues, but this one could probably be closed with a message to check the other issue in the correct place.

@perdakovich
Copy link
Author

looking forward to try it out :-)

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

No branches or pull requests

3 participants