Created
November 8, 2017 21:16
-
-
Save fractalbach/321844854a2a43ec0216f6856dbabb0c to your computer and use it in GitHub Desktop.
Custom Keyboard shortcut shell script, drag and drop mouse clicking with a keyboard key!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# xinput --list to identify the different input devices availiable to you. | |
# xinput query-state [device] where the device is a keyboard. Returns all the keys' states. | |
# xdotool mousedown 1 automates holding down the left mouse click. | |
# xdotool mouseup 1 automates releasing the left mouse click. | |
# This program begins by checking if the keyboard button is pressed at the time of its execution. | |
# If the keyboard button is in the DOWN position, then "press down" the mouse left click. | |
# wait for a bit (but not too long!), and then check the keyboard position again. | |
# Once the keyboard button has been released, break out of the loop, and "release" the mouse left click! | |
if [ $(xinput query-state 13 | grep 'key\[49' | sort) = "key[49]=down" ]; then | |
xdotool mousedown 1 | |
while [ $(xinput query-state 13 | grep 'key\[49' | sort) = "key[49]=down" ]; do | |
sleep 0.1 | |
xdotool key --repeat-delay DELAY 100 | |
done | |
fi | |
xdotool mouseup 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
xdotool key --repeat-delay DELAY 100
was added in to prevent the actual keypress from continuing. For example, It prevents you from typing "aaaaaaaaaaaaaaaaaaaaaaaaaaaa" while holding down a key.