#!/bin/sh # focus the top-most window, i.e. the window just mapped topmost() { xwininfo -root -children | awk '/^ *0x/{ print $1; exit; }' } [[ "$1" != "" ]] && sleep 0.5 xdotool windowfocus $( topmost )