]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds xrandr action
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 29 Mar 2018 20:50:04 +0000 (17:50 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 29 Mar 2018 20:50:04 +0000 (17:50 -0300)
kvmx
kvmxfile
share/provision/files/desktop-basic/home/user/.custom/xsession

diff --git a/kvmx b/kvmx
index c8d315bf66d637c74359077814313495229ee2ac..139d5306f49bfdd4f986ac2f990cbd8e0d435206 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -500,6 +500,12 @@ function kvmx_up {
       done
       IFS="$old_ifs"
     fi
+
+    if [ "$xrandr" == "1" ]; then
+      echo "Waiting for X11 to come up so we can set machine resolution..."
+      sleep 8
+      kvmx_xrandr
+    fi
   fi
 
   if [ "$run_xpra" == "1" ]; then
@@ -1692,6 +1698,36 @@ function kvmx_shell {
   done
 }
 
+# Xrandr integration
+function kvmx_xrandr {
+  if ! kvmx_running; then
+    echo "$BASENAME: guest $VM is not running"
+    exit 1
+  fi
+
+  local mode="`xrandr | grep '*+' | awk '{ print $1 }' | tr 'x' ' '`"
+
+  if [ ! -z "$resolution_y_offset" ]; then
+    local x="`echo $mode | awk '{ print $1 }'`"
+    local y="`echo $mode | awk '{ print $2 }'`"
+
+    mode="$x $(($y $resolution_y_offset))"
+  fi
+
+  if [ -z "$xrandr_device" ]; then
+    xrandr_device="Virtual-0"
+  fi
+
+  local line="`cvt $mode  | tail -1   | sed -e 's/^Modeline//'`"
+  local name="`echo $line | awk '{ print $1 }'`"
+
+  echo "Setting Modeline $line..."
+
+  echo DISPLAY=:0 xrandr --newmode                       $line | kvmx_ssh
+  echo DISPLAY=:0 xrandr --addmode $xrandr_device        $name | kvmx_ssh
+  echo DISPLAY=:0 xrandr --output  $xrandr_device --mode $name | kvmx_ssh
+}
+
 # Dispatch
 if type kvmx_$ACTION 2> /dev/null | grep -q "kvmx_$ACTION ()"; then
   __kvmx_initialize $*
index 5701f0d8fc6d528c43b9e6f0a11a613e04708939..08f9ffedb835598a41a1114581fada6e40ce52f9 100644 (file)
--- a/kvmxfile
+++ b/kvmxfile
@@ -83,6 +83,14 @@ run_xpra="0"
 # Set this if you want to start an xephyr session when the machine boots.
 run_xephyr="0"
 
+# Set this if you want kvmx to redimension the guest screen according to host's screen dimension
+# Requires ssh_support and xrandr installed on both host and guest
+xrandr="0"
+
+# Xrandr device
+#xrandr_device="qxl-0"
+#xrandr_device="Virtual-0"
+
 # Set screen resolution
 #resolution="1280x785"
 
index 5e2820353b8d4282f10118dff30a0ddbafc6f90e..d223263c7c8953719da44c019c5d3d7741e80e86 100644 (file)
@@ -10,16 +10,16 @@ DISPLAY_DEVICE="Virtual-0" # or maybe qlx-0
 #
 
 # Modeline determined by running "cvt 1280 780"
-xrandr --newmode "1280x780_60.00"   81.50  1280 1352 1480 1680  780 783 793 810 -hsync +vsync
-xrandr --addmode $DISPLAY_DEVICE 1280x780_60.00
+#xrandr --newmode "1280x780_60.00"   81.50  1280 1352 1480 1680  780 783 793 810 -hsync +vsync
+#xrandr --addmode $DISPLAY_DEVICE 1280x780_60.00
 
 # Modeline determined by running "cvt 1368 748"
-xrandr --newmode "1368x748_60.00"   83.00  1368 1440 1576 1784  748 751 761 777 -hsync +vsync
-xrandr --addmode $DISPLAY_DEVICE 1368x748_60.00
+#xrandr --newmode "1368x748_60.00"   83.00  1368 1440 1576 1784  748 751 761 777 -hsync +vsync
+#xrandr --addmode $DISPLAY_DEVICE 1368x748_60.00
 
 # Set default modeline
 #xrandr --output $DISPLAY_DEVICE --mode 1368x748_60.00
-xrandr --output $DISPLAY_DEVICE --mode 1280x780_60.00
+#xrandr --output $DISPLAY_DEVICE --mode 1280x780_60.00
 
 # Workaround for programs that depend on a system fully operational
 # Example: chromium browser running with firejail when your ${DOWNLOADS}