Skip to content

Instantly share code, notes, and snippets.

@festival4799
Created December 28, 2023 12:02
Show Gist options
  • Select an option

  • Save festival4799/26ab23ac84d8b00a161baa10bd558d60 to your computer and use it in GitHub Desktop.

Select an option

Save festival4799/26ab23ac84d8b00a161baa10bd558d60 to your computer and use it in GitHub Desktop.
udev rule to dynamilcally change screen resolution of a libvirt guest with spice display
# /etc/udev/rules.d/50-x-resize.rules
ACTION=="change",KERNEL=="card0", SUBSYSTEM=="drm", RUN+="/usr/local/bin/x-resize"
#!/bin/sh
# /usr/local/bin/x-resize
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 '/ connected/{print $1; exit; }') --auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment