Switching focus in bash script
<p>Please help me understand the source of a little issue I have when <strong>trying to make a windows loose focus</strong> in a Bash script invoked with a hotkey combination in Openbox on Linux.</p>

<p>I have a couple of lines in the script:</p>

<pre><code>wmctrl -F -r "${TERMINAL_TITLE}" -b add,shaded,below
xdotool key alt+Tab
</code></pre>

<p>The first line shades the window in question and "drops" it below all the other but it remaines focused. The second line should in theory move focus to the next window in stack…</p>

<p>…and it does! But only if the script in run with gmrun, or in the terminal itself (because the window i'm trying to hide &amp; defocus is a terminal emulator). </p>

<p>However it doesn't work as intended if the script is invoked with an Openbox hotlkey (which is what I need), or run in a heignbour terminal (just for a test). </p>

<p>I'm not a proficient bash user by any means. I can ususally knock together a simple script here and there for my humble needs but here I'm just lost. Will appreciate an advice.</p>