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.
A place to discuss and support all things Steam Deck.
Replacement for r/steamdeck_linux.
As Lemmy doesn't have flairs yet, you can use these prefixes to indicate what type of post you have made, eg:
[Flair] My post title
The following is a list of suggested flairs:
[Discussion] - General discussion.
[Help] - A request for help or support.
[News] - News about the deck.
[PSA] - Sharing important information.
[Game] - News / info about a game on the deck.
[Update] - An update to a previous post.
[Meta] - Discussion about this community.
Some more Steam Deck specific flairs:
[Boot Screen] - Custom boot screens/videos.
[Selling] - If you are selling your deck.
These are not enforced, but they are encouraged.
Rules:
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