From efb006065b4e5e9f57aa3d8a6fdde865202425c1 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 28 May 2019 09:23:21 +0200 Subject: [PATCH] xsettings: make Firefox more happy with DPI changes See https://bugzilla.mozilla.org/show_bug.cgi?id=1554850 --- bin/xsettingsd-setup | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/bin/xsettingsd-setup b/bin/xsettingsd-setup index 5d0c14c..8194b85 100755 --- a/bin/xsettingsd-setup +++ b/bin/xsettingsd-setup @@ -14,21 +14,33 @@ case $(hostname),$(xrandr --current | \ *) dpi=96 ;; esac -# Build xsettingsd.local -{ - cat ~/.config/awesome/xsettingsd - echo Xft/DPI $(( $dpi*1024 )) - echo Gdk/WindowScalingFactor $(( $dpi/96 )) - echo Gdk/UnscaledDPI $(( $dpi*1024/($dpi/96) )) -} > ~/.config/awesome/xsettingsd.local - -# Signal xsettingsd +# Get xsettingsd PID pid=$(xprop -name xsettingsd _NET_WM_PID 2> /dev/null | awk '{print $NF}') -if [ x"$pid" = x ]; then - xsettingsd -c ~/.config/awesome/xsettingsd.local & -else - kill -HUP $pid + +change() { + # Build xsettingsd.local + { + cat ~/.config/awesome/xsettingsd + echo Xft/DPI $(( $1*1024 )) + echo Gdk/WindowScalingFactor $(( $1/96 )) + echo Gdk/UnscaledDPI $(( $1*1024/($1/96) )) + } > ~/.xsettingsd + + # Signal xsettingsd + if [ x"$pid" = x ]; then + xsettingsd -c ~/.xsettingsd & + else + kill -HUP $pid + fi +} + +if [ x"$pid" != x ]; then + # Change a first time to a DPI that will trigger a scale factor + # change (notably, Firefox needs that). + change $(( $dpi * 2 )) + sleep 1 fi +change $dpi # Also use xrdb for very old stuff (you know, LibreOffice) echo Xft.dpi: $dpi | xrdb -merge