#!/bin/ash wfile="/run/user/$(id -u)/vmwins" if [ "$1" = "pre" ]; then # Find all VirtualBox windows currently visible WINDOWS="$( xdotool search --onlyvisible --class VirtualBoxVM )" [ -z "$WINDOWS" ] && exit 0 for window in $WINDOWS; do # minimize doesn't work for virtualbox... xdotool windowunmap --sync $window echo "$window" >> "$wfile" # Remember for later done # move mouse pointer around to avoid some problems with ghost clicks xdotool mousemove --sync 0 0 usleep 10000 xdotool mousemove --polar 0 0 usleep 10000 fi if [ "$1" = "post" ]; then # let's restore the windows WINDOWS="$( sort -u "$wfile" )" for window in $WINDOWS; do xdotool windowmap $window done rm -f -- "$wfile" fi exit 0