gamescope icon indicating copy to clipboard operation
gamescope copied to clipboard

Select monitor for gamescope to appear on

Open flying-sheep opened this issue 2 years ago • 21 comments

I’m using KDE Plasma, which supports selecting a primary monitor for both X11 and Wayland.

Therefore everything that doesn’t place itself on some specific monitor will appear on my primary (office) monitor.

I want gamescope to appear on my projector instead, but there seems to be no flag to select any monitor. Is there another way or can you implement such a flag?

flying-sheep avatar Oct 12 '22 09:10 flying-sheep

I guess it can be done using window rules (kcmshell5 kwinrules):

grafik

flying-sheep avatar Oct 26 '22 10:10 flying-sheep

A feature like this would be much appreciated; some games don't allow you to select a specific display which can be a hassle.

GitThisBugOff avatar Oct 30 '22 02:10 GitThisBugOff

I was also looking for a way to do this.

gamescope --help

Shows this as one of the options: -O, --prefer-output list of connectors in order of preference

From my understanding of this (#211) issue I should be able to get a list of available connectors with: ls /sys/class/drm/card0/ and then gamescope -O card0-DP-3, for example. But I must be misunderstanding what connectors mean, because it doesn't work for me.

It's also mentioned on that issue that The list of available connectors is printed on startup. If we take a look at older issues (for example #508) we see that the list of connectors indeed was printed on startup, but at least for the version available on Fedora 37 (gamescope-3.11.49-1), that's not the case. Here's my output:

No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
wlserver: [backend/headless/backend.c:82] Creating headless backend
vulkan: selecting physical device 'AMD Radeon RX 5700 XT (RADV NAVI10)': queue family 1
vulkan: physical device supports DRM format modifiers
vulkan: supported DRM formats for sampling usage:
vulkan:   0x34325241
vulkan:   0x34325258
vulkan:   0x3231564E
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/server.c:92] Starting Xwayland on :2
wlserver: [types/wlr_surface.c:748] New wlr_surface 0x55fb7252e560 (res 0x55fb72531330)
wlserver: [xwayland/server.c:250] Xserver is ready
pipewire: stream state changed: connecting
pipewire: stream state changed: paused
pipewire: stream available on node ID: 64
pipewire: renegotiating stream params (size: 1280x720)

Am I right in believing that the -O parameter should allow us to select a specific monitor or did I misunderstood what it means ?

Arbitrate3280 avatar Dec 28 '22 20:12 Arbitrate3280

@Vitorvlv I believe the help output is of use here.

-O is under the header for Embedded mode. This means running without X11 or Wayland, so basically pure framebuffer from a TTY. The -O would be needed because at that point there's no concept of monitors or screens, just connectors.

parkerlreed avatar Dec 28 '22 20:12 parkerlreed

Ah, I see. Thank you!!

Arbitrate3280 avatar Dec 28 '22 20:12 Arbitrate3280

For reference here's the option being used on TTY on a Steam Deck

20221228_154041 20221228_154254 20221228_154305 20221228_154327 20221228_154335

parkerlreed avatar Dec 28 '22 20:12 parkerlreed

It does exactly what I would like it to do. Shame it can only done while in embedded mode, hopefully this feature can be implemented at some point.

Thanks for showing me!

Arbitrate3280 avatar Dec 28 '22 22:12 Arbitrate3280

It does exactly what I would like it to do. Shame it can only done while in embedded mode, hopefully this feature can be implemented at some point.

It doesn' t make sense to be implemented in nested mode since in that case the parent compositor is the one that manages windows and monitors. You should be able to select in which monitor to show gamescope window in the settings of your desktop environment.

Samsagax avatar Dec 29 '22 11:12 Samsagax

You should be able to select in which monitor to show gamescope window in the settings of your desktop environment.

While that does seems to be the case for plasma, using kwin's window rules, I couldn't find a way to do it in gnome (wayland), the DE i'm using. If anyone has any ideas I would be grateful to be pointed in the right direction.

