mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-04-21 18:13:14 +02:00
Compare commits
5 commits
16b9d4ac18
...
2809528fda
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2809528fda | ||
![]() |
24c90a8fde | ||
![]() |
42518f2304 | ||
![]() |
4e61c3369b | ||
![]() |
13c4aca5ac |
3 changed files with 107 additions and 10 deletions
|
@ -20,4 +20,40 @@ if command -v gamemoderun > /dev/null 2>&1; then
|
||||||
COMMAND="$COMMAND gamemoderun"
|
COMMAND="$COMMAND gamemoderun"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
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-}" ] || [ "$XDG_SESSION_TYPE" = "x11" ]; then
|
||||||
|
echo "Scaling: Performed by environment, skipping." >&2
|
||||||
|
else
|
||||||
|
# Query monitor config directly (GNOME), default display only.
|
||||||
|
if [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "GNOME" && -f ~/.config/monitors.xml ]] then
|
||||||
|
echo -n 'Scaling: Monitor config located, querying scale...' >&2
|
||||||
|
SCALING="$(grep '<scale' ~/.config/monitors.xml -m 1 | cut -f2 -d">"|cut -f1 -d"<")"
|
||||||
|
SCALING="${SCALING##* }"
|
||||||
|
echo "found! Factor: ${SCALING}" >&2
|
||||||
|
|
||||||
|
# Fallback to X DPI query for others.
|
||||||
|
# Plasma handles this fine, GNOME will always round up e.g. 1.25 -> 2.00.
|
||||||
|
elif command -v xrdb >/dev/null; then
|
||||||
|
echo -n 'Scaling: Attempting to get scaling from X DPI value...' >&2
|
||||||
|
dpi="$(xrdb -get Xft.dpi)"
|
||||||
|
if [[ -n "${dpi}" ]]; then
|
||||||
|
SCALING=$(awk -vdpi="$dpi" 'BEGIN{print dpi/96}')
|
||||||
|
fi
|
||||||
|
echo "found! Factor: ${SCALING}"
|
||||||
|
|
||||||
|
# Query kscreen-doctor for Plasma as a fallback.
|
||||||
|
elif [[ "$(echo "$XDG_CURRENT_DESKTOP")" == "KDE" ]] && command -v kscreen-doctor >/dev/null; then
|
||||||
|
# gsub strips ANSI color codes from ksd output
|
||||||
|
SCALING=$(kscreen-doctor --outputs | awk '/Scale:/{gsub(/\x1b\[[0-9;]*m/,""); print $2; exit}')
|
||||||
|
echo "found! Factor: ${SCALING}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${SCALING-}" || "${SCALING-}" == "0" ]]; then
|
||||||
|
echo 'Unset invalid scaling value' >&2
|
||||||
|
SCALING="1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMMAND="$COMMAND AVALONIA_GLOBAL_SCALE_FACTOR=$SCALING"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec $COMMAND "$SCRIPT_DIR/$RYUJINX_BIN" "$@"
|
|
@ -1,5 +1,9 @@
|
||||||
|
using Ryujinx.Common.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Ryujinx.Common
|
namespace Ryujinx.Common
|
||||||
{
|
{
|
||||||
|
@ -34,12 +38,60 @@ namespace Ryujinx.Common
|
||||||
|
|
||||||
public static string Version => IsValid ? BuildVersion : Assembly.GetEntryAssembly()!.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
public static string Version => IsValid ? BuildVersion : Assembly.GetEntryAssembly()!.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||||
|
|
||||||
public static string GetChangelogUrl(Version currentVersion, Version newVersion) =>
|
public static string GetChangelogUrl(Version currentVersion, Version newVersion, ReleaseChannels.Channel releaseChannel) =>
|
||||||
IsCanaryBuild
|
IsCanaryBuild
|
||||||
? $"https://github.com/{ReleaseChannelOwner}/{ReleaseChannelSourceRepo}/compare/Canary-{currentVersion}...Canary-{newVersion}"
|
? $"https://github.com/{ReleaseChannelOwner}/{ReleaseChannelSourceRepo}/compare/Canary-{currentVersion}...Canary-{newVersion}"
|
||||||
: GetChangelogForVersion(newVersion);
|
: GetChangelogForVersion(newVersion, releaseChannel);
|
||||||
|
|
||||||
public static string GetChangelogForVersion(Version version) =>
|
public static string GetChangelogForVersion(Version version, ReleaseChannels.Channel releaseChannel) =>
|
||||||
$"https://github.com/{ReleaseChannelOwner}/{ReleaseChannelRepo}/releases/{version}";
|
$"https://github.com/{releaseChannel}/releases/{version}";
|
||||||
|
|
||||||
|
public static async Task<ReleaseChannels> GetReleaseChannelsAsync(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
ReleaseChannelPair releaseChannelPair = JsonHelper.Deserialize(await httpClient.GetStringAsync("https://ryujinx.app/api/release-channels"), ReleaseChannelPairContext.Default.ReleaseChannelPair);
|
||||||
|
return ReleaseChannels.Create(releaseChannelPair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct ReleaseChannels
|
||||||
|
{
|
||||||
|
internal static ReleaseChannels Create(ReleaseChannelPair channelPair) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Stable = new Channel(channelPair.Stable),
|
||||||
|
Canary = new Channel(channelPair.Canary)
|
||||||
|
};
|
||||||
|
|
||||||
|
public Channel Stable { get; init; }
|
||||||
|
public Channel Canary { get; init; }
|
||||||
|
|
||||||
|
public struct Channel
|
||||||
|
{
|
||||||
|
public Channel(string raw)
|
||||||
|
{
|
||||||
|
string[] parts = raw.Split('/');
|
||||||
|
Owner = parts[0];
|
||||||
|
Repo = parts[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Owner;
|
||||||
|
public string Repo;
|
||||||
|
|
||||||
|
public override string ToString() => $"{Owner}/{Repo}";
|
||||||
|
|
||||||
|
public string GetLatestReleaseApiUrl() =>
|
||||||
|
$"https://api.github.com/repos/{ToString()}/releases/latest";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonSerializable(typeof(ReleaseChannelPair))]
|
||||||
|
partial class ReleaseChannelPairContext : JsonSerializerContext;
|
||||||
|
|
||||||
|
class ReleaseChannelPair
|
||||||
|
{
|
||||||
|
[JsonPropertyName("stable")]
|
||||||
|
public string Stable { get; set; }
|
||||||
|
[JsonPropertyName("canary")]
|
||||||
|
public string Canary { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace Ryujinx.Ava.Systems
|
||||||
{
|
{
|
||||||
internal static class Updater
|
internal static class Updater
|
||||||
{
|
{
|
||||||
|
private static ReleaseChannels.Channel? _currentReleaseChannel;
|
||||||
|
|
||||||
private const string GitHubApiUrl = "https://api.github.com";
|
private const string GitHubApiUrl = "https://api.github.com";
|
||||||
private const string LatestReleaseUrl =
|
|
||||||
$"{GitHubApiUrl}/repos/{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}/releases/latest";
|
|
||||||
|
|
||||||
private static readonly GithubReleasesJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
private static readonly GithubReleasesJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
|
@ -70,13 +70,22 @@ namespace Ryujinx.Ava.Systems
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Application, "Checking for updates.");
|
Logger.Info?.Print(LogClass.Application, "Checking for updates.");
|
||||||
|
|
||||||
// Get latest version number from GitHub API
|
// Get latest version number from GitHub API
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using HttpClient jsonClient = ConstructHttpClient();
|
using HttpClient jsonClient = ConstructHttpClient();
|
||||||
|
|
||||||
string fetchedJson = await jsonClient.GetStringAsync(LatestReleaseUrl);
|
if (_currentReleaseChannel == null)
|
||||||
|
{
|
||||||
|
ReleaseChannels releaseChannels = await ReleaseInformation.GetReleaseChannelsAsync(jsonClient);
|
||||||
|
|
||||||
|
_currentReleaseChannel = ReleaseInformation.IsCanaryBuild
|
||||||
|
? releaseChannels.Canary
|
||||||
|
: releaseChannels.Stable;
|
||||||
|
}
|
||||||
|
|
||||||
|
string fetchedJson = await jsonClient.GetStringAsync(_currentReleaseChannel.Value.GetLatestReleaseApiUrl());
|
||||||
GithubReleasesJsonResponse fetched = JsonHelper.Deserialize(fetchedJson, _serializerContext.GithubReleasesJsonResponse);
|
GithubReleasesJsonResponse fetched = JsonHelper.Deserialize(fetchedJson, _serializerContext.GithubReleasesJsonResponse);
|
||||||
_buildVer = fetched.TagName;
|
_buildVer = fetched.TagName;
|
||||||
|
|
||||||
|
@ -122,7 +131,7 @@ namespace Ryujinx.Ava.Systems
|
||||||
|
|
||||||
if (userResult is UserResult.Ok)
|
if (userResult is UserResult.Ok)
|
||||||
{
|
{
|
||||||
OpenHelper.OpenUrl(ReleaseInformation.GetChangelogForVersion(currentVersion));
|
OpenHelper.OpenUrl(ReleaseInformation.GetChangelogForVersion(currentVersion, _currentReleaseChannel.Value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue