Skip to content

Instantly share code, notes, and snippets.

@TheFern2
Created April 11, 2024 18:54
Show Gist options
  • Save TheFern2/d16cf87bea50eba1a9907ef1d7dc4166 to your computer and use it in GitHub Desktop.
Save TheFern2/d16cf87bea50eba1a9907ef1d7dc4166 to your computer and use it in GitHub Desktop.
UTM VM resize script and udev rule

source: utmapp/UTM#4064 (comment)

Hi, just adding a more elegant way of making dynamic resolution. We gonna just use the udev event for that.

YOU MUST have installed :

sudo systemctl start spice-vdagent
sudo systemctl enable spice-vdagent

Here is my config files for the udev rule :

sudo cat /etc/udev/rules.d/10-resize.rules
ACTION=="change",KERNEL=="card0", SUBSYSTEM=="drm", RUN+="/usr/local/bin/resize"

Now the script it trigger :

sudo cat /usr/local/bin/resize            
#! /bin/sh 
PATH=/usr/bin
desktopuser=$(/bin/ps -ef  | /bin/grep -oP '^\w+ (?=.*vdagent( |$))') || exit 0
export DISPLAY=:0
export XAUTHORITY=$(eval echo "~$desktopuser")/.Xauthority
xrandr --output "$(xrandr | awk '{if($0 ~/ connected/){print $1}}')" --auto

The script take account of the possibility that the monitor is not named Virtual-1

I can confirm that's not an issue from UTM because i apply similar workaround for almost every Kali install i do. And it is also a bug that have been signaled for years without any real fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment