1

I have a script where I activate a shortcut after clicking a mouse button, but I need the window under the cursor to be focused for this to work. I tried sending a normal click before the shortcut, but it can cause accidental clicks. Is there a way to trigger a raise/focus to the window below the cursor?

madprops
  • 137

1 Answers1

0

I found a solution:

# Find the id of the window under the cursor
sedGetValue='s/.*=\(.*\)/\1/'
id=`xdotool getmouselocation --shell 2>/dev/null | grep WINDOW | sed "$sedGetValue"`

# Focus the window
wmctrl -iR "$id"
madprops
  • 137