Skip to content

Instantly share code, notes, and snippets.

@nukhes
Created December 30, 2025 20:14
Show Gist options
  • Select an option

  • Save nukhes/b36f127db5cf5b64a81f0bab206a3f61 to your computer and use it in GitHub Desktop.

Select an option

Save nukhes/b36f127db5cf5b64a81f0bab206a3f61 to your computer and use it in GitHub Desktop.
Speed up Steam's Shader in Linux Machines.
#!/bin/bash
# This script optimizes Steam's background shader compilation by automatically configuring the steam_dev.cfg file
# to use your total CPU threads minus four, a calculation designed to maximize processing speed while reserving
# enough resources to prevent system freezes. It functions idempotently, meaning it first checks if the configuration
# file exists (creating it if necessary) and then uses sed to either update the existing unShaderBackgroundProcessingThreads
# line or append it if missing.
CONFIG_FILE="$HOME/.local/share/Steam/steam_dev.cfg"
TOTAL_THREADS=$(nproc)
TARGET_THREADS=$((TOTAL_THREADS - 4))
if [ "$TARGET_THREADS" -lt 1 ]; then
TARGET_THREADS=1
fi
if [ ! -d "$(dirname "$CONFIG_FILE")" ]; then
echo "Steam directory not found."
exit 1
fi
if [ ! -f "$CONFIG_FILE" ]; then
touch "$CONFIG_FILE"
fi
if grep -q "^unShaderBackgroundProcessingThreads" "$CONFIG_FILE"; then
sed -i "s/^unShaderBackgroundProcessingThreads .*/unShaderBackgroundProcessingThreads $TARGET_THREADS/" "$CONFIG_FILE"
else
echo "unShaderBackgroundProcessingThreads $TARGET_THREADS" >> "$CONFIG_FILE"
fi
@nukhes
Copy link
Author

nukhes commented Dec 30, 2025

Run with one command.

curl -fsSL https://gist.githubusercontent.com/nukhes/b36f127db5cf5b64a81f0bab206a3f61/raw/ | sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment