banner
可达鸭

可达鸭DE博客

「この世界は完璧ではないが、私にはちょうどいい」
bluesky

Does your Linux start Steam like this all the time?

Question 1. Why can my Steam start in the terminal but not on the desktop?#

So I tried something, thinking as a Linux newbie—logging out and switching to x11.
The root cause is not in Wayland/X11, but in “the environment variables obtained by the desktop launcher” ≠ “the environment variables in the terminal”.
I can start it in the terminal because bash loads various exports from ~/.bashrc and /etc/profile.d/ for you;
When double-clicking the icon, systemd-/plasma-/gnome-session only gives you a minimal environment, so Steam cannot find libraries, cannot find the graphics card, and even cannot find PATH, leading to an abort.

Question 2. How can I make this desktop program start with Bash?#

Just modify the .desktop file.
Dump the entire “terminal environment” as AI suggested.
First, execute in the terminal where you can start it:

# Export the current environment to a file
env | grep -E '^(PATH|LD_|GTK_|QT_|XDG_|GALLIUM|VK_|DRI|LIBGL)' > ~/.steam_env
# Then write a line for Steam
echo 'export GDK_BACKEND=x11' >> ~/.steam_env

Create a "wrapper script with environment"

mkdir -p ~/.local/bin
nano ~/.local/bin/steam-wrapper

Add the following content:

#!/bin/bash
# First load the complete environment just dumped
set -a
source ~/.steam_env
set +a
# Then start the real steam
exec /usr/bin/steam "$@"

Grant permissions

chmod +x ~/.local/bin/steam-wrapper

Make the desktop launcher call this script instead of the bare steam
Copy the desktop file to local:

cp /usr/share/applications/steam.desktop ~/.local/share/applications/
sed -i 's|Exec=/usr/bin/steam|Exec=/home/'$USER'/.local/bin/steam-wrapper|' \
       ~/.local/share/applications/steam.desktop

Tested and effective~

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.