Skip to content

Instantly share code, notes, and snippets.

@s-zeid
Created August 19, 2017 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-zeid/8ca170c629c35ca1b31d47c44074ca46 to your computer and use it in GitHub Desktop.
Save s-zeid/8ca170c629c35ca1b31d47c44074ca46 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Thanks to Zorawar on unix.stackexchange: <https://unix.stackexchange.com/a/202489>
KEYBOARD_ID=12 # from `xinput list`
press="key press "
release="key release"
super=133
time_ms() {
local x=0
x=$(date +%s%N)
printf '%s' $((x / 1000000))
}
last=$(time_ms)
xinput test "$KEYBOARD_ID" | while read i; do
now=$(time_ms)
if [ x"$i" = x"$press $super" ]; then
last=$now
elif [ x"$i" = x"$release $super" ]; then
if [ $((now - last)) -lt 10 ]; then
xdotool click --clearmodifiers 3 mouseup 3
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment