diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index ffa4312..09df3e8 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -10,6 +10,7 @@ import traceback import gi gi.require_version("Gtk", "3.0") gi.require_version('MatePanelApplet', '4.0') +gi.require_version('XApp', '1.0') from gi.repository import Gtk, GdkPixbuf, Gdk, GObject from gi.repository import MatePanelApplet from gi.repository import Gio diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 262d82f..893a3f5 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -192,9 +192,13 @@ class pluginclass(object): self.canOffload = False try: - self.canOffload = XApp.util_gpu_offload_supported() + helper = XApp.GpuOffloadHelper.get_sync() + self.canOffload = helper.is_offload_supported() except AttributeError: - print("Could not check for gpu offload support - maybe xapps isn't up to date."); + try: + self.canOffload = XApp.util_gpu_offload_supported() + except AttributeError: + print("Could not check for gpu offload support - maybe xapps isn't up to date."); # Detect the locale (this is used for the Wikipedia search) self.lang = "en" diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index 206b6b8..17001de 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -268,6 +268,7 @@ class ApplicationLauncher(easyButton): self.appMateDocPath = desktopItem.get("X-MATE-DocPath") or "" self.useTerminal = desktopItem.getTerminal() self.appPath = desktopItem.getPath() + self.prefersOffload = desktopItem.get("PrefersNonDefaultGPU", "Desktop Entry", type="boolean") if not self.appMateDocPath: self.appKdeDocPath = desktopItem.getDocPath() or "" @@ -355,6 +356,9 @@ class ApplicationLauncher(easyButton): except KeyError: pass + if self.prefersOffload: + offload = True + Execute(None, desktopFile=self.desktopFile, offload=offload) def uninstall(self, *args): diff --git a/usr/lib/linuxmint/mintMenu/plugins/execute.py b/usr/lib/linuxmint/mintMenu/plugins/execute.py index 64de85e..c3f5d7a 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/execute.py +++ b/usr/lib/linuxmint/mintMenu/plugins/execute.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 import os -from gi.repository import Gio, GLib, Gdk +from gi.repository import Gio, GLib, Gdk, XApp def RemoveArgs(Execline): @@ -32,8 +32,19 @@ def Execute(cmd , commandCwd=None, desktopFile=None, offload=False): if offload: print("Offloading '%s' to discrete gpu." % launcher.get_name()); - context.setenv("__NV_PRIME_RENDER_OFFLOAD", "1") - context.setenv("__GLX_VENDOR_LIBRARY_NAME", "nvidia"); + try: + helper = XApp.GpuOffloadHelper.get_sync() + infos = helper.get_offload_infos() + + if infos: + i = 0 + env_strv = infos[0].env_strv + while i < len(env_strv): + context.setenv(env_strv[i], env_strv[i + 1]) + i += 2 + except AttributeError: + context.setenv("__NV_PRIME_RENDER_OFFLOAD", "1") + context.setenv("__GLX_VENDOR_LIBRARY_NAME", "nvidia"); try: retval = launcher.launch_uris_as_manager(uris=[],