-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #438 from Jovian-Experiments/feature/updater-steam…
…os-logo-fix modules/steam: Fix SteamOS logo scaling in updater
- Loading branch information
Showing
6 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ in | |
./steam.nix | ||
./autostart.nix | ||
./environment.nix | ||
./updater.nix | ||
]; | ||
options = { | ||
jovian = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
inherit (lib) | ||
mkIf | ||
mkMerge | ||
mkOption | ||
optionalString | ||
types | ||
; | ||
|
||
cfg = config.jovian.steam; | ||
in | ||
{ | ||
options = { | ||
jovian.steam.updater = { | ||
splash = mkOption { | ||
type = types.enum [ | ||
"steamos" | ||
"jovian" | ||
"vendor" | ||
]; | ||
default = "steamos"; | ||
description = '' | ||
Configures the source of the splash screen used by the updater (preloader) step when launching Steam. | ||
When `steamos`, this will use the vendor-selected image, scaled appropriately. | ||
When `jovian`, this will use the Jovian Experiments logo, scaled appropriately. | ||
When `vendor`, the vendor default will not be changed. This differs from `default` in that | ||
on systems other than the Steam Deck, the scaling may not be correct. | ||
> The scale of the vendor logo (in `vendor`) is incorrect when the display resolution | ||
> is different from 1280 pixels wide. The updater logo will be bigger than the one | ||
> used in the startup animation. | ||
''; | ||
}; | ||
}; | ||
}; | ||
config = mkIf (cfg.enable && cfg.updater.splash != "vendor") (mkMerge [ | ||
{ | ||
systemd.services."jovian-updater-logo-helper" = { | ||
enable = true; | ||
unitConfig.ConditionPathIsDirectory = "/run"; | ||
before = [ "multi-user.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
serviceConfig = { | ||
Type = "oneshot"; | ||
RemainAfterExit = true; | ||
}; | ||
script = '' | ||
mkdir -p /run/jovian | ||
${optionalString (cfg.updater.splash == "steamos") '' | ||
# NOTE: keep in sync with the conventions from `gamescope-session`. | ||
# (IMO downstream should rely on the BGRT instead...) | ||
# https://github.com/Jovian-Experiments/PKGBUILDs-mirror/blob/92e7fe11493915a23745e96e78ecac87af0c1a02/gamescope-session#L162-L175 | ||
board_name=$(cat /sys/class/dmi/id/board_name) | ||
if [[ $board_name = "Galileo" ]]; then | ||
ui_background=${pkgs.steamdeck-hw-theme}/share/plymouth/themes/steamos/steamos-galileo.png | ||
else | ||
ui_background=${pkgs.steamdeck-hw-theme}/share/plymouth/themes/steamos/steamos-jupiter.png | ||
fi | ||
jovian_updater_logo="$ui_background" | ||
''} | ||
${optionalString (cfg.updater.splash == "jovian") '' | ||
jovian_updater_logo="${../../artwork/logo/splash.png}" | ||
''} | ||
${pkgs.jovian-updater-logo-helper}/bin/jovian-updater-logo-helper "$jovian_updater_logo" "/run/jovian/steam-splash.png" | ||
''; | ||
}; | ||
environment.etc."xdg/gamescope-session/environment" = { | ||
text = lib.mkAfter '' | ||
# Actually tell the session to use the splash we just made. If it was made. | ||
if test -e "/run/jovian/steam-splash.png"; then | ||
export STEAM_UPDATEUI_PNG_BACKGROUND="/run/jovian/steam-splash.png" | ||
else | ||
echo "Warning: steam-splash.png was not generated as expected... keeping auto-picked splash." | ||
fi | ||
''; | ||
}; | ||
} | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ writeShellApplication | ||
, lib | ||
, drm_info | ||
, imagemagick | ||
|
||
}: | ||
|
||
writeShellApplication { | ||
name = "jovian-updater-logo-helper"; | ||
|
||
runtimeInputs = [ | ||
drm_info | ||
imagemagick | ||
]; | ||
|
||
text = builtins.readFile ./jovian-updater-logo-helper.sh; | ||
|
||
meta = { | ||
# Same license as the repo. | ||
license = lib.licenses.mit; | ||
}; | ||
} |
79 changes: 79 additions & 0 deletions
79
pkgs/jovian-updater-logo-helper/jovian-updater-logo-helper.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -u | ||
PS4=" $ " | ||
|
||
if (( $# != 2 )); then | ||
2>&1 echo "Error: expecting two arguments." | ||
echo "Usage: ${0##*/} <input> <output>" | ||
exit 1 | ||
fi | ||
|
||
logo="$1"; shift | ||
output="$1"; shift | ||
|
||
# This is the number of degrees the native orientation of the display is at. | ||
# | ||
# Note that the updater applet applies the counter-rotation for us. | ||
# This is used to correctly build up the image. | ||
display_rotation=$( | ||
# drm_info will report the orientation this way: | ||
# ``` | ||
# │ │ └───"panel orientation" (immutable): enum {Normal, Upside Down, Left Side Up, Right Side Up} = Right Side Up | ||
# ``` | ||
# We're keeping the part after the `=`. | ||
case "$(drm_info | grep 'panel orientation' | head -n1 | cut -d'=' -f2)" in | ||
*Left*Side*) echo '270';; | ||
*Upside*) echo '180';; | ||
*Right*Side*) echo '90';; | ||
*) echo '0';; | ||
esac | ||
) | ||
|
||
# Gets the "preferred" display resolution | ||
resolution=$(cat /sys/class/drm/card*-eDP-*/modes | head -n1) | ||
|
||
# The image dimension will be used as our canvas size. | ||
if [[ "$display_rotation" == "0" || "$display_rotation" == "180" ]]; then | ||
image_height=${resolution#*x} | ||
image_width=${resolution%x*} | ||
else | ||
image_height=${resolution%x*} | ||
image_width=${resolution#*x} | ||
fi | ||
|
||
# Build up a `magick` invocation. | ||
MAGICK_INVOCATION=( | ||
magick | ||
|
||
# Create an empty image, with the panel-native resolution | ||
"canvas:black[${image_width}x${image_height}!]" | ||
) | ||
|
||
MAGICK_INVOCATION+=( | ||
# Add the logo | ||
"$logo" | ||
# Centered | ||
-gravity center | ||
# (This means 'add') | ||
-composite | ||
) | ||
|
||
# Final fixups to the image | ||
MAGICK_INVOCATION+=( | ||
# Ensures crop crops a single image with gravity | ||
-gravity center | ||
|
||
# Crop to 16:9... always. | ||
# Steam scales the image, whichever dimensions to a 16:9 aspect ratio. | ||
# A 800px high image on steam deck will be scaled to 720p size. | ||
-crop 16:9 | ||
|
||
# Save to this location. | ||
"$output" | ||
) | ||
|
||
# Run the command, and also print its invocation. | ||
set -x | ||
"${MAGICK_INVOCATION[@]}" |