Quick shortcut for Hephaistos (Hades 16:10 mod)?

SatyrSack@lemmy.one to Steam Deck@sopuli.xyz – 13 points –

https://github.com/nbusseneau/hephaistos

Hephaistos patches Hades to allow for custom screen resolutions, including enabling 16:10 support for the Steam Deck. Simply run it in Konsole, and you can select the right aspect ratio. But I play both in handheld and docked, meaning I have to switch between the 16:10 mod and 16:9 each time I play. I currently have two *.sh scripts that I have added as non-Steam games:

  • hephaistos patch 1280 800
  • hephaistos restore

So I just select the correct one, from Game Mode, before launching the game. But launching the game then stalls sometimes, and I have to restart the device to get it to launch.

I have also tried the Bash Shortcuts DeckyLoader plugin, but I cannot get that to work at all

Any ideas for the best way to handle this? Preferably, it would be nice to have a script that finds the current display's resolution/aspect ratio and then use Hephaistos to patch the game accordingly. That way I would not have to make sure I am selecting the correct shortcut before launching the game, it would just be one shortcut to handle the right scenario.

4

xrandr | grep primary | awk -F'[ +]' '{print $4}'

Try running that and see if that returns the correct dimensions? You can probably work out the rest of the script from there.

Great, that definitely does grab the right display dimensions based on the active display, whether that be the built-in display or an external display if docked! I still need to figure out the most efficient way to trigger this from Game Mode before launching the game, but this script does the trick.

#!/bin/bash

# get dimensions of current active display
dimensions=$(xrandr | grep primary | awk -F'[ +]' '{print $4}')
dimensions_x=${dimensions%x*}
dimensions_y=${dimensions#*x}

# get decimal representations of current aspect ratio and "standard" 16:9
ratio_std=$(awk -v var1=16 -v var2=9 'BEGIN { print  ( var1 / var2 ) }')
ratio_active=$(awk -v var1=$dimensions_x -v var2=$dimensions_y 'BEGIN { print  ( var1 / var2 ) }')

# if active display is 16:9, restore Hephaistos, otherwise patch to active dimensions
if (( $(echo "$ratio_active $ratio_std" | awk '{print ($1 == $2)}') )); then
    ./hephaistos restore
else
    ./hephaistos patch $dimensions_x $dimensions_y
fi