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

@ -72,7 +72,7 @@ input {
// Find more information on the wiki:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Outputs
// Remember to uncomment the node by removing "/-"!
/-output "eDP-1" {
output "DP-1" {
// Uncomment this line to disable this output.
// off
@ -82,10 +82,12 @@ input {
// for the resolution.
// If the mode is omitted altogether or is invalid, niri will pick one automatically.
// Run `niri msg outputs` while inside a niri instance to list all outputs and their modes.
mode "1920x1080@120.030"
mode "3440x1440@99.982"
// You can use integer or fractional scale, for example use 1.5 for 150% scale.
scale 2
scale 1
// Transform allows to rotate the output counter-clockwise, valid values are:
// normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270.
@ -100,15 +102,18 @@ input {
// so to put another output directly adjacent to it on the right, set its x to 1920.
// If the position is unset or results in an overlap, the output is instead placed
// automatically.
position x=1280 y=0
position x=1440 y=0
}
output "DP-2" {
mode "1920x1080@71.910"
scale 1
}
// Settings that influence how windows are positioned and sized.
// Find more information on the wiki:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Layout
layout {
// Set gaps around windows in logical pixels.
gaps 16
gaps 8
// When to center a column when changing focus, options are:
// - "never", default behavior, focusing an off-screen column will keep at the left
@ -591,4 +596,15 @@ binds {
// Powers off the monitors. To turn them back on, do any input like
// moving the mouse or pressing any other key.
Mod+Shift+P { power-off-monitors; }
// Steam launcher that uses xwayland-satellite
Mod+S hotkey-overlay-title="Launch Steam with XWayland Satellite" { spawn "steam-xwayland-satellite"; }
}
// Enable XWayland for X11 application compatibility (like Steam)
// XWayland will automatically start when an X11 app needs it
spawn-at-startup "xwayland-satellite"
environment {
// Let xwayland-satellite manage DISPLAY dynamically
DISPLAY ":1"
}

View file

@ -27,6 +27,7 @@
../../modules/desktop/cosmic.nix
../../modules/desktop/sway.nix
../../modules/desktop/niri.nix
../../modules/desktop/steam-xwayland-satellite.nix
# Fonts
../../modules/desktop/fonts.nix

View file

@ -1,4 +1,8 @@
{ config, pkgs, ... }: {
{
config,
pkgs,
...
}: {
# Common desktop configuration shared across all environments
# XDG Portal configuration for Wayland/X11 compatibility
@ -11,6 +15,9 @@
# 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

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
];
};