mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Sets the correct DPI for you monitor instead of the the generic 100
This commit is contained in:
parent
32e0623424
commit
16a54b7990
36
.local/bin/set-dpi
Executable file
36
.local/bin/set-dpi
Executable file
@ -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"
|
||||||
|
|
||||||
@ -7,6 +7,7 @@
|
|||||||
# Add this when you include flatpak in your system
|
# Add this when you include flatpak in your system
|
||||||
dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY
|
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
|
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
|
remaps & # run the remaps script, switching caps/esc and more; check it for more info
|
||||||
setbg & # set the background with the `setbg` script
|
setbg & # set the background with the `setbg` script
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user