Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(steam): Add shortcut to start Steam BPM without slugishness #1754

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ RUN /usr/libexec/containerbuild/image-info && \
echo "Compiling gschema to include Bazzite Deck setting overrides" && \
glib-compile-schemas /usr/share/glib-2.0/schemas &>/dev/null && \
rm -r /tmp/bazzite-schema-test && \
echo "Removing Steam BPM workaround .desktop file" && \
{ rm -v /usr/share/applications/bazzite-steam-bpm.desktop || true; } && \
systemctl enable bazzite-autologin.service && \
systemctl enable wireplumber-workaround.service && \
systemctl enable wireplumber-sysconf.service && \
Expand Down Expand Up @@ -936,11 +938,16 @@ ARG VERSION_PRETTY="${VERSION_PRETTY}"
COPY system_files/nvidia/shared system_files/nvidia/${BASE_IMAGE_NAME} /

# Remove everything that doesn't work well with NVIDIA
# Install X11 session (Remove me for Fedora 41)
RUN --mount=type=cache,dst=/var/cache/rpm-ostree \
rpm-ostree override remove \
rocm-hip \
rocm-opencl \
rocm-clinfo && \
if [[ "${BASE_IMAGE_NAME}" == "kinoite" && "$FEDORA_MAJOR_VERSION" -eq "40" ]]; then \
rpm-ostree install \
plasma-workspace-x11 \
; fi && \
/usr/libexec/containerbuild/cleanup.sh && \
ostree container commit

Expand Down

This file was deleted.

71 changes: 71 additions & 0 deletions system_files/desktop/shared/usr/bin/bazzite-steam-bpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/bash
# Stop Steam client and it in Big Picture Mode
#
# This is a workaround for Big Picture Mode running slugish when switching from
# desktop mode to BPM from the client. See https://github.com/ublue-os/bazzite/issues/1675

# TODO 20/10/2024: Remove me whenever the issue above gets solved

# Check if we are running from a terminal or from a .desktop shortcut
if ((SHLVL > 1)); then
function echoerr() {
echo >&2 "$@"
}
else
function echoerr() {
zenity --error --icon=bazzite-logo --text="$*"
}
fi

STEAM_BIN=/usr/bin/steam
BAZZITE_STEAM_BIN="/usr/bin/bazzite-steam"
# BAZZITE_STEAM_BIN="$(type -P bazzite-steam)"
STEAM_DIR="${HOME}/.local/share/Steam"
TIMEOUT_SECS=30

# List of binaries to check with lsof to prove steam is running
BIN_WATCH=(
"${STEAM_BIN}"
"${BAZZITE_STEAM_BIN}"
"${STEAM_DIR}/steam.sh"
"${STEAM_DIR}"/ubuntu*/steam
)

# Echo pids of steam processes
function get_steam_pids() {
lsof -t -- "${BIN_WATCH[@]}" 2>/dev/null || true
}

# Return err if steam is not running
function is_steam_running() {
(($(get_steam_pids | wc --lines) > 0))
return
}

function main() {
# Check if steam is running
if is_steam_running; then
# Stop it
${STEAM_BIN} +quit

# Wait to be fully stopped
# shellcheck disable=SC2046
if ! waitpid --exited --timeout ${TIMEOUT_SECS} $(get_steam_pids); then
# Check if we timed out
local err=$?
if ((err == 3)); then
echoerr "ERROR: Timed out stopping Steam. Stopping script..."
exit 1

else # Something else happened
echoerr "ERROR: code=${err}; This is strange..."
exit ${err}
fi
fi
fi

# Start steam in big picture mode
${BAZZITE_STEAM_BIN} steam://open/bigpicture "$@"
}

main "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Desktop Entry]
Name=Steam Big Picture Mode
Exec=/usr/bin/bazzite-steam-bpm %U
Icon=steam
Terminal=false
Type=Application
Categories=Network;FileTransfer;Game;