Arbitrate3280 avatar Dec 29 '22 12:12 Arbitrate3280

I'll also add an additional edge case where the output flag does not work.

I have two GPU/DRM one is a Nvidia 4060 which I am using for Scanout over HDMI and the other is my Primary GPU (6800XT) which I want to use as a renderer.

In either situation (without an existing compositor i.e plasma) gamescope does not honor the output connector. Nor given that the only way to get nvidia and amd working is to ensure that a panel is connected to the amd gpu at boot (i.e DP-1). The HDMI-A-3 that shows as connected in Plasma wayland via nvidia never gets probed as nvidia drm modeset is not handling the tty/console - the amdgpu is. And so even with an approprite invoation of gamescope i.e : gamescope --hdr-enabled -W 3840 -H 2160 --prefer-vk-device 1002:73bf -O HDMI-A-3 steam

results in the DP-1 output being selected.

Ideally being able to launch gamescope from either nested mode using the existing amdgpu compositor and using the second gpu as scanout should be possible. I guess this would require some probing to check to see if a connector is claimed already?

The first instance should also work without an existing compositor, but doesn't due to expectation render and scanout will be the same device which is often not that case.

aenertia avatar Jul 15 '23 11:07 aenertia

Workaround for wayland/sway users:

>>> ~/.config/sway/config for_window [ app_id="gamescope" ] 'move output current ; focus parent ; focus child'

It moves gamescope window to the current monitor and acquire focus.

telychko avatar Oct 15 '23 21:10 telychko

More viable solution. Place this line before running gamescope (not in config)

swaymsg "for_window [ app_id=gamescope ] 'move output current ; workspace back_and_forth ; workspace back_and_forth'"

Moving back and forth needed to gain focus back.

telychko avatar Oct 20 '23 13:10 telychko

not sure when it was added but --display-index seems to work for me

Briaoeuidhtns avatar Mar 20 '24 21:03 Briaoeuidhtns

not sure when it was added but --display-index seems to work for me

https://github.com/ValveSoftware/gamescope/commit/1bd20cebd2980e629161669caec5c5306c63da70

parkerlreed avatar Mar 21 '24 01:03 parkerlreed

not sure when it was added but --display-index seems to work for me

hey man, how did you use it in a command? i tried this: gamescope -W 3840 -H 2160 -e --display-index 2 -- steam -bigpicture but this doesnt work, it just launches on my monitor, i want to launch big picture on my TV and still have my monitor plugged in, I am on CachyOS using KDE Plasma with Wayland

shenk-i avatar Apr 15 '24 17:04 shenk-i

Fwiw --display-index does nothing on the Wayland backend.

Can we even do anything there? I am not sure. Maybe pass an output to set_fullscreen? I'll look into it

misyltoad avatar Apr 15 '24 20:04 misyltoad

Fwiw --display-index does nothing on the Wayland backend.

Can we even do anything there? I am not sure. Maybe pass an output to set_fullscreen? I'll look into it

oh i see, sorry im really new on linux :D

shenk-i avatar Apr 15 '24 20:04 shenk-i

--display-index works fine for me, only problem is that the index seems to change randomly

Visne avatar Apr 15 '24 21:04 Visne

I’m on Wayland (kwin) and have the same issue as @Visne: the index isn’t stable per output, but changes based on what outputs are currently connected.

It would be great to have an alternative way of specifying. E.g. the following script returns for me:

0: DP-1 34"

So being able to specify --display=DP-1 would be nice!

I don’t know why SDL adds the 34" here, on linux the adapter is /sys/class/drm/card1-DP-1, so the information would be there I guess.

#!/usr/bin/env run-cargo-script
//! Get all display names
//!
//! ```cargo
//! [dependencies]
//! color-eyre = "0.6"
//! sdl2 = "0.36.0"
//! ```

extern crate color_eyre;
extern crate sdl2;

use color_eyre::eyre::{Result, eyre};

