Hi,
I could not find an easy way to scale VM screens (changing DPI), therefore came up with a script to do that.
One can run the script through an xfce terminal in the VM or through qvm-run from dom0.
qvm-run -p my-xfce-vm bash -c "/usr/bin/qubes-scale.sh 1.25"
/usr/bin/qubes-scale.sh 1.25
Scales the VM quickly. No need to manually edit files.
#!/usr/bin/env bash
# ==============================================================================
# qubes-scale - Runtime DPI and UI scaling for Qubes OS X11 AppVMs
#
# Usage:
# qubes-scale [SCALE]
# qubes-scale [-h | --help]
#
# Arguments:
# SCALE Numeric scale multiplier (default: 1).
# Examples: 1 (100%), 1.25 (125%), 1.5 (150%), 2 (200%)
#
# Options:
# -h, --help Show this help message and exit.
#
# Examples:
# qubes-scale 1.5 # Run locally inside an AppVM
# qvm-run work 'qubes-scale 2' # Trigger from dom0 for 'work' VM
# ssh user@vm 'qubes-scale 1.25' # Trigger over SSH
# ==============================================================================
set -euo pipefail
show_help() {
sed -n '/^# Usage:/,/^# ====/p' "$0" | sed 's/^# \{0,1\}//; /^====/d'
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
show_help
exit 0
fi
SCALE="${1:-1}"
if ! [[ "$SCALE" =~ ^[0-9]+([.][0-9]+)?$ ]] || (( $(awk "BEGIN {print ($SCALE <= 0)}") )); then
echo "Error: SCALE must be a positive number (e.g., 1, 1.5, 2)." >&2
show_help >&2
exit 1
fi
TARGET_USER="${SUDO_USER:-user}"
USER_ID=$(id -u "$TARGET_USER")
# 1. Attach to the Qubes dummy Xorg & D-Bus session (works via qvm-run or SSH)
export DISPLAY="${DISPLAY:-:0}"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${USER_ID}/bus"
# Auto-detect active Xauthority used by Qubes Xorg process
XAUTH_DETECTED=$(pgrep -a Xorg | grep -oP '(?<=-auth )\S+' || true)
export XAUTHORITY="${XAUTH_DETECTED:-/home/${TARGET_USER}/.Xauthority}"
# 2. Ensure xfsettingsd is running (minimal Qubes templates sometimes omit it)
if ! pgrep -u "$TARGET_USER" -x xfsettingsd >/dev/null; then
nohup xfsettingsd --daemon >/dev/null 2>&1 &
sleep 0.5
fi
# 3. Calculate DPI & integer GDK scaling
DPI=$(awk "BEGIN {printf \"%.0f\", 96 * $SCALE}")
if (( $(awk "BEGIN {print ($SCALE >= 1.75)}") )); then
GDK_SCALE=2
EFFECTIVE_DPI=$(awk "BEGIN {printf \"%.0f\", $DPI / 2}")
CURSOR_SIZE=48
else
GDK_SCALE=1
EFFECTIVE_DPI=$DPI
CURSOR_SIZE=24
fi
# 4. Push live settings to xfsettingsd
xfconf-query -c xsettings -p /Gdk/WindowScalingFactor -n -t int -s "$GDK_SCALE"
xfconf-query -c xsettings -p /Xft/DPI -n -t int -s "$EFFECTIVE_DPI"
xfconf-query -c xsettings -p /Gtk/CursorThemeSize -n -t int -s "$CURSOR_SIZE"
# 5. Update Xresources & X11 DPI for non-GTK apps (xterm, Java, legacy X11)
echo "Xft.dpi: $EFFECTIVE_DPI" | xrdb -merge
xrandr --dpi "$DPI" 2>/dev/null || true
echo "Qubes VM [${HOSTNAME}] scaled to ${SCALE}x (Xft.DPI=${EFFECTIVE_DPI}, GDK=${GDK_SCALE})"