Skip to content

Instantly share code, notes, and snippets.

@atx
Created July 13, 2018 14:12
Show Gist options
  • Save atx/8f53b424e41e3fa1e6655c63632d2f7d to your computer and use it in GitHub Desktop.
Save atx/8f53b424e41e3fa1e6655c63632d2f7d to your computer and use it in GitHub Desktop.
Hacky script to support automatic screen resize with virt-manager VMs with arbitrary window manager (see https://bugzilla.redhat.com/show_bug.cgi?id=1352226 for details )
#! /bin/bash
if ! pgrep -u $(whoami) spice-vdagent; then
echo "Starting vdagent"
spice-vdagent
fi
INTERVAL=1
while true; do
# No multiple outputs supported
outname=$(xrandr | grep "^Virtual-" | head -n1 | cut -d' ' -f1)
if xrandr | grep "$outname" -A1 | tail -n1 | grep -vq '\*'; then
echo "Resizing..."
xrandr --output "$outname" --auto
fi
sleep $INTERVAL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment