#!/bin/bash function has_active_window { xprop -root -f _NET_ACTIVE_WINDOW 32c ' $0\n' _NET_ACTIVE_WINDOW | awk '{ exit $2 == 0 }' } while true; do if ! has_active_window; then xdotool search --onlyvisible --class xfdesktop windowfocus fi sleep 5 done &> /dev/null