Repository: lutris/lutris

Issue:
gamemode option greyed out on kubuntu 20.04
**Describe the bug**

Option greyed out.

**Expected behavior**

Not, greyed, out.

**Current behavior**

Greyed, out.

**Steps to reproduce**

- Install ubuntu 20.04
- Install lutris
- Launch lutris

**Lutris debugging output**

[gamemode.tar.gz](https://github.com/lutris/lutris/files/4716458/gamemode.tar.gz)


**System information**

[lutris-issue-report.tar.gz](https://github.com/lutris/lutris/files/4716460/lutris-issue-report.tar.gz)

**Screenshots**

![image](https://user-images.githubusercontent.com/5204968/83504878-b5965280-a4cd-11ea-8aa1-016ac86d8407.png)



Discussion:
I believe that it should only be greyed when it can't find what it needs to find on the system (50% a Lutris problem) or Feral game mode isn't installed correctly for Lutris to use (100% user problem).

In any case, an issue present on the official git suggests Debian based distros don't fully support Feral game mode out-of-the box? https://github.com/FeralInteractive/gamemode/issues/216

In the end, if you search and find libgamemodeauto.so in /usr/lib & /usr/lib64 then I would assume it should not be greyed out as that's what it looks like the setting is using to determine eligibility. [Its possible that other paths might work as well.]
Yes, on Ubuntu 18.04 libgamemodeauto.so.0 shows up as 64bit only and in /usr/lib/x86_64-linux-gnu.

Maybe Lutris can try to support it as-is but I don't know why it doesn't already.
Ubuntu 20.04 is 64bit only, fast fix is Configure -> System options -> Command prefix set to gamemoderun ;) Of course you can setup it for every new installation in **Manage Runners**

Resolving patch:
diff --git a/lutris/game.py b/lutris/game.py
--- a/lutris/game.py
+++ b/lutris/game.py
@@ -474,10 +474,13 @@ def configure_game(self, prelaunched, error=None):  # noqa: C901
         # Feral gamemode
         gamemode = system_config.get("gamemode")
         if gamemode:
-            env["LD_PRELOAD"] = ":".join([path for path in [
-                env.get("LD_PRELOAD"),
-                "libgamemodeauto.so",
-            ] if path])
+            if system.find_executable("gamemoderun"):
+                launch_arguments.insert(0, "gamemoderun")
+            else:
+                env["LD_PRELOAD"] = ":".join([path for path in [
+                    env.get("LD_PRELOAD"),
+                    "libgamemodeauto.so",
+                ] if path])
 
         # LD_LIBRARY_PATH
         game_ld_libary_path = gameplay_info.get("ld_library_path")
diff --git a/lutris/sysoptions.py b/lutris/sysoptions.py
--- a/lutris/sysoptions.py
+++ b/lutris/sysoptions.py
@@ -240,8 +240,8 @@ def get_vk_icd_choices():
     {
         "option": "gamemode",
         "type": "bool",
-        "default": system.LINUX_SYSTEM.is_feature_supported("GAMEMODE"),
-        "condition": system.LINUX_SYSTEM.is_feature_supported("GAMEMODE"),
+        "default": system.LINUX_SYSTEM.gamemode_available,
+        "condition": system.LINUX_SYSTEM.gamemode_available,
         "label": "Enable Feral gamemode",
         "help": "Request a set of optimisations be temporarily applied to the host OS",
     },
diff --git a/lutris/util/linux.py b/lutris/util/linux.py
--- a/lutris/util/linux.py
+++ b/lutris/util/linux.py
@@ -14,6 +14,7 @@
 from lutris.util.disks import get_drive_for_path
 from lutris.util.graphics import drivers, glxinfo, vkquery
 from lutris.util.log import logger
+from lutris.util import system
 
 try:
     from distro import linux_distribution
@@ -208,6 +209,16 @@ def get_kernel_version():
             version = info.split(" ")[2]
         return version
 
+    def gamemode_available(self):
+        """Return whether gamemode is available"""
+        # Current versions of gamemode use gamemorerun
+        if system.find_executable("gamemoderun"):
+            return True
+        # This is for old versions of gamemode only
+        if self.is_feature_supported("GAMEMODE"):
+            return True
+        return False
+
     @property
     def is_flatpak(self):
         """Check is we are running inside Flatpak sandbox"""


Test patch: