summaryrefslogtreecommitdiffstats
path: root/core/modules/vmware-common/data/opt/openslx/xscreensaver/ungrab.d/vmware
blob: 66e5eed4e3d9e4ad39cb13ee47bfc02c8ea0055c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/ash

wfile="/run/user/$(id -u)/vmwins"

if [ "$1" = "pre" ]; then
	# Find all vmware windows currently visible
	WINDOWS="$( xdotool search --onlyvisible --class vmplayer )"
	[ -z "$WINDOWS" ] && exit 0
	for window in $WINDOWS; do
		xdotool windowminimize "$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 click 1
	usleep 10000
	xdotool mousemove --polar 0 0
	usleep 10000
fi

if [ "$1" = "post" ]; then
	# let's restore vmware
	WINDOWS="$( sort -u "$wfile" )"
	for window in $WINDOWS; do
		xdotool windowmap "$window"
	done
	rm -f -- "$wfile"
fi

exit 0