Skip to content

Commit

Permalink
Updated xinitrc, updated readme, added support for running app from ~…
Browse files Browse the repository at this point in the history
…/.nvidia-xinitrc, Fixed module unloading order
  • Loading branch information
Witko committed Oct 20, 2016
1 parent bf1eeab commit 635761d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Created by .ignore support plugin (hsz.mobi)
nvidia-xrun.iml
.idea
49 changes: 40 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
42 changes: 40 additions & 2 deletions nvidia-xinitrc
Original file line number Diff line number Diff line change
@@ -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
16 changes: 5 additions & 11 deletions nvidia-xrun
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<options>] <app>"
echo "nvidia-xrun [<options>] [<app>]"
echo "Options: "
echo " -d Dry run - prints the final command but does not execute it"
}
Expand All @@ -29,12 +29,6 @@ if [ "$1" == "-d" ]
shift 1
fi

if [ $# -eq 0 ]
then
printHelp
exit 1
fi

# calculate current VT
LVT=`fgconsole`

Expand Down Expand Up @@ -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 <<<OFF"
Expand Down

0 comments on commit 635761d

Please sign in to comment.