Skip to content

Instantly share code, notes, and snippets.

@Barteks2x
Created March 31, 2017 09:31
Show Gist options
  • Save Barteks2x/3dbb087114ffeb1ba4e73dcb033b9574 to your computer and use it in GitHub Desktop.
Save Barteks2x/3dbb087114ffeb1ba4e73dcb033b9574 to your computer and use it in GitHub Desktop.
A way to make running things with nvidia GPU with nouuveau easier on Cinnamon. These files go into /usr/share/nemo/actions/
#!/usr/bin/env python
import errno
import os
import sys
from gi.repository import Gio
os.environ["DRI_PRIME"] = "1"
arg, *rest = sys.argv[1:]
if not os.path.isfile(arg):
exit("error: not a file: %r" % arg)
# check for .desktop mime type as workaround to https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/378783
if arg.endswith(".desktop"):
Gio.DesktopAppInfo.new_from_filename(sys.argv[1]).launch_uris(sys.argv[2:])
else:
try:
os.execl(arg, arg, *rest)
except OSError as e:
if e.errno in {errno.ENOEXEC, errno.EACCES}:
print("bad file format, trying xdg-open")
os.execlp("xdg-open", "xdg-open", arg)
else:
exit("error: could not run %r: %r" % (arg, e))
[Nemo Action]
Name=Run with PRIME
Comment=Run the executable with DRI_PRIME=1 to use nvidia GPU
Exec=<run-prime.py %F>
Selection=s
Mimetypes=application/*;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment