Created Tuesday 02 April 2019
# This should have better performance than the bumblebee solution.
# If you've chosen not to install the dkms package with bumblebee,
# you will have to run a window manager from a second tty, to use the card.
USAGE!!!
# When the below is settled,
# To use it, you have to log out of the current desktop session
# then run nvidia-xrun
# Voila, the desktop now starts up using the nvidia card.
Install
$ pacman -S nvidia lib32-nvidia-utils bbswitch
$ cower -d nvidia-xrun
Hook
# Create a hook to update the mkinitcpio
$ sudo vim /etc/pacman.d/hooks/nvidia.hook
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux
# Change the linux part above and in the Exec line if a different kernel is used
Description=Update Nvidia module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux) exit 0; esac; done; /usr/bin/mkinitcpio -P'
BUS id
# Get the bus id and create an xorg.conf file
$ $ lspci | egrep 'VGA|3D'
# It should be 03:00.0 which should be formatted to 3:0:0
# Then create the xorg conf
$ sudo vim /etc/X11/xorg.conf
Driver "nvidia"
BusID "PCI:3:0:0"
Option "AllowEmptyInitialConfiguration"
# Be aware, that the above might be autogenerated and the BUSid might be set wrong!
# Also create this mofo
$ vim /etc/X11/nvidia-xorg.conf.d/30-nvidia.conf
Driver "nvidia"
BusID "PCI:3:0:0"
Create xrun-xinit
$ vim ~/.nvidia-xinitrc
# No need for an exec apparently. Just define the WM/desktop
Screen tearing
# Ait, add a kernel parameter to the MODULES array
# (edit the modules line, and add nvidia, nvidia_modeset, nvidia_uvm and nvidia_drm )
$ vim /etc/mkinitcpio.conf
# Edit, and add to the GRUB config
$ vim /etc/default/grub
# And update GRUB
$ grub-mkconfig -o /boot/grub/grub.cfg
BBswitch - SHOULDN'T BE NECESSARY
# To enable it by default from start
# Use the Super User
$ su
$ echo 'bbswitch ' > /etc/modules-load.d/bbswitch.conf
# Turn it back off by default - also SU
$ echo 'options bbswitch load_state=0 unload_state=1' > /etc/modprobe.d/bbswitch.conf
# To check the status
cat /proc/acpi/bbswitch
# Turn it on manually
$ sudo tee /proc/acpi/bbswitch <<<ON
# And back off
$ sudo tee /proc/acpi/bbswitch <<<OFF