]> gitweb.fluxo.info Git - kvmx.git/commitdiff
XrandR: honor resolution and cli param
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 15 Nov 2018 13:18:15 +0000 (11:18 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 15 Nov 2018 13:18:15 +0000 (11:18 -0200)
kvmx

diff --git a/kvmx b/kvmx
index 0420211479a355b6ad9b78ca3033cd139d89349d..8e00fc1ac6bee37f0fdbe9d75a225a7a33b9ac86 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -1998,6 +1998,8 @@ function kvmx_shell {
 
 # Xrandr integration
 function kvmx_xrandr {
+  local size="$1"
+
   if ! kvmx_running; then
     echo "$BASENAME: guest $VM is not running"
     exit 1
@@ -2009,13 +2011,20 @@ function kvmx_xrandr {
   fi
 
   if echo which xrandr | kvmx_ssh &> /dev/null; then
-    local mode="`xrandr | grep '*+' | awk '{ print $1 }' | tr 'x' ' '`"
+    # Check for resolution configuration or explicit param
+    if [ ! -z "$size" ]; then
+      mode="`echo $size | tr 'x' ' '`"
+    elif [ ! -z "$resolution" ]; then
+      mode="`echo $resolution | tr 'x' ' '`"
+    else
+      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 }'`"
+      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))"
+        mode="$x $(($y $resolution_y_offset))"
+      fi
     fi
 
     if [ -z "$xrandr_device" ]; then