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
  • 129
  • 1
  • 1
  • 5
  • 1
    Have a look at `wmctrl`. I don't use KDE, so I don't know if it will work with KDE. Anyhow, you need to communicate with KDE's window manager to achieve this, if not with `wmctrl`, then through some KDE-specific mechanism. – dirkt May 23 '20 at 05:31

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
  • 129
  • 1
  • 1
  • 5