flathub / com.mojang.Minecraft

https://flathub.org/apps/details/com.mojang.Minecraft
32 stars 13 forks source link

Gamescope extension support #112

Open vchernin opened 2 years ago

vchernin commented 2 years ago

Todo:

flathubbot commented 2 years ago

Started test build 68162

flathubbot commented 2 years ago

Build 68162 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/65995/com.mojang.Minecraft.flatpakref
flathubbot commented 2 years ago

Started test build 68172

flathubbot commented 2 years ago

Build 68172 successful To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/66005/com.mojang.Minecraft.flatpakref
AsciiWolf commented 2 years ago

Thanks! I will test it when I have more time, however I am not sure whether I like adding a new wrapper script just for Gamescope.

vchernin commented 2 years ago

In theory a wrapper script could also be necessary for mods, optifine etc, but I haven't tried that yet.

I agree it's not ideal, I'm sure there's some trick I could use to avoid the wrapper, I just haven't found it. Gotta keep working on my scripting skills :)

AsciiWolf commented 2 years ago

You could probably include it as a function directly in the main script file, then call the function. ;-)

vchernin commented 2 years ago

Running from a function works fine, I discovered that early on. The problem is passing --workDir doesn't work without a new file.

The commited version with the wrapper script is able to correctly launch gamescope with minecraft with all correct arguments (at least as far as I can tell).

To only use one file, you can replace the last exec line with one of the following demos:

Works (but no --workDir)

minecraft_wrapper () {
    exec /app/utils/gamescope/bin/gamescope "/app/extra/minecraft-launcher/minecraft-launcher"
}

# verify extension installed and config file exists.
if test -f "/app/utils/gamescope/bin/gamescope" && test -f "$XDG_DATA_HOME/../.minecraft/gamescope.txt"; then    

    minecraft_wrapper "--workDir $XDG_DATA_HOME/../.minecraft"
else 
    /app/extra/minecraft-launcher/minecraft-launcher
fi

Notice how even though I'm passing --workDir to the function, the function doesn't actually use any parameters, i.e. there is no $1.

But if I tell it to use the --workDir argument:

minecraft_wrapper () {
    exec /app/utils/gamescope/bin/gamescope "/app/extra/minecraft-launcher/minecraft-launcher $1"
}

# verify extension installed and config file exists.
if test -f "/app/utils/gamescope/bin/gamescope" && test -f "$XDG_DATA_HOME/../.minecraft/gamescope.txt"; then    

    minecraft_wrapper "--workDir $XDG_DATA_HOME/../.minecraft"
else 
    /app/extra/minecraft-launcher/minecraft-launcher
fi

Now this never works.

