From f519c793bc9c0e0922c99e76963a6c8a080c4249 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 17 Feb 2020 11:38:46 +0100 Subject: [run-virt] Use beamergui -d for screen detection --- .../set_runvirt_hardware_variables.inc | 18 ++++++++++-------- .../vmchooser/run-virt.d/setup_virtual_floppy.inc | 21 ++++++++------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc index 91577f71..ae8172ee 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc @@ -151,13 +151,15 @@ set_serial_ports() { readonly SERIAL0 PARALLEL0 } -get_display_count() { - declare -g DISPLAY_COUNT="$(xrandr | grep -c -w 'connected')" - if ! [[ "$DISPLAY_COUNT" =~ ^[1-9]$ ]]; then - writelog "Weird monitor count detected ($DISPLAY_COUNT). Falling back to 1." - DISPLAY_COUNT=1 - fi - readonly DISPLAY_COUNT +get_displays() { + local list=$( mktemp ) + beamergui -d | grep -v '^#' > "$list" + # These are logical screens, ie. cloned outputs count only once + declare -g DISPLAY_COUNT="$( < "$list" wc -l || echo 1 )" + declare -g RESOLUTIONS="$( < "$list" awk '{printf "%dx%d ", $3, $4}' )" + RESOLUTIONS=${RESOLUTIONS% } # trim + readonly RESOLUTIONS DISPLAY_COUNT + rm -f -- "$list" } ## MAIN ## @@ -168,5 +170,5 @@ call_post_source \ set_virt_hostname \ set_serial_ports \ check_optical_drives \ - get_display_count + get_displays diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc index f589d2b6..fd62005f 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc @@ -105,24 +105,19 @@ setup_virtual_floppy() { SHARE_NO_HOME_WARN=0 fi - # Legacy: openslx.exe expects HOSTRES.TXT - local RESOLUTION=$(xrandr | grep -o -E 'connected\s*(primary)?\s*[0-9]+x[0-9]+\+0\+0' \ - | grep -o -E -m1 '[0-9]+x[0-9]+') - cat > "${FLOPPYDIR}/HOSTRES.TXT" <<-EOF - ${RESOLUTION} - EOF - - ( - echo '[openslx]' + local resolution= # Ugly hack for multi-monitor support with virtualbox. # The guest additions properly set up the resolutions of multiple # monitor, thus we need to disable the resolution feature of # the openslx.exe as it would break what virtualbox did. - if [ "$PLUGIN_ID" = "vmware" ] || [ "$PLUGIN_ID" = "virtualbox" -a "$DISPLAY_COUNT" -eq 1 ]; then - echo "resolution=$RESOLUTION" + if [ "$PLUGIN_ID" != "virtualbox" ] || [ "$DISPLAY_COUNT" -eq 1 ]; then + resolution="${RESOLUTIONS}" fi - cat <<-EOF + + cat > "${FLOPPYDIR}/openslx.ini" <<-EOF + [openslx] username=${UNAME} + resolution=${resolution} createMissingRemap=${SHARE_CREATE_MISSING_REMAP} remapMode=${SHARE_REMAP_MODE_INI} homeDrive=${SHARE_HOME_DRIVE} @@ -140,7 +135,7 @@ setup_virtual_floppy() { media=${SHARE_MEDIA} other=${SHARE_OTHER} EOF - ) > "${FLOPPYDIR}/openslx.ini" + ln -n -s "${VMCHOOSER_DIR}/data/openslx.exe" "${FLOPPYDIR}/openslx.exe" # If we have a kerberos ticket, copy that one too (TODO: Copy keytab too?) if [ -n "$KRB5CCNAME" ]; then -- cgit v1.2.3-55-g7522