-
Notifications
You must be signed in to change notification settings - Fork 0
/
intsize
executable file
·50 lines (44 loc) · 1.74 KB
/
intsize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/bash
#
# intsize.sh
#
# Distributed under terms of the MIT license.
#
# This script uses the pythagoream theorem to determine font size for the interface of your system.
# It has been tuned for my eyes, if you find it annoying, or hard to read, you'll have to
# adjust the formulas.
# Declare variables (that get overwritten by the source)
measureddots=''
distance=''
fontname=''
termname=''
termfontname=''
# Shellcheck can't read this on my system, ignoring
# shellcheck disable=SC1091
source "${HOME}/.local/envrc"
xres=$(xdpyinfo | grep dimensions | awk '{print $2}' | awk -F "x" '{print $1}')
yres=$(xdpyinfo | grep dimensions | awk '{print $2}' | awk -F "x" '{print $2}')
combres=$((xres * yres))
squareddots=$((measureddots**2))
combsquare=$((combres / squareddots))
squaredpix=$(bc <<< "scale=0; sqrt($((combsquare)))")
c=$((squaredpix + distance))
b=$((squaredpix))
if [ -z "${fontsize}" ]; then
fontsize=$(bc <<< "scale=0; sqrt($(($((c**2)) - $((b**2)))))")
fi
if [ -z "${termfontsize}" ]; then
termfontsize=$(bc <<< "scale=0; sqrt($(($((c**2)) - $((b**2)))))")
else
echo "termfontsize overwritten as ${termfontsize}"
fi
termfontstring="${termname}.font:${termfontname}:pixelsize=${termfontsize}:antialias=true"
echo "Font set to $fontname $fontsize"
xrandr --dpi "${measureddots}"
echo "Setting terminal font to ${termfontstring}"
echo "${termfontstring}" | xrdb -merge -
echo "Xft.dpi: ${measureddots}" | xrdb -merge -
sed -i "s/gtk-font-name=.*/gtk-font-name=$fontname $fontsize/g" ~/.config/gtk-3.0/settings.ini
sed -i "s/gtk-font-name=.*/gtk-font-name=\"$fontname $fontsize\"/g" ~/.gtkrc-2.0
gsettings set org.gnome.desktop.interface document-font-name "$fontname $fontsize"
gsettings set org.gnome.desktop.interface font-name "$fontname $fontsize"