From 43a656ee96c37b3d16e5a605ace2904ee4b4726f Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 20 Nov 2018 15:06:09 +0000 Subject: [PATCH] scripts/dpi: add DPI live change script --- scripts/dpi | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 scripts/dpi diff --git a/scripts/dpi b/scripts/dpi new file mode 100755 index 0000000..1f4700d --- /dev/null +++ b/scripts/dpi @@ -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: " "$(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