From b2fd69b34d1b9f90367728be4e3a550bf55e0050 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Thu, 29 May 2025 06:45:12 +0200 Subject: [PATCH] Enable HiDPI support only if the framebuffer size is detectable --- .../common/usr/lib/armbian/armbian-firstlogin | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin index 195d811f9..fca30573f 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin @@ -687,15 +687,30 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then systemctl start systemd-networkd-wait-online fi - # enable hiDPI support - if [[ "$(cut -d, -f1 < /sys/class/graphics/fb0/virtual_size 2> /dev/null)" -gt 1920 ]]; then - # lightdm - [[ -f /etc/lightdm/slick-greeter.conf ]] && echo "enable-hidpi = on" >> /etc/lightdm/slick-greeter.conf - # xfce - [[ -f /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml ]] && sed -i 's||g' /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml + # Enable HiDPI support only if the framebuffer size is detectable + FB_VIRTUAL_SIZE="/sys/class/graphics/fb0/virtual_size" + HIDPI_THRESHOLD="1920" + if [[ -r "$FB_VIRTUAL_SIZE" ]]; then + fb_virtual_width=$(cut -d, -f1 < "$FB_VIRTUAL_SIZE" 2>/dev/null) + if [[ "$fb_virtual_width" =~ ^[0-9]+$ && "$fb_virtual_width" -gt "${HIDPI_THRESHOLD}" ]]; then + # Enable HiDPI in LightDM slick-greeter + if [[ -f /etc/lightdm/slick-greeter.conf ]]; then + if ! grep -q "^enable-hidpi *= *on" /etc/lightdm/slick-greeter.conf; then + echo "enable-hidpi = on" >> /etc/lightdm/slick-greeter.conf + fi + fi - # framebuffer console larger font - setfont /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz + # Set XFCE scaling factor in skeleton config + XFCE_XSETTINGS="/etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml" + if [[ -f "$XFCE_XSETTINGS" ]]; then + sed -i 's|\(\)|\12\2|' "$XFCE_XSETTINGS" + fi + + # Set a larger console font for framebuffer + if [[ -f /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz ]]; then + setfont /usr/share/consolefonts/Uni3-TerminusBold32x16.psf.gz + fi + fi fi clear