From 4a54b6e00cb6f8b7fbfb403a3f1895f7956d4364 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 27 Apr 2024 20:46:23 -0700 Subject: [PATCH] Improve resolution detection when run in a VM --- setup/linux/profile/airootfs/etc/skel/.update_x | 9 +++++++++ setup/linux/profile/airootfs/etc/skel/.zlogin | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/setup/linux/profile/airootfs/etc/skel/.update_x b/setup/linux/profile/airootfs/etc/skel/.update_x index 95eb986f..a34fec11 100755 --- a/setup/linux/profile/airootfs/etc/skel/.update_x +++ b/setup/linux/profile/airootfs/etc/skel/.update_x @@ -2,8 +2,17 @@ # ## Calculate DPI, update settings if necessary, then start desktop apps +MONITOR=$(xrandr --listmonitors | grep -E '^\s+[0-9]' | head -1 | sed -r 's/^.*\s+(.*)$/\1/') REGEX_XRANDR='^.* ([0-9]+)x([0-9]+)\+[0-9]+\+[0-9]+.* ([0-9]+)mm x ([0-9]+)mm.*$' +# Resize screen in VMs +if lsmod | grep -Eq 'qxl|virtio_gpu'; then + echo -n "Starting VM guest services..." + spice-vdagent + sleep 0.5 + xrandr --output "${MONITOR}" --auto +fi + echo -n "Getting display details... " # Get screen data diff --git a/setup/linux/profile/airootfs/etc/skel/.zlogin b/setup/linux/profile/airootfs/etc/skel/.zlogin index 8ecba0a8..b91b220c 100644 --- a/setup/linux/profile/airootfs/etc/skel/.zlogin +++ b/setup/linux/profile/airootfs/etc/skel/.zlogin @@ -1,5 +1,10 @@ setterm -blank 0 -powerdown 0 2>/dev/null if [ "$(fgconsole 2>/dev/null)" -eq "1" ]; then + # VM guest init + if lsmod | grep -Eq 'qxl|virtio_gpu'; then + systemctl start spice-vdagentd.service + fi + # Set up teststation details $HOME/.setup_teststation