2021-08-01 19:18:15 +00:00
|
|
|
#!/bin/bash
|
2021-08-01 19:05:07 +00:00
|
|
|
set -eu
|
2018-11-20 15:06:09 +00:00
|
|
|
|
|
|
|
# Based on https://github.com/vincentbernat/awesome-configuration/blob/master/bin/xsettingsd-setup
|
2021-08-01 19:05:07 +00:00
|
|
|
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
2018-11-20 15:06:09 +00:00
|
|
|
|
2021-08-01 19:18:15 +00:00
|
|
|
xrdbget() {
|
|
|
|
set -o pipefail
|
|
|
|
xrdb -query | grep -i -m1 "$1" | sed 's/^.*:\s//g' || echo "$2"
|
|
|
|
}
|
|
|
|
|
2018-11-20 15:06:09 +00:00
|
|
|
dpi=$1
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
>&2 printf "Usage\n\t%s: <dpi>" "$(basename "$0")"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
# Update picom and xorg
|
|
|
|
sed -i "s/strength =.*$/strength = $(( dpi*8/96 ));/" "$CONF_DIR/picom/picom.conf" &
|
|
|
|
xrandr --dpi "$dpi" &
|
2018-11-20 15:06:09 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
scale=$(( dpi/96 ))
|
|
|
|
cursor=$(( dpi/6 ))
|
2021-01-30 11:47:07 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
# Build xsettingsd.conf
|
|
|
|
mkdir -p "$CONF_DIR/xsettingsd"
|
2018-11-20 15:06:09 +00:00
|
|
|
{
|
2021-08-01 19:05:07 +00:00
|
|
|
cat "$CONF_DIR/xsettingsd.local" 2>/dev/null || true
|
|
|
|
echo "Xcursor/size $cursor"
|
|
|
|
echo "Gtk/CursorThemeSize $cursor"
|
2021-08-01 19:18:15 +00:00
|
|
|
echo "Gtk/CursorThemeName \"$(xrdbget Xcursor.theme Adwaita)\""
|
|
|
|
echo "Xft/HintStyle \"$(xrdbget Xft.hintstyle hintfull)\""
|
|
|
|
echo "Xft/Hinting \"$(xrdbget Xft.hinting -1)\""
|
|
|
|
echo "Xft/RGBA \"$(xrdbget Xft.rgba rgb)\""
|
2021-08-01 19:05:07 +00:00
|
|
|
echo "Xft/DPI $(( dpi*1024 ))"
|
|
|
|
echo "Gdk/WindowScalingFactor $scale"
|
|
|
|
echo "Gdk/UnscaledDPI $(( dpi*1024/scale ))"
|
|
|
|
} > "$CONF_DIR/xsettingsd/xsettingsd.conf"
|
2018-11-20 15:06:09 +00:00
|
|
|
|
2021-01-30 11:47:07 +00:00
|
|
|
{
|
2021-08-01 19:05:07 +00:00
|
|
|
echo "Xft.dpi: $dpi"
|
|
|
|
echo "Xcursor.size: $cursor"
|
|
|
|
} | xrdb -merge &
|
2021-01-30 11:47:07 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
systemctl --user reload-or-restart xsettingsd &
|
|
|
|
wait
|
2020-03-21 23:20:05 +00:00
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
systemctl --user reload \
|
|
|
|
i3 \
|
|
|
|
polybar@i3bar
|