When I click middle mouse button, and current window name is "Visual Studio Code", instead of middle mouse click do left mouse click and then F12. I am using Fedora.
To achieve this behavior in Fedora, you can use a combination of xdotool and a custom script. Here's a step-by-step guide:
-
Install xdotool: This is a command-line tool that allows you to simulate keyboard and mouse input.
sudo dnf install xdotool
-
Create a script: This script will check the current window name and perform the desired actions.
Create a new script file, e.g.,
middle_click_script.sh
:nano ~/middle_click_script.sh
Add the following content to the script:
#!/bin/bash # Get the active window name WINDOW_NAME=$(xdotool getactivewindow getwindowname) # Check if the active window is "Visual Studio Code" if [[ "$WINDOW_NAME" == *"Visual Studio Code"* ]]; then # Simulate left mouse click xdotool click 1 # Workaround to add sleep and another click sleep 0.1 xdotool click 1 # Simulate F12 key press xdotool key F12 else # Forward middle mouse click if the active window is not "Visual Studio Code" xdotool click 2 fi
Save and close the file.
-
Make the script executable:
chmod +x ~/middle_click_script.sh
-
Bind the script to the middle mouse button:
You can use
xbindkeys
to bind the middle mouse button to your script. First, install xbindkeys:sudo dnf install xbindkeys
Create a default configuration file for xbindkeys:
xbindkeys --defaults > ~/.xbindkeysrc
Edit the configuration file:
nano ~/.xbindkeysrc
Add the following line to bind the middle mouse button to your script:
"bash ~/middle_click_script.sh" b:2
Save and close the file.
-
Start xbindkeys:
xbindkeys
To make sure xbindkeys starts automatically on login, add it to your startup applications. The way to do this might vary depending on your desktop environment.
By following these steps, clicking the middle mouse button while the active window is "Visual Studio Code" will simulate a left mouse click followed by an F12 key press. In all other cases, it will perform the standard middle mouse click.
fuck it