made script for steam on xwayland satelite

This commit is contained in:
Geir Okkenhaug Jerstad 2025-06-12 17:37:12 +02:00
parent fc1482494f
commit 1a4e7fd3f6
6 changed files with 161 additions and 18 deletions

View file

@ -1,20 +1,27 @@
{ config, pkgs, ... }: {
{
config,
pkgs,
...
}: {
# Common desktop configuration shared across all environments
# XDG Portal configuration for Wayland/X11 compatibility
xdg.portal = {
enable = true;
wlr.enable = true;
extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
extraPortals = [pkgs.xdg-desktop-portal-gtk];
};
# Display manager and session management
services.dbus.enable = true;
# Enable XWayland for X11 app compatibility (Steam, etc.)
programs.xwayland.enable = true;
# Common desktop packages
environment.systemPackages = with pkgs; [
firefox
];
# Flatpak support
services.flatpak.enable = true;
}
}

View file

@ -0,0 +1,118 @@
{
config,
pkgs,
...
}: {
# Steam configuration with xwayland-satellite support
# Create a wrapper script for Steam that uses xwayland-satellite
environment.systemPackages = with pkgs; [
(writeShellScriptBin "steam-xwayland-satellite" ''
#!/usr/bin/env bash
# Set environment variables for better Steam compatibility
export STEAM_FRAME_FORCE_CLOSE=1
export DXVK_HUD=fps
export __GL_THREADED_OPTIMIZATIONS=1
# Check if xwayland-satellite is running and get its DISPLAY
XWAYLAND_PID=$(pgrep -f "xwayland-satellite")
if [ -z "$XWAYLAND_PID" ]; then
echo "Starting xwayland-satellite..."
${xwayland-satellite}/bin/xwayland-satellite &
sleep 5 # Give it more time to start
XWAYLAND_PID=$(pgrep -f "xwayland-satellite")
if [ -z "$XWAYLAND_PID" ]; then
echo "Warning: Failed to start xwayland-satellite"
fi
fi
# Debug: Show what displays are available
echo "Available X11 sockets:"
ls -la /tmp/.X11-unix/ 2>/dev/null || echo "No X11 sockets found"
# Try to detect the DISPLAY from xwayland-satellite
if [ -n "$XWAYLAND_PID" ]; then
# Try to find DISPLAY from the process environment
XWAYLAND_DISPLAY=$(tr '\0' '\n' < /proc/$XWAYLAND_PID/environ 2>/dev/null | grep '^DISPLAY=' | cut -d= -f2)
if [ -n "$XWAYLAND_DISPLAY" ]; then
export DISPLAY="$XWAYLAND_DISPLAY"
echo "Found xwayland-satellite on DISPLAY=$DISPLAY"
else
# Look for available X displays (prioritize :1 since that's where xwayland-satellite typically runs)
for display in :1 :2 :3 :0; do
if [ -S "/tmp/.X11-unix/X''${display#:}" ]; then
export DISPLAY="$display"
echo "Using available X display: $DISPLAY"
break
fi
done
fi
else
echo "Warning: xwayland-satellite not found, checking for available displays..."
# Look for available X displays (prioritize :1)
for display in :1 :2 :3 :0; do
if [ -S "/tmp/.X11-unix/X''${display#:}" ]; then
export DISPLAY="$display"
echo "Using available X display: $DISPLAY"
break
fi
done
fi
# Final fallback - if no DISPLAY is set, try :1 explicitly
if [ -z "$DISPLAY" ]; then
echo "No DISPLAY found, trying :1 as fallback..."
export DISPLAY=":1"
fi
echo "Starting Steam with xwayland-satellite on DISPLAY=$DISPLAY"
exec ${steam}/bin/steam "$@"
'')
# Also create a desktop entry for the launcher
(makeDesktopItem {
name = "steam-xwayland-satellite";
desktopName = "Steam (XWayland Satellite)";
comment = "Steam with xwayland-satellite for better Wayland compatibility";
exec = "steam-xwayland-satellite";
icon = "steam";
categories = ["Application" "Game"];
startupNotify = true;
})
# Additional gaming packages
gamemode
gamescope
mangohud # Performance overlay
lutris # Game manager
bottles # Windows app runner
];
# Ensure Steam has proper gaming optimizations
programs.steam = {
enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
# Enable GameScope for better Steam gaming on Wayland
gamescopeSession.enable = true;
};
# Gaming-related environment variables
environment.sessionVariables = {
# Force Steam to use XWayland
STEAM_FORCE_DESKTOPUI_SCALING = "1";
# Better gaming performance
__GL_SYNC_TO_VBLANK = "0";
__GL_THREADED_OPTIMIZATIONS = "1";
# AMD GPU optimizations (since you have AMD Radeon)
AMD_VULKAN_ICD = "RADV";
VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
};
# Enable gamemode for better gaming performance
programs.gamemode.enable = true;
}

View file

@ -1,4 +1,8 @@
{ config, pkgs, ... }: {
{
config,
pkgs,
...
}: {
# AMD GPU configuration
hardware.amdgpu.initrd.enable = true;
@ -24,7 +28,4 @@
alsa.enable = true;
pulse.enable = true;
};
# Gaming support
programs.steam.enable = true;
}
}

View file

@ -78,7 +78,6 @@ in {
vscode
git-credential-manager
nodejs
nodePackages.npm
virt-manager
# Creative Tools (optional - remove if not needed)
@ -104,6 +103,7 @@ in {
dbus
wayland
xwayland
xwayland-satellite
xdg-utils
];
};