VBoxRandR.sh revision 3e86e8ef6a669cf893ebca28e03a668402ac022d
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#!/bin/sh
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
5b281ba489ca18f0380d7efc7a5108b606cce449vboxsync# @file
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# Sun VirtualBox
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# X11 guest additions: dynamic display changes
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync#
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# Copyright (C) 2008-2009 Sun Microsystems, Inc.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# available from http://www.virtualbox.org. This file is free software;
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# you can redistribute it and/or modify it under the terms of the GNU
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# General Public License (GPL) as published by the Free Software
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# Clara, CA 95054 USA or visit http://www.sun.com if you need
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# additional information or have any questions.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# In order to keep things simple, we just call the X11 xrandr application
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# when we receive notification of a display change instead of reimplementing
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# it inside our Guest Additions client application. This saves us among
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# other things having to find ways to build and link the C code on systems
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync# which do not support RandR 1.2. We wrap the call to xrandr in this script
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# so that we can make any fiddly adjustments to the call which may be needed.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync#
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsyncxorgbin=Xorg
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsyncfound=`which Xorg | grep "no Xorg"`
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsyncif test ! -z "$found"; then
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync if test -f "/usr/X11/bin/Xorg"; then
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync xorgbin=/usr/X11/bin/Xorg
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync else
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync exit 1
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync fi
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsyncfi
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsyncrandrbin=xrandr
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsyncfound=`which xrandr | grep "no xrandr"`
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsyncif test ! -z "$found"; then
0a7b20727716a00270f358a1c546473d8c36e8f3vboxsync if test -f "/usr/X11/bin/xrandr"; then
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync randrbin=/usr/X11/bin/xrandr
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync else
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync exit 1
3aad980b92149dd95a1ab72ddb8d11d61a28ace6vboxsync fi
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncfi
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncrefreshbin=xrefresh
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncfound=`which xrefresh | grep "no xrefresh"`
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncif test ! -z "$found"; then
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if test -f "/usr/X11/bin/xrefresh"; then
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync refreshbin=/usr/X11/bin/xrefresh
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync else
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync exit 1
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync fi
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncfi
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# If we were called with the --test parameter, we check whether the display
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# we are running on is really using the VBox video driver (and RandR 1.2),
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# and whether we are running on a buggy version of X.Org which might crash
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# when we resize.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncif test "$1" = "--test"; then
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync # Check for buggy X.Org versions
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync xout=`$xorgbin -version 2>&1`
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync if echo "$xout" | grep "1\.4\.99\.90[12345]" > /dev/null
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync then
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync echo "Warning: the version of the X Window system on your guest has known"
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync echo "problems which prevent dynamic resizing and seamless mode from working."
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync echo
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync exit 1
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync fi
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync # Don't write out error information in this case, as this script is also
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync # called from the installer, and vboxvideo will not yet be in place yet in
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync # that case.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync $randrbin 2> /dev/null | grep VBOX1 > /dev/null
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync exit
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsyncfi
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# Otherwise we just switch the guest display into its preferred resolution,
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync# which is the one corresponding to the last video mode hint sent by the host.
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync$randrbin --output VBOX1 --preferred
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync$refreshbin 2>&1 > /dev/null
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync
9e5c26690d45216629b5f588aced8fcfb68c23b6vboxsync