Error
``` [v@thinkpad-x1 com.mojang.Minecraft]$ flatpak run com.mojang.Minecraft No CAP_SYS_NICE, falling back to regular-priority compute and threads. Performance will be affected. MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0 vulkan: selecting physical device 'Intel(R) UHD Graphics 620 (WHL GT2)' vulkan: physical device supports DRM format modifiers vulkan: supported DRM formats for sampling usage: vulkan: 0x34325241 vulkan: 0x34325258 vulkan: 0x3231564E wlserver: [backend/noop/backend.c:59] Creating noop backend wlserver: Running compositor on wayland display 'gamescope-0' wlserver: [backend/noop/backend.c:16] Starting noop backend wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X0: Address already in use wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X1: Address already in use wlserver: [xwayland/server.c:84] Starting Xwayland on :2 The XKEYBOARD keymap compiler (xkbcomp) reports: > Warning: Could not resolve keysym XF86BrightnessAuto > Warning: Could not resolve keysym XF86DisplayOff > Warning: Could not resolve keysym XF86Info > Warning: Could not resolve keysym XF86AspectRatio > Warning: Could not resolve keysym XF86DVD > Warning: Could not resolve keysym XF86Audio > Warning: Could not resolve keysym XF86ChannelUp > Warning: Could not resolve keysym XF86ChannelDown > Warning: Could not resolve keysym XF86Break > Warning: Could not resolve keysym XF86VideoPhone > Warning: Could not resolve keysym XF86ZoomReset > Warning: Could not resolve keysym XF86Editor > Warning: Could not resolve keysym XF86GraphicsEditor > Warning: Could not resolve keysym XF86Presentation > Warning: Could not resolve keysym XF86Database > Warning: Could not resolve keysym XF86Voicemail > Warning: Could not resolve keysym XF86Addressbook > Warning: Could not resolve keysym XF86DisplayToggle > Warning: Could not resolve keysym XF86SpellCheck > Warning: Could not resolve keysym XF86ContextMenu > Warning: Could not resolve keysym XF86MediaRepeat > Warning: Could not resolve keysym XF8610ChannelsUp > Warning: Could not resolve keysym XF8610ChannelsDown > Warning: Could not resolve keysym XF86Images > Warning: Could not resolve keysym XF86NotificationCenter > Warning: Could not resolve keysym XF86PickupPhone > Warning: Could not resolve keysym XF86HangupPhone > Warning: Could not resolve keysym XF86Fn > Warning: Could not resolve keysym XF86Fn_Esc > Warning: Could not resolve keysym XF86FnRightShift > Warning: Could not resolve keysym XF86Numeric0 > Warning: Could not resolve keysym XF86Numeric1 > Warning: Could not resolve keysym XF86Numeric2 > Warning: Could not resolve keysym XF86Numeric3 > Warning: Could not resolve keysym XF86Numeric4 > Warning: Could not resolve keysym XF86Numeric5 > Warning: Could not resolve keysym XF86Numeric6 > Warning: Could not resolve keysym XF86Numeric7 > Warning: Could not resolve keysym XF86Numeric8 > Warning: Could not resolve keysym XF86Numeric9 > Warning: Could not resolve keysym XF86NumericStar > Warning: Could not resolve keysym XF86NumericPound > Warning: Could not resolve keysym XF86NumericA > Warning: Could not resolve keysym XF86NumericB > Warning: Could not resolve keysym XF86NumericC > Warning: Could not resolve keysym XF86NumericD > Warning: Could not resolve keysym XF86CameraFocus > Warning: Could not resolve keysym XF86WPSButton > Warning: Could not resolve keysym XF86CameraZoomIn > Warning: Could not resolve keysym XF86CameraZoomOut > Warning: Could not resolve keysym XF86CameraUp > Warning: Could not resolve keysym XF86CameraDown > Warning: Could not resolve keysym XF86CameraLeft > Warning: Could not resolve keysym XF86CameraRight > Warning: Could not resolve keysym XF86AttendantOn > Warning: Could not resolve keysym XF86AttendantOff > Warning: Could not resolve keysym XF86AttendantToggle > Warning: Could not resolve keysym XF86LightsToggle > Warning: Could not resolve keysym XF86ALSToggle > Warning: Could not resolve keysym XF86Buttonconfig > Warning: Could not resolve keysym XF86Taskmanager > Warning: Could not resolve keysym XF86Journal > Warning: Could not resolve keysym XF86ControlPanel > Warning: Could not resolve keysym XF86AppSelect > Warning: Could not resolve keysym XF86Screensaver > Warning: Could not resolve keysym XF86VoiceCommand > Warning: Could not resolve keysym XF86Assistant > Warning: Could not resolve keysym XF86BrightnessMin > Warning: Could not resolve keysym XF86BrightnessMax > Warning: Could not resolve keysym XF86KbdInputAssistPrev > Warning: Could not resolve keysym XF86KbdInputAssistNext > Warning: Could not resolve keysym XF86KbdInputAssistPrevgroup > Warning: Could not resolve keysym XF86KbdInputAssistNextgroup > Warning: Could not resolve keysym XF86KbdInputAssistAccept > Warning: Could not resolve keysym XF86KbdInputAssistCancel > Warning: Could not resolve keysym XF86RightUp > Warning: Could not resolve keysym XF86RightDown > Warning: Could not resolve keysym XF86LeftUp > Warning: Could not resolve keysym XF86LeftDown > Warning: Could not resolve keysym XF86RootMenu > Warning: Could not resolve keysym XF86MediaTopMenu > Warning: Could not resolve keysym XF86Numeric11 > Warning: Could not resolve keysym XF86Numeric12 > Warning: Could not resolve keysym XF86AudioDesc > Warning: Could not resolve keysym XF863DMode > Warning: Could not resolve keysym XF86NextFavorite > Warning: Could not resolve keysym XF86StopRecord > Warning: Could not resolve keysym XF86PauseRecord > Warning: Could not resolve keysym XF86VOD > Warning: Could not resolve keysym XF86Unmute > Warning: Could not resolve keysym XF86FastReverse > Warning: Could not resolve keysym XF86SlowReverse > Warning: Could not resolve keysym XF86Data > Warning: Could not resolve keysym XF86OnScreenKeyboard > Warning: Could not resolve keysym XF86PrivacyScreenToggle > Warning: Could not resolve keysym XF86SelectiveScreenshot > Warning: Could not resolve keysym XF86Macro1 > Warning: Could not resolve keysym XF86Macro2 > Warning: Could not resolve keysym XF86Macro3 > Warning: Could not resolve keysym XF86Macro4 > Warning: Could not resolve keysym XF86Macro5 > Warning: Could not resolve keysym XF86Macro6 > Warning: Could not resolve keysym XF86Macro7 > Warning: Could not resolve keysym XF86Macro8 > Warning: Could not resolve keysym XF86Macro9 > Warning: Could not resolve keysym XF86Macro10 > Warning: Could not resolve keysym XF86Macro11 > Warning: Could not resolve keysym XF86Macro12 > Warning: Could not resolve keysym XF86Macro13 > Warning: Could not resolve keysym XF86Macro14 > Warning: Could not resolve keysym XF86Macro15 > Warning: Could not resolve keysym XF86Macro16 > Warning: Could not resolve keysym XF86Macro17 > Warning: Could not resolve keysym XF86Macro18 > Warning: Could not resolve keysym XF86Macro19 > Warning: Could not resolve keysym XF86Macro20 > Warning: Could not resolve keysym XF86Macro21 > Warning: Could not resolve keysym XF86Macro22 > Warning: Could not resolve keysym XF86Macro23 > Warning: Could not resolve keysym XF86Macro24 > Warning: Could not resolve keysym XF86Macro25 > Warning: Could not resolve keysym XF86Macro26 > Warning: Could not resolve keysym XF86Macro27 > Warning: Could not resolve keysym XF86Macro28 > Warning: Could not resolve keysym XF86Macro29 > Warning: Could not resolve keysym XF86Macro30 > Warning: Could not resolve keysym XF86MacroRecordStart > Warning: Could not resolve keysym XF86MacroRecordStop > Warning: Could not resolve keysym XF86MacroPresetCycle > Warning: Could not resolve keysym XF86MacroPreset1 > Warning: Could not resolve keysym XF86MacroPreset2 > Warning: Could not resolve keysym XF86MacroPreset3 > Warning: Could not resolve keysym XF86KbdLcdMenu1 > Warning: Could not resolve keysym XF86KbdLcdMenu2 > Warning: Could not resolve keysym XF86KbdLcdMenu3 > Warning: Could not resolve keysym XF86KbdLcdMenu4 > Warning: Could not resolve keysym XF86KbdLcdMenu5 Errors from xkbcomp are not fatal to the X server wlserver: [types/wlr_surface.c:737] New wlr_surface 0x559c860b0670 (res 0x559c86204480) wlserver: [xwayland/server.c:242] Xserver is ready pipewire: pw_context_connect failed Warning: failed to setup PipeWire, screen capture won't be available xwm: execvp failed: No such file or directory gamescope: received kill signal, terminating! (EE) failed to read Wayland events: Broken pipe ```

Somehow launching gamescope within a function, with a command that happens to have an argument causes xwm to not be found. The same happens with other minecraft launcher arguments. Yet this problem doesn't exist with a new file as commited.

orowith2os commented 1 year ago

Please remember to update this to use the new gamescope extension, if you (or anyone else) picks up work on it: https://github.com/flathub/com.valvesoftware.Steam.Utility.gamescope