mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-23 10:18:34 +02:00
39 lines
1.1 KiB
Bash
Executable file
39 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
DISPLAY=${DISPLAY%.0}
|
|
|
|
# For information
|
|
xrandr --current \
|
|
| sed -n 's/^\([^ ]\)* connected.* \([0-9]*\)x.* \([0-9]*\)mm x .*/\1 \2 \3/p' \
|
|
| while read output pixels mm; do
|
|
dpi=$(($pixels * 25.4 / $mm))
|
|
echo "$output: $dpi DPI"
|
|
done
|
|
|
|
# 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),$(autorandr --current) in
|
|
zoro,default) dpi=144 ;;
|
|
guybrush,default) dpi=144 ;;
|
|
neo,*) dpi=192 ;;
|
|
*,*) dpi=96 ;;
|
|
esac
|
|
|
|
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
|
|
systemctl --user reload xsettingsd@$(systemd-escape -- "$DISPLAY").service
|
|
|
|
# Also use xrdb for very old stuff (you know, LibreOffice)
|
|
echo Xft.dpi: $dpi | xrdb -merge
|
|
}
|
|
|
|
change $dpi
|