Skip to content

Instantly share code, notes, and snippets.

@talwrii
Last active March 6, 2025 20:41
Show Gist options
  • Save talwrii/14dbada36be9e12c919a6d3fa6bebe6a to your computer and use it in GitHub Desktop.
Save talwrii/14dbada36be9e12c919a6d3fa6bebe6a to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script clciks on the other window and presses enter
current_window=$(json-wmctrl | jq 'select(.focus) | .id')
# Extract x and y coordinates from the output
x=$(xdotool getmouselocation | cut -d ' ' -f 1 | cut -d ':' -f 2)
y=$(xdotool getmouselocation | cut -d ' ' -f 2 | cut -d ':' -f 2)
# Move x to the other side of the screen by mirroring along the middle
xdotool mousemove $((1920 - x)) $y
xdotool click 1
xdotool key Up
# press enter with xdotool
xdotool key Return
xdotool mousemove $x $y
wmctrl -i -a "$current_window"
@talwrii
Copy link
Author

talwrii commented Mar 6, 2025

This is a little script to press return in the "other window" when you have two windows open. It uses a little tool called json-wmctrl available in pypi to get the current window.

If you are interested in small tools like this you might like to

  1. Have a look at my collection of command line tools
  2. Read the Technical miscellany section of my blog
  3. Follow me on X where I tend to write about this sort of thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment