diff --git a/.local/bin/set-dpi b/.local/bin/set-dpi new file mode 100755 index 00000000..fcfe19fc --- /dev/null +++ b/.local/bin/set-dpi @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +# Sets the correct DPI for your monitor instead of the generic '100' +# ❗ Make sure there is no DPI entry in your Xresources already! + +file=~/.config/Xresources + +grep 'Xft.dpi' "$file" && xrdb -merge "$file" && exit + +info=$(xrandr | grep ' connected') + +width=$(echo "$info" | rev | cut -d ' ' -f 3 | rev) +width_in=$(echo "${width%mm}" | awk '{print $1 * 0.039370}') + +height=$(echo "$info" | rev | cut -d ' ' -f 1 | rev) +height_in=$(echo "${height%mm}" | awk '{print $1 * 0.039370}') + +px=$(echo "$info" | cut -d ' ' -f 4) + +width_px=${px%x*} + +height_px=${px#*x} +height_px=${height_px%%+*} + +diagonal_px=$(awk -v w="$width_px" -v h="$height_px" \ + 'BEGIN{print sqrt(w*w+h*h)}') + +diagonal_in=$(awk -v w="$width_in" -v h="$height_in" \ + 'BEGIN{print sqrt(w*w + h*h)}') + +dpi=$(awk -v dp="$diagonal_px" -v di="$diagonal_in" \ + 'BEGIN{print dp / di}') + +echo "Xft.dpi: $dpi" >> "$file" +xrdb -merge "$file" + diff --git a/.xprofile b/.xprofile index 861443b8..29170cc6 100755 --- a/.xprofile +++ b/.xprofile @@ -7,6 +7,7 @@ # Add this when you include flatpak in your system dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY +set-dpi & # sets the correct DPI for your monitor mpd & # music player daemon-you might prefer it as a service though remaps & # run the remaps script, switching caps/esc and more; check it for more info setbg & # set the background with the `setbg` script