summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data/opt/openslx/xscreensaver/ungrab.d/virt-viewer
blob: f4b1b8b47b9b7761541da7a6f287e3f23916604e (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)/virt-viewer-wins"

if [ "$1" = "pre" ]; then
	# Find all vmware windows currently visible
	WINDOWS=$( xdotool search --onlyvisible --class virt-viewer )
	[ -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
	# also this resets the idle time durr hurr
	xdotool mousemove 0 0
	usleep 10000
	xdotool mousemove --polar 0 0
	usleep 10000
	xdotool key "ctrl+alt+shift+super"
	usleep 10000
fi

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

exit 0