From 1a4e7fd3f611180a765db9aeb2b4408b2fd3d837 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Thu, 12 Jun 2025 17:37:12 +0200 Subject: [PATCH] made script for steam on xwayland satelite --- dotfiles/geir/niri/config.kdl | 30 +++-- .../congenital-optimist/configuration.nix | 1 + modules/desktop/common.nix | 17 ++- modules/desktop/steam-xwayland-satellite.nix | 118 ++++++++++++++++++ modules/hardware/amd-workstation.nix | 11 +- modules/users/geir.nix | 2 +- 6 files changed, 161 insertions(+), 18 deletions(-) create mode 100644 modules/desktop/steam-xwayland-satellite.nix diff --git a/dotfiles/geir/niri/config.kdl b/dotfiles/geir/niri/config.kdl index 6ed8811..b6eb00d 100644 --- a/dotfiles/geir/niri/config.kdl +++ b/dotfiles/geir/niri/config.kdl @@ -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; } -} \ No newline at end of file + + // 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" +} diff --git a/machines/congenital-optimist/configuration.nix b/machines/congenital-optimist/configuration.nix index b6f58fc..68e280b 100644 --- a/machines/congenital-optimist/configuration.nix +++ b/machines/congenital-optimist/configuration.nix @@ -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 diff --git a/modules/desktop/common.nix b/modules/desktop/common.nix index b3043ce..f8274ac 100644 --- a/modules/desktop/common.nix +++ b/modules/desktop/common.nix @@ -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; -} \ No newline at end of file +} diff --git a/modules/desktop/steam-xwayland-satellite.nix b/modules/desktop/steam-xwayland-satellite.nix new file mode 100644 index 0000000..261e98d --- /dev/null +++ b/modules/desktop/steam-xwayland-satellite.nix @@ -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; +} diff --git a/modules/hardware/amd-workstation.nix b/modules/hardware/amd-workstation.nix index 8d82ee9..6b5d5ae 100644 --- a/modules/hardware/amd-workstation.nix +++ b/modules/hardware/amd-workstation.nix @@ -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; -} \ No newline at end of file +} diff --git a/modules/users/geir.nix b/modules/users/geir.nix index fb1fa70..26c86de 100644 --- a/modules/users/geir.nix +++ b/modules/users/geir.nix @@ -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 ]; };