aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-03-29 17:50:04 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-03-29 17:50:04 -0300
commit6d10ed52ca130aaabcb0ed27e198dc5d66426061 (patch)
treef2398c51d6a9b9a4df0164643460e4ddd8738755
parent1f01fb02bcf6d15d153a1c7ae5964a02551a14dc (diff)
downloadkvmx-6d10ed52ca130aaabcb0ed27e198dc5d66426061.tar.gz
kvmx-6d10ed52ca130aaabcb0ed27e198dc5d66426061.tar.bz2
Adds xrandr action
-rwxr-xr-xkvmx36
-rw-r--r--kvmxfile8
-rw-r--r--share/provision/files/desktop-basic/home/user/.custom/xsession10
3 files changed, 49 insertions, 5 deletions
diff --git a/kvmx b/kvmx
index c8d315b..139d530 100755
--- 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 $*
diff --git a/kvmxfile b/kvmxfile
index 5701f0d..08f9ffe 100644
--- 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"
diff --git a/share/provision/files/desktop-basic/home/user/.custom/xsession b/share/provision/files/desktop-basic/home/user/.custom/xsession
index 5e28203..d223263 100644
--- a/share/provision/files/desktop-basic/home/user/.custom/xsession
+++ b/share/provision/files/desktop-basic/home/user/.custom/xsession
@@ -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}