Skip to content

Instantly share code, notes, and snippets.

@Brainiarc7
Last active November 11, 2018 15:16
Show Gist options
  • Save Brainiarc7/03c188cb045253ff7caf to your computer and use it in GitHub Desktop.
Save Brainiarc7/03c188cb045253ff7caf to your computer and use it in GitHub Desktop.
Enable NVIDIA PRIME's selector on Arch Linux
# Maintainer: Dennis E. Mungai <dmngaie@gmail.com>
pkgname=nvidia-prime
pkgver=0.7
pkgrel=1
pkgdesc="Tools to enable NVIDIA's Prime."
url="https://launchpad.net/ubuntu/+source/nvidia-prime"
arch=('x86_64' 'i686')
license=('GPLv3')
depends=('lightdm' 'bbswitch' 'python' 'bash')
optdepends=('nvidia' 'lightdm-gtk3-greeter')
makedepends=()
conflicts=()
replaces=()
backup=()
#install='nvidia-prime.install'
source=("https://launchpad.net/ubuntu/+archive/primary/+files/${pkgname}_${pkgver}.tar.gz")
sha256sums=('SKIP')
package() {
cd "${srcdir}/${pkgname}"
mkdir -p "${pkgdir}"/usr/{bin,lib/systemd/system}
mkdir -p "${pkgdir}"/usr/share/{doc/nvidia-prime,nvidia-prime,lightdm/lightdm.conf.d}
#Install PRIME
install -m755 $srcdir/nvidia-prime/get-quirk-options $pkgdir/usr/bin/get-quirk-options
install -m755 $srcdir/nvidia-prime/prime-offload $pkgdir/usr/bin/prime-offload
install -m755 $srcdir/nvidia-prime/prime-select $pkgdir/usr/bin/prime-select
install -m755 $srcdir/nvidia-prime/prime-supported $pkgdir/usr/bin/prime-supported
install -m755 $srcdir/nvidia-prime/prime-switch $pkgdir/usr/bin/prime-switch
#Add nvidia-prime-quirks
install -m755 $srcdir/nvidia-prime/prime-quirks $pkgdir/usr/share/nvidia-prime/prime-quirks
#Add systemD service
install -m644 $srcdir/nvidia-prime/debian/nvidia-prime.service $pkgdir/usr/lib/systemd/system/nvidia-prime.service
#Add LightDM
install -m644 $srcdir/nvidia-prime/90-nvidia.conf $pkgdir/usr/share/lightdm/lightdm.conf.d/90-nvidia.conf
#Other Information
install -m644 $srcdir/nvidia-prime/debian/changelog $pkgdir/usr/share/doc/nvidia-prime/changelog.gz
install -m644 $srcdir/nvidia-prime/debian/copyright $pkgdir/usr/share/doc/nvidia-prime/copyright
}
# vim:set ts=2 sw=2 et:
@osgyan
Copy link

osgyan commented Apr 13, 2016

@CommanderAlchemy I am more than Happy to help. However I am not very good at packaging. If there is anything which you think I can help with, please let me know.

@edoantonioco
Copy link

What happened with this?

@Brainiarc7
Copy link
Author

Hey,

I can work on this in a day or two. Let's get in touch here (see my email address on my profile).

Regards,

Brainiarc7

@Brainiarc7
Copy link
Author

Brainiarc7 commented Jul 1, 2017

By the way, this is @clfarron4 's work, I copied it here as a reminder to contribute this to the AUR.

@TerminalWitchcraft
Copy link

What is the current status? Do we have an AUR package yet?

@oberon-manjaro
Copy link

oberon-manjaro commented Oct 2, 2017

Didn't mean to step on anyone's toes, but since it's been quite a while now I just went ahead now and provided a PKGBUILD for Ubuntu's latest version 0.8.4 in the AUR. If anyone wants to take over maintenance there, just let me know!
https://aur.archlinux.org/packages/nvidia-prime/

@oberon-manjaro
Copy link

Will try adding a separate package for gpu-manager.

@oberon-manjaro
Copy link

oberon-manjaro commented Oct 2, 2017

I've added gpu-manager and u-d-c-gpu-detection from ubuntu-drivers-common to the package directly now
https://aur.archlinux.org/cgit/aur.git/commit/?h=nvidia-prime&id=a32421973458e8a5bffde553c8edd36b9486b3ae
Please test the package and let me know if it works!

@oberon-manjaro
Copy link

Gives

prime-select query
Traceback (most recent call last):
 File "/usr/bin/prime-select", line 401, in <module>
   if not switcher.print_current_alternative():
 File "/usr/bin/prime-select", line 259, in print_current_alternative
   gl_alternatives = self._get_current_gl_alternative()
 File "/usr/bin/prime-select", line 216, in _get_current_gl_alternative
   return self._get_current_alternative(self._gl_switcher, self._gl_switc
her_other)
 File "/usr/bin/prime-select", line 203, in _get_current_alternative
   raw_alternative = switcher.get_current_alternative()
 File "/usr/bin/prime-select", line 83, in get_current_alternative
   c = p.split('\n')
TypeError: a bytes-like object is required, not 'str'

I wonder if the reason is simply that we are not using the same python version as Ubuntu ...
Ideas anyone?

@oberon-manjaro
Copy link

Ok. Fixed now using python2, seems to be working:
https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=nvidia-prime

@ArtyomFR
Copy link

ArtyomFR commented Nov 18, 2017

Hello there, i'm also using arch on a Optimus laptop and i've try many solution but none of theme fully work (some applications works fine some other don't). I've installed a ubuntu on a different HDD to test the nvidia-prime proprietary and it works just fine, all applications use the nvidia card. So I'm happy to see that some of you are porting this to arch. But when I test it it doesn't work:
$ sudo prime-select nvidia
Info: the current GL alternatives in use are: [None, None]
Info: the current EGL alternatives in use are: [None, None]
Error: the installed packages do not support PRIME
Error: nvidia mode can't be enable
If anyone have an idea on how to get ride of this I would be really thanksfull!

@wildtruc
Copy link

You can try there https://github.com/wildtruc/nvidia-prime-select
Fork from Fedora-prime to be multi-distros. Works nicely... now. :s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment