1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

scripts/dpi: add DPI live change script

This commit is contained in:
Joe Groocock 2018-11-20 15:06:09 +00:00
parent 51c91b4803
commit 43a656ee96
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86

30
scripts/dpi Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
set -e
# Based on https://github.com/vincentbernat/awesome-configuration/blob/master/bin/xsettingsd-setup
dpi=$1
if [ -z "$1" ]; then
>&2 printf "Usage\n\t%s: <dpi>" "$(basename "$0")"
exit 1
fi
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/xsettingsd"
# Build xsettingsd.local
{
cat $CONF_DIR/xsettingsd.conf 2>/dev/null || true
echo Xft/DPI $(( $dpi*1024 ))
echo Gdk/WindowScalingFactor $(( $dpi/96 ))
echo Gdk/UnscaledDPI $(( $dpi*1024/($dpi/96) ))
} > $CONF_DIR/xsettingsd.local
pid=$(xprop -name xsettingsd _NET_WM_PID 2> /dev/null | awk '{print $NF}')
if [ -z "$pid" ]; then
xsettingsd -c $CONF_DIR/xsettingsd.local &
else
kill -HUP $pid
fi
echo Xft.dpi: $dpi | xrdb -merge