#!/bin/sh # Don't try to guess DPI. For a laptop, we don't want the same DPI as # for an external screen. Just hardcode stuff... case $(hostname),$(xrandr --current | \ sed -n 's/\([^ ]*\) connected .*[0-9][0-9]*x[0-9][0-9]*+[0-9][0-9]*+[0-9][0-9]* .*/\1/p' | \ sort | tr '\n' ':') in zoro,eDP1:) dpi=144 ;; zoro,eDP-1:) dpi=144 ;; zoro,eDP-1:HDMI-2:) dpi=144 ;; zoro,eDP-1:DP-1:) dpi=144 ;; neo,HDMI-1:HDMI-2:) dpi=96 ;; neo,*) dpi=192 ;; *) dpi=96 ;; esac # Get xsettingsd PID pid=$(xprop -name xsettingsd _NET_WM_PID 2> /dev/null | awk '{print $NF}') change() { # Build xsettingsd.local { cat ~/.config/awesome/xsettingsd echo Xft/DPI $(( $1*1024 )) echo Xft/RGBA \"$( [ $1 -gt 144 ] && echo none || echo rgb )\" 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