diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2bc7515 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Created by .ignore support plugin (hsz.mobi) +nvidia-xrun.iml +.idea diff --git a/README.md b/README.md index 5d813e2..38eee0a 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,47 @@ These utility scripts aim to make the life easier for nvidia cards users. It started with a revelation that bumblebee in current state offers very poor performance. This solution offers a bit more complicated procedure but offers a full GPU utilization(in terms of linux drivers) ## Usage: - 1) switch to free tty - - 2) login - - 3) run _nvidia-xrun_ _app_ - - 4) enjoy - + 1. switch to free tty + 2. login + 3. run _nvidia-xrun_ [_app_] + 4. enjoy Currently sudo is required as the script needs to wake up GPU, modprobe the nvidia driver and perform cleanup afterwards. For this we use bbswitch. - + +## Structure +* **nvidia-xrun** - uses following dir structure: +* **/usr/bin/nvidia-xrun** - the executable script +* **/etc/X11/nvidia-xorg.conf** - the main X confing file +* **/etc/X11/xinit/nvidia-xinitrc** - xinitrc config file. Contains the setting of provider output source +* **/etc/X11/xinit/nvidia-xinitrc.d** - custom xinitrc scripts directory +* **/etc/X11/nvidia-xorg.conf.d** - custom X config directory +* **[OPTIONAL] ~/.nvidia-xinitrc** - user-level custom xinit script file. You can put here your favourite window manager for example + + +## Setting the right bus id +Usually the 1:0:0 bus is correct. If this is not your case(you can find out through lspci or bbswitch output mesages) you can create +a conf script in /etc/X11/nvidia-xorg.conf.d to set the proper bus id + + Section "Device" + Identifier "nvidia" + Driver "nvidia" + BusID "PCI:2:0:0" + EndSection + +Also this way you can adjust some nvidia settings if you encounter issues: + + Section "Screen" + Identifier "nvidia" + Device "nvidia" + # Option "AllowEmptyInitialConfiguration" "Yes" + # Option "UseDisplayDevice" "none" + EndSection + ## Aur package the aur package can be found here: https://aur.archlinux.org/packages/nvidia-xrun/ + + +## Troubleshooting +### Steam issues +Yes unfortunately this does not work well - I recommend to use some window manager like openbox +# diff --git a/nvidia-xinitrc b/nvidia-xinitrc index 0139422..c766384 100644 --- a/nvidia-xinitrc +++ b/nvidia-xinitrc @@ -1,6 +1,44 @@ #!/bin/bash -export LD_LIBRARY_PATH=/usr/lib64/nvidia/:/usr/lib32/nvidia:/usr/lib:$LD_LIBRARY_PATH +userresources=$HOME/.Xresources +usermodmap=$HOME/.Xmodmap +sysresources=/etc/X11/xinit/.Xresources +sysmodmap=/etc/X11/xinit/.Xmodmap +userxinitrc=$HOME/.nvidia-xinitrc + +# merge in defaults and keymaps +if [ -f ${sysresources} ]; then + xrdb -merge ${sysresources} +fi + +if [ -f ${sysmodmap} ]; then + xmodmap ${sysmodmap} +fi + +if [ -f "$userresources" ]; then + xrdb -merge "$userresources" +fi + +if [ -f "$usermodmap" ]; then + xmodmap "$usermodmap" +fi + +# load additional configs +if [ -d /etc/X11/xinit/nvidia-xinitrc.d ] ; then + for f in /etc/X11/xinit/nvidia-xinitrc.d/?*.sh ; do + [ -x "$f" ] && . "$f" + done + unset f +fi + +export LD_LIBRARY_PATH=/usr/lib64/nvidia/:/usr/lib32/nvidia:/usr/lib:${LD_LIBRARY_PATH} xrandr --setprovideroutputsource modesetting NVIDIA-0 xrandr --auto -$* +if [ -f "$userxinitrc" ]; then + sh ${userxinitrc} +fi + +if [ $# -gt 0 ] + then + $* +fi diff --git a/nvidia-xrun b/nvidia-xrun index da358c7..40eaecd 100644 --- a/nvidia-xrun +++ b/nvidia-xrun @@ -3,7 +3,7 @@ DRY_RUN=0 function printHelp { echo "Utility to run games and applications in separate X on discrete Nvidia graphic card" echo "Usage: " - echo "nvidia-xrun [] " + echo "nvidia-xrun [] []" echo "Options: " echo " -d Dry run - prints the final command but does not execute it" } @@ -29,12 +29,6 @@ if [ "$1" == "-d" ] shift 1 fi -if [ $# -eq 0 ] - then - printHelp - exit 1 -fi - # calculate current VT LVT=`fgconsole` @@ -82,14 +76,14 @@ execute "sudo modprobe nvidia_drm" execute $COMMAND -echo 'Unloading nvidia module' -execute "sudo rmmod nvidia" +echo 'Unloading nvidia_drm module' +execute "sudo rmmod nvidia_drm" echo 'Unloading nvidia_modeset module' execute "sudo rmmod nvidia_modeset" -echo 'Unloading nvidia_drm module' -execute "sudo rmmod nvidia_drm" +echo 'Unloading nvidia module' +execute "sudo rmmod nvidia" echo 'Turning off nvidia GPU' execute "sudo tee /proc/acpi/bbswitch <<