linux: Attempt to apply Avalonia scaling factor via environment pre-launch. #656
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "bangfire/brute_scaling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Inspired by https://github.com/NixOS/nixpkgs/pull/348427 as it seems to work well at least on my system (Plasma 6.3).
A little ugly but probably better than nothing. Tried to get a KDE route working via
kscreen-doctor
but for whatever reason the environment variable refuses to set with the output of that... not sure why as when I copied the exact string that was being executed into the terminal directly it did work. Either way I gave up, probably some unicode weirdness that I don't want to get into.Needs
bc
to be installed which I think is widely packaged with most distros but it's hard to know.Needs GNOME testing.
Edit: GNOME is also useless, the
gsettings
scaling value doesn't even seem to be used and there doesn't seem to be any other method to query display scaling without parsing the XML manually.Fixes #643 in theory.
Download the artifacts for this pull request:
Only for Developers
Hi, I would suggest running shellcheck on the script and fixing the warnings. Also left a couple of more specific suggestions.
This will complicate the parsing, but maybe it's worth setting
AVALONIA_SCREEN_SCALE_FACTORS
instead (for the methods that provide this info, likekscreen-doctor
andmonitors.xml
) to support multiple monitors. See: https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI. For thekscreen-doctor
method it may look like:I frequently run Ryujinx on an external monitor (but not always), would be nice to have it automatically adapt scaling to the monitor it's currently on.
@ -23,1 +23,3 @@
exec $COMMAND "$SCRIPT_DIR/$RYUJINX_BIN" "$@"
# Check if user already has a manual Avalonia scaling override or session type is x11.
if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" || "$(echo "$XDG_SESSION_TYPE")" == "x11" ]]; then
echo "Scaling: Performed by environment, skipping." >&2
The
#!/bin/sh
shebang indicates that this is a POSIX-compatible shell script, and POSIXsh
doesn't specify the[[
syntax. The same goes for==
which should be just=
. As is, the script will fail on Debian-based systems (including Ubuntu) I think, as they usedash
as/bin/sh
which doesn't implement these syntax extensions. The same applies to all otherif
s.Also,
echo
here is redundant, but that's just a nit.@ -24,0 +38,4 @@
dpi="$(xrdb -get Xft.dpi)"
if [[ -n "${dpi}" ]]; then
SCALING=$(echo "scale=2; ${dpi}/96" | bc)
fi
bc
can be replaced withawk
which is more commonly installed by default.@ -24,0 +47,4 @@
SCALING="$(kscreen-doctor --outputs | grep "Scale" -m 1)"
SCALING="${SCALING##* }"
SCALING=$(echo $SCALING | sed 's/\x1B\[[0-9;]*m//g') # Trim ANSI chars from ksd output.
echo "found! Factor: ${SCALING}"
Can be replaced with a single
awk
call:Checkout
From your project repository, check out a new branch and test the changes.