nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1# Keep existing value if it is already non-empty
2if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]] && command -v gsettings >/dev/null; then
3 echo 'Attempting to get GNOME desktop interface scaling factor' >&2
4 AVALONIA_GLOBAL_SCALE_FACTOR="$(gsettings get org.gnome.desktop.interface scaling-factor)"
5 AVALONIA_GLOBAL_SCALE_FACTOR="${AVALONIA_GLOBAL_SCALE_FACTOR##* }"
6fi
7
8if [[ "${AVALONIA_GLOBAL_SCALE_FACTOR-}" == "0" ]]; then
9 echo 'Unset invalid scaling value' >&2
10 unset AVALONIA_GLOBAL_SCALE_FACTOR
11fi
12
13if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]] && command -v xrdb >/dev/null; then
14 echo 'Attempting to get scaling factor from X FreeType DPI setting' >&2
15 dpi="$(xrdb -get Xft.dpi)"
16 if [[ -n "${dpi}" ]]; then
17 AVALONIA_GLOBAL_SCALE_FACTOR=$(echo "scale=2; ${dpi}/96" | bc)
18 fi
19fi
20
21if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then
22 echo "Applying scale factor: ${AVALONIA_GLOBAL_SCALE_FACTOR}" >&2
23 export AVALONIA_GLOBAL_SCALE_FACTOR
24fi