summaryrefslogtreecommitdiffstats
path: root/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/run-virt.include
blob: 24debedd8ca5728aeb4372a6102caaef4542451b (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -----------------------------------------------------------------------------
#
# Copyright (c) 2009..2018 bwLehrpool-Projektteam
#
# This program/file is free software distributed under the GPL version 2.
# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
#
# If you have any feedback please consult https://bwlehrpool.de and
# send your feedback to support@bwlehrpool.de.
#
# General information about bwLehrpool can be found at https://bwlehrpool.de
#
# -----------------------------------------------------------------------------
# run-virt.include
#    - component for vmware/player of the vmchooser plugin vmchooser-run_virt
################################################################################

# BASH_SOURCE[0] contains the file being sourced, namely this one
declare -rg VMWARE_PLUGIN_DIR="$(dirname "${BASH_SOURCE[0]}")"
declare -rg VMWARE_INCLUDE_DIR="${VMWARE_PLUGIN_DIR}/includes"

# TODO make this part of the metadata coming from the server
# Define which features the VMware plugin supports
declare -rg PLUGIN_FEATURES="firewall printer usb slxfloppy sound netshares"

run_plugin() {
	# declaration of default functions and variables for vmware
	$(safesource --exit "${VMWARE_INCLUDE_DIR}/init_core.inc")
	
	# get information from downloaded vmx
	$(safesource "${VMWARE_INCLUDE_DIR}/parse_vmx.inc")
	
	# determine limitations wrt RAM and CPU count of VM
	$(safesource "${VMWARE_INCLUDE_DIR}/determine_hardware_limitations.inc")
	
	# create preferences file ${HOME}/.vmware/preferences
	$(safesource "${VMWARE_INCLUDE_DIR}/create_vmhome_preferences_file.inc")
	
	# parse the given vmx file
	$(safesource "${VMWARE_INCLUDE_DIR}/write_final_vmx.inc")
	
	# print summary - needs writelog() from vmchooser-run_virt
	$(safesource "${VMWARE_INCLUDE_DIR}/log_config_summary.inc")
	
	# For debugging
	cp "$VM_RUN_FILE" "/tmp/vmware-last-config"

	# If we have multi-screen, try to switch to blackbox, seems the only
	# lean WM to handle this properly.
	if [ "$DISPLAY_COUNT" -gt 1 ] && command -v xfwm4 > /dev/null; then
		start_wm "xfwm4"
	fi

	# HACK: make the mouse disappear
	(
		local WINDOWS="$(xdotool search --sync --name '.*VMware.*Player.*')"
		isempty WINDOWS && writelog "Could not find any vmplayer windows."
		for WINDOW in $WINDOWS; do
			xdotool set_desktop_for_window $WINDOW 0 || writelog "Could not move vmplayer to desktop 0"
			xdotool windowactivate --sync $WINDOW || writelog "Could not activate vmplayer window"
			xdotool key --delay 2000 --clearmodifiers ctrl+g || writelog "Could not send ctrl+g to vmplayer window"
		done
	) &
	
	# HACK: using the modified version of the wrapper script
	declare -rg VIRTCMD="/opt/openslx/bin/vmplayer"
	# -X for fullscreen, plus VMX file
	VIRTCMDOPTS+=( "-X" "${VM_RUN_FILE}" )
}