From 498606b38ede18f8909fdc7e0b60b27b350a959d Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 31 Jan 2020 07:14:28 +0100 Subject: [PATCH] xsettingsd: don't use a subshell when computing DPI This is to be able to use `dpi` variable. Also, for some reason, the journal doesn't keep the output of short-lived processes. --- bin/xsettingsd-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/xsettingsd-setup b/bin/xsettingsd-setup index f72a157..8b8f9cb 100755 --- a/bin/xsettingsd-setup +++ b/bin/xsettingsd-setup @@ -3,9 +3,12 @@ DISPLAY=${DISPLAY%.0} # For information -xrandr --current \ - | sed -n 's/^\([^ ]\{1,\}\)* connected.* \([0-9]\{1,\}\)x.* \([0-9]\{1,\}\)mm x .*/\1 \2 \3/p' \ - | while read output pixels mm; do +for info in $(xrandr --current \ + | sed -n 's/^\([^ ]\{1,\}\)* connected.* \([0-9]\{1,\}\)x.* \([0-9]\{1,\}\)mm x .*/\1,\2,\3/p'); do + output=${info%%,*} + pixels=${info#*,} + pixels=${pixels%%,*} + mm=${info##*,} dpi=$(($pixels * 254 / 10 / $mm)) # For laptop screens, we need to apply a correction factor case $output in