Files
chromebrew/packages/gdk_base.rb
Maximilian Downey Twiss 40b8844fa3 Upgrade f* packages (#10244)
* f2fs-tools 1.14.0 -> 1.16.0

* faad2 2.10.1 -> 2.11.1

* fakeroot 1.25.3 -> 1.35.1

* faultstat 0.01.01 -> 0.01.11

* fcft 2.5.1 -> 3.1.8

* feh 3.6.3 -> 3.10.3

* fetch 12.0.10 -> 12.0.11

* Add libgnt package

* Finch 2.12.0-1 -> 2.14.13

* fish 3.6.1 -> 3.7.1

* flatseal 1.7.5 -> 2.2.0

* flif 0.3 -> 0.4

* fnotifystat 0.02.02 -> 0.03.00

* Foliate 2.6.4 -> 3.1.1

* Folks 0.15.7 -> 0.15.9

* util_macros 1.19.3 -> xorg_macros 1.20.1

* font-util 1.3.2 -> 1.4.1

* font-adobe-100dpi 1.0.3 -> 1.0.4

* font-adobe-75dpi 1.0.3 -> 1.0.4

* font-adobe-utopia-100dpi 1.0.4 -> 1.0.5

* font-adobe-utopia-75dpi 1.0.4 -> 1.0.5

* font-adobe-utopia-type1 1.0.4 -> 1.0.5

* font-bh-100dpi 1.0.3 -> 1.0.4

* font-bh-75dpi 1.0.3 -> 1.0.4

* font-bh-lucidatypewriter-100dpi 1.0.3 -> 1.0.4

* font-bh-lucidatypewriter-75dpi 1.0.3 -> 1.0.4

* font-bh-ttf 1.0.3 -> 1.0.4

* font-bh-type1 1.0.3 -> 1.0.4

* font-bitstream-100dpi 1.0.3 -> 1.0.4

* font-bitstream-75dpi 1.0.3 -> 1.0.4

* font-bitstream-type1 1.0.3 -> 1.0.4

* font-cursor-misc 1.0.3 -> 1.0.4

* font-daewoo-misc 1.0.3 -> 1.0.4

* font-dec-misc 1.0.3 -> 1.0.4

* font-isas-misc 1.0.3 -> 1.0.4

* font-jis-misc 1.0.3 -> 1.0.4

* font-misc-misc 1.1.2 -> 1.1.3

* font-mutt-misc 1.0.3 -> 1.0.4

* Add libspiro package

* fontforge 20170731 -> 20230101

* tllist 1.0.5 -> 1.1.0

* foot 1.15.0 -> 1.18.0

* forkstat 0.02.10 -> 0.03.02

* fossil 2.6 -> 2.24

* Fragments 2.1.1 -> 3.0.1

* FreeGLUT 3.2.1 -> 3.6.0
2024-08-03 08:01:05 -04:00

52 lines
2.1 KiB
Ruby

require 'package'
class Gdk_base < Package
description 'Set environment variables for autoscaling GTK applications'
homepage 'https://gitlab.com/chromebrew/chromebrew/'
version '1.3'
license 'GPL-3'
compatibility 'all'
source_url 'SKIP'
depends_on 'wayland_info' # L
no_compile_needed
print_source_bashrc
def self.install
gdk_base = <<~EOF
# GDK environment variable settings
# Do not edit this file. It will be overwritten by updates.
GDK_BACKEND=${GDK_BACKEND:-x11}
function roundhalves {
echo "$1 * 2" | bc | xargs -I@ printf "%1.f" @ | xargs -I% echo "% * .5" | bc
}
pxwidth=$(WAYLAND_DISPLAY=wayland-0 wayland-info -i wl_output | grep width: | grep px | head -n 1 | awk '{print $2}')
lwidth=$(WAYLAND_DISPLAY=wayland-0 wayland-info -i zxdg_output_manager_v1 | grep logical_width: | sed 's/,//' | awk '{print $2}')
# echo "pxwidth: $pxwidth, lwidth: $lwidth"
# SCALE needs to be rounded to the nearest 0.5
# Check to see if pxwidth and lwidth are integers before calculating SCALE.
# wayland-info on armv7l does not show lwidth, but aarch64 does.
if [[ $pxwidth == ?(-)+([0-9]) ]] && [[ $lwidth == ?(-)+([0-9]) ]] && [[ -z "$SCALE" ]] ; then
SCALE=$(roundhalves $(echo "scale=2 ;$lwidth / $pxwidth" | bc))
fi
#[[ $RESOLUTION -gt 1500 && $RESOLUTION -lt 2500 ]] && GDK_SCALE=1.5
#[[ $RESOLUTION -ge 2500 && $RESOLUTION -lt 3500 ]] && GDK_SCALE=2
#[[ $RESOLUTION -ge 3500 && $RESOLUTION -lt 4500 ]] && GDK_SCALE=2.5
#[[ $RESOLUTION -ge 4500 && $RESOLUTION -lt 5500 ]] && GDK_SCALE=3
#[[ $RESOLUTION -gt 5500 ]] && GDK_SCALE=3.5
SCALE=${SCALE:-1}
GDK_SCALE=$SCALE
QT_SCALE_FACTOR=$(printf "%.2f" $(bc -l <<< "((1 / $SCALE))"))
echo -e "Gdk_base set environment variables below:"
echo -e "\e[1;33mSCALE=\e[1;32m"${SCALE}
echo -e "\e[1;33mGDK_SCALE=\e[1;32m"${GDK_SCALE}
echo -e "\e[1;33mQT_SCALE_FACTOR=\e[1;32m"${QT_SCALE_FACTOR}"\e[0m"
EOF
FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/etc/env.d"
File.write("#{CREW_DEST_PREFIX}/etc/env.d/09-gdk_base", gdk_base)
end
end