Skip to content

Commit

Permalink
fix(deck): Use new rotation system based on Valve's bootstrap.
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Apr 18, 2024
1 parent e1a7af7 commit c16afeb
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 69 deletions.
49 changes: 49 additions & 0 deletions system_files/deck/kinoite/usr/bin/bazzite-plasma-bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Modified from:
# https://gitlab.com/evlaV/steamdeck-kde-presets/-/blob/master/usr/bin/jupiter-plasma-bootstrap?ref_type=heads

set -eo pipefail

SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"

if [[ "${XDG_SESSION_TYPE}" = "wayland" ]]; then
if /usr/libexec/hardware/needs-left-rotation || /usr/libexec/hardware/needs-right-rotation; then
# Try to wait for kscreen to be ready. This was mostly a hack to try to make the below bug not happen, but I'm afraid
# to remove it because this weird bug has caused hours of grief.
i=0
while (( ++i < 5 )) && ! kscreen-console outputs; do
sleep 5
done

# Then try to fix the config
#
# There is some fun/insane bug where if kscreen hasn't evaluated connected displays yet, doing that at the same time as
# asking it to set the rotation causes it to racily either ignore you, or somehow do two modesets in such a way as to
# break the amdgpu driver and disable the screen for this X11 session. Really. Wayland seems fine.
#
# But if you ask for a nonsense rotation, it will guarantee it has evaluated the new display and added it to the config
# (before failing because foo isn't a rotation). Ha-ha, software!
kscreen-doctor output.eDP-1.rotation.foo || true
kscreen-doctor output.eDP.rotation.foo || true
# In wayland mode the display is named after some EDID identifier and not the output, but "1" works there, and hopefully
# is the internal screen oh boy.

# Try to wait for kscreen to be ready
i=0
while (( ++i < 5 )) && ! kscreen-console json; do
sleep 5
done

# Then try to fix the config
if /usr/libexec/hardware/needs-right-rotation; then
kscreen-doctor output.eDP.rotation.right \
|| kscreen-doctor output.eDP-1.rotation.right \
|| true
elif /usr/libexec/hardware/needs-left-rotation; then
kscreen-doctor output.eDP.rotation.left \
|| kscreen-doctor output.eDP-1.rotation.left \
|| true
fi
fi
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Desktop Entry]
Exec=/usr/bin/bazzite-plasma-bootstrap
GenericName[en_US]=Desktop Bootstrap
GenericName=Desktop Bootstrap
Icon=system-run
MimeType=
Name[en_US]=Desktop Bootstrap
Name=Desktop Bootstrap
Path=
StartupNotify=true
Terminal=false
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
46 changes: 0 additions & 46 deletions system_files/deck/kinoite/usr/libexec/bazzite-rotation-fix

This file was deleted.

12 changes: 12 additions & 0 deletions system_files/deck/kinoite/usr/libexec/hardware/needs-left-rotation
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/bash

SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"

# Legion Go
# Loki Max
# AYANEO Air Plus
if [[ ":83E1:Loki Max:AIR Plus:" =~ ":$SYS_ID:" ]]; then
exit 0
fi

exit 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/bash

# Steam Deck
if /usr/libexec/hardware/valve-hardware; then
exit 0
fi

exit 1
12 changes: 3 additions & 9 deletions system_files/desktop/shared/usr/libexec/bazzite-user-setup
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BAZZITE_CONFIG_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/bazzite"
mkdir -p "$BAZZITE_CONFIG_DIR"

# SCRIPT VERSION
USER_SETUP_VER=30
USER_SETUP_VER=31
USER_SETUP_VER_FILE="$BAZZITE_CONFIG_DIR/version"
USER_SETUP_FEDORA_VER_FILE="$BAZZITE_CONFIG_DIR/fedora_version"
USER_SETUP_IMAGE_VER_FILE=$BAZZITE_CONFIG_DIR/image_name""
Expand Down Expand Up @@ -148,14 +148,8 @@ if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegam
rm -f "$AUTOSTART_FOLDER/autostart/bazzite-handle-legion-go-rotation.desktop"
fi

if /usr/libexec/hardware/rotation-fix-hardware && [[ $BASE_IMAGE_NAME =~ "kinoite" ]]; then
if [[ ! -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop" ]]; then
echo 'Adding rotation fix'
mkdir -p "$AUTOSTART_FOLDER/autostart"
printf "[Desktop Entry]\nExec=/usr/libexec/bazzite-rotation-fix\nIcon=dialog-scripts\nName=bazzite-rotation-fix\nType=Application\nX-KDE-AutostartScript=true\n" > "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop"
fi
elif [[ -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop" ]]; then
echo 'Non-supported or GNOME detected, removing rotaion fix'
# Remove old rotation fix
if [[ -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop" ]]; then
rm -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop"
fi
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
if [[ ":ROG Ally RC71L_RC71L:ROG Ally RC71L:83E1:G1618-04:G1617-01:G1619-05:AIR Plus:AIR:AYANEO GEEK:AYANEO 2:AYANEO 2S:AOKZOE A1 AR07:G1619-04:Win600:Loki Max:Loki Zero:Loki MiniPro:" =~ ":$SYS_ID:" ]]; then
exit 0
else
exit 1
fi

exit 1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
if [[ ":ROG Ally RC71L_RC71L:ROG Ally RC71L:83E1:G1618-04:G1619-04:G1617-01:G1619-05:AIR Plus:AIR:SLIDE:" =~ ":$SYS_ID:" ]]; then
exit 0
else
exit 1
fi

exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
if [[ ":Jupiter:Galileo:" =~ ":$SYS_ID:" ]]; then
exit 0
else
exit 1
fi

exit 1

0 comments on commit c16afeb

Please sign in to comment.