]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Detect resolution dynamically at kvmx_xephyr
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 3 Oct 2017 14:26:46 +0000 (11:26 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 3 Oct 2017 14:26:46 +0000 (11:26 -0300)
kvmx

diff --git a/kvmx b/kvmx
index 256bccb7677df780596f6cf853b11748ae40763e..1776d58ea664f59d233698fb712aa42af7ba913d 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -1075,8 +1075,23 @@ function kvmx_xephyr {
   GUEST_DISPLAY="`cat $DISPLAYFILE`"
   XDMCP_PORT="`cat $XDMCPPORTFILE`"
 
+  # Check for resolution configuration
   if [ ! -z "$resolution" ]; then
     resolution="-screen $resolution"
+  else
+    # Detect resolution dynamically
+    if which xwininfo &> /dev/null; then
+      resolution="`xwininfo -root | grep -- '-geometry' | cut -d '+' -f 1 | sed -e 's/-geometry//'`"
+
+      # Check for resolution_x_offset and resolution_y_offset configuration
+      if [ ! -z "$resolution_x_offset" ] || [ ! -z "$resolution_y_offset" ]; then
+        local width="`echo $resolution  | cut -d 'x' -f 1`"
+        local height="`echo $resolution | cut -d 'x' -f 2`"
+        resolution="$(($width $resolution_x_offset))x$(($height $resolution_y_offset))"
+      fi
+
+      resolution="-screen $resolution"
+    fi
   fi
 
   if ! which Xephyr &> /dev/null; then