fn main() -> Result<()> {
	color_eyre::install()?;

	let sdl = sdl2::init().map_err(|e| eyre!(e))?;
	let video = sdl.video().map_err(|e| eyre!(e))?;
	for d in 0..video.num_video_displays().map_err(|e| eyre!(e))? {
		println!("{d}: {}", video.display_name(d).map_err(|e| eyre!(e))?);
	}

	Ok(())
}

flying-sheep avatar Apr 16 '24 08:04 flying-sheep

Fwiw --display-index does nothing on the Wayland backend.

Can we even do anything there? I am not sure. Maybe pass an output to set_fullscreen? I'll look into it

I am not sure how it works, but some (Windows) games (that I run via Proton) allow me to select the monitor, even when they run fullscreen. (I am running KDE Plasma Wayland.)

I would mainly want to use gamescope to move the games that do not include multi monitor support to my second monitor.

devurandom avatar May 12 '24 21:05 devurandom

--display-index seems to work for me. The only way I've been able to reliably determine which display gets which index, however, is by compiling the SDL2 test utilities and using testdisplayinfo. It doesn't seem consistent, at least I haven't looked deeply enough to determine if there's something that can be configured to ensure consistency.

nlutterman avatar Jul 10 '24 07:07 nlutterman

I cannot get it to work in my multi monitor setup. With gamescope -f -w 2560 -h 1440 --display-index 2 --hdr-enabled %command% System Shock (2023) still starts on the primary screen. (I tried --display-index 0, 1, 2 and 3.)

I do get an error dialogue, though (appears a 2nd time, when I press "Ok"):

CreateSwapchainKHR: Creating swapchain for non-Gamescope swapchain.
Hooking has failed somewhere!
You may have a bad Vulkan layer interfering.
Press OK to try to power through this error, or Cancel to stop.

Steam:

❯ flatpak info com.valvesoftware.Steam

Valve Corporation - Launcher for the Steam software distribution service

          ID: com.valvesoftware.Steam
         Ref: app/com.valvesoftware.Steam/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 1.0.0.79
     License: LicenseRef-proprietary
      Origin: flathub
  Collection: org.flathub.Stable
Installation: system
   Installed: 45,5 MB
     Runtime: org.freedesktop.Platform/x86_64/23.08
         Sdk: org.freedesktop.Sdk/x86_64/23.08

      Commit: 173cd565d98d4951bd858bad290e8481a9e72dbf5f7c9c980165a060666184b1
      Parent: 98f034b154eed70b957bedcba0a5ce3785e70999b4aef85e1f6dd66f2eb15ff7
     Subject: Add pressure-vessel's overrides data dir to XDG_DATA_DIRS (ee358536)
        Date: 2024-04-03 13:45:40 +0000

Gamescope:

❯ flatpak info org.freedesktop.Platform.VulkanLayer.gamescope

gamescope - The micro-compositor formerly known as steamcompmgr

          ID: org.freedesktop.Platform.VulkanLayer.gamescope
         Ref: runtime/org.freedesktop.Platform.VulkanLayer.gamescope/x86_64/23.08
        Arch: x86_64
      Branch: 23.08
     Version: 3.14.24
     License: BSD-2-Clause
      Origin: flathub
  Collection: org.flathub.Stable
Installation: system
   Installed: 17,0 MB

      Commit: 0039e1ddb7c62864450f769b8828ce6b22932c1ce8a1819613638d0c028de84e
      Parent: 5087007a6d3cb2e95afdbb68823764e95254f4b5ab693378d5789d2a3a9dab0e
     Subject: Update gamescope and xwayland modules (#217) (5202e5a7)
        Date: 2024-07-10 17:26:32 +0000

System:

Operating System: NixOS 24.05
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.2
Kernel Version: 6.10.1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 9 6900HS with Radeon Graphics
Memory: 30,6 GiB of RAM
Graphics Processor: AMD Radeon Graphics

Window manager: https://invent.kde.org/-/snippets/3190

devurandom avatar Jul 28 '24 14:07 devurandom