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
|
|
|
|
2022-10-23 10:59:37 +00:00
|
|
|
BLUR_STRENGTH=12
|
2022-10-23 10:24:28 +00:00
|
|
|
CURSOR_SIZE=28
|
2022-10-23 10:59:37 +00:00
|
|
|
CORNER_RADIUS=9
|
2022-10-23 10:24:28 +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"
|
|
|
|
}
|
|
|
|
|
2022-03-21 21:41:57 +00:00
|
|
|
xsetting_bool() {
|
|
|
|
case "$1" in
|
|
|
|
true) echo 1;;
|
|
|
|
false) echo 0;;
|
|
|
|
default) echo -1;;
|
|
|
|
*) echo -1;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2018-11-20 15:06:09 +00:00
|
|
|
|
2022-03-21 21:41:57 +00:00
|
|
|
if [ -z "$1" ] || [ "$1" -gt 200 ] || [ "$1" -lt 96 ]; then
|
|
|
|
>&2 printf "Usage\n\t%s: value\n\n value\t Value must be within 96-200 inclusive\n" "$(basename "$0")"
|
2018-11-20 15:06:09 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-03-21 21:41:57 +00:00
|
|
|
dpi=$1
|
2021-08-01 19:05:07 +00:00
|
|
|
scale=$(( dpi/96 ))
|
2022-10-23 10:24:28 +00:00
|
|
|
cursor=$(( (dpi*CURSOR_SIZE)/96 ))
|
2021-01-30 11:47:07 +00:00
|
|
|
|
2022-03-21 21:41:57 +00:00
|
|
|
# Update picom scale
|
2022-10-23 10:59:37 +00:00
|
|
|
sed -i -e "s/strength =.*$/strength = $(( (dpi*BLUR_STRENGTH)/96 ));/" \
|
|
|
|
-e "s/corner-radius =.*$/corner-radius = $(( (dpi*CORNER_RADIUS)/96 ));/" \
|
2022-03-21 21:41:57 +00:00
|
|
|
"$CONF_DIR/picom/picom.conf" &
|
|
|
|
|
2021-08-01 19:05:07 +00:00
|
|
|
# Build xsettingsd.conf
|
|
|
|
mkdir -p "$CONF_DIR/xsettingsd"
|
2018-11-20 15:06:09 +00:00
|
|
|
{
|
2022-03-21 21:41:57 +00:00
|
|
|
cat "$CONF_DIR/xsettingsd.local" 2>/dev/null || :
|
2021-08-01 19:05:07 +00:00
|
|
|
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)\""
|
2022-03-21 21:41:57 +00:00
|
|
|
echo "Xft/Hinting $(xsetting_bool "$(xrdbget Xft.hinting default)")"
|
2021-08-01 19:18:15 +00:00
|
|
|
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
|
|
|
|
2022-03-21 21:41:57 +00:00
|
|
|
xrdb -merge <<EOF &
|
|
|
|
Xft.dpi: $dpi
|
|
|
|
Xcursor.size: $cursor
|
|
|
|
EOF
|
|
|
|
xrandr --dpi "$dpi" &
|
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 \
|
2022-03-21 21:41:57 +00:00
|
|
|
polybar@i3bar &
|
|
|
|
systemctl --user restart \
|
|
|
|
dunst &
|
|
|
|
|
|
|
|
wait
|