Adaptation to using PRIME

For reasons nvidia-xrun doesn't work anymore.
There was an update breaking a lot of things apparently,
but downgrading didn't help so 🤷‍♂️.
Didn't add all the X11 config because might be temporary though.
This commit is contained in:
Geoffrey Frogeye 2022-01-09 19:36:33 +01:00
parent 1ba2a75749
commit e2cddff4c4
3 changed files with 90 additions and 4 deletions

View file

@ -15,10 +15,13 @@ extensions:
- g
- gh
x11_screens:
# nvidia
# nvidia-xrun
# - HDMI-0
# - eDP-1-1
# nouveau
- HDMI-1-3
# mesa + nouveau
# - HDMI-1-3
# - eDP1
# mesa + nvidia
- HDMI-1-0
- eDP1
max_video_height: 1440

View file

@ -1,5 +1,5 @@
Section "Device"
Identifier "Intel Graphics"
Identifier "intel"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection

83
config/scripts/nv Executable file
View file

@ -0,0 +1,83 @@
#!/usr/bin/env bash
# Extracted frm nvidia-xrun
DRY_RUN=0
function execute {
if [[ ${DRY_RUN} -eq 1 ]]
then
echo ">>Dry run. Command: $*"
else
eval $*
fi
}
function turn_off_gpu {
if [[ "$REMOVE_DEVICE" == '1' ]]; then
echo 'Removing Nvidia bus from the kernel'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/remove <<<1"
else
echo 'Enabling powersave for the graphic card'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<auto"
fi
echo 'Enabling powersave for the PCIe controller'
execute "sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<auto"
}
function turn_on_gpu {
echo 'Turning the PCIe controller on to allow card rescan'
execute "sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<on"
echo 'Waiting 1 second'
execute "sleep 1"
if [[ ! -d /sys/bus/pci/devices/${DEVICE_BUS_ID} ]]; then
echo 'Rescanning PCI devices'
execute "sudo tee /sys/bus/pci/rescan <<<1"
echo "Waiting ${BUS_RESCAN_WAIT_SEC} second for rescan"
execute "sleep ${BUS_RESCAN_WAIT_SEC}"
fi
echo 'Turning the card on'
execute "sudo tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<on"
}
function load_modules {
for module in "${MODULES_LOAD[@]}"
do
echo "Loading module ${module}"
execute "sudo modprobe ${module}"
done
}
function unload_modules {
for module in "${MODULES_UNLOAD[@]}"
do
echo "Unloading module ${module}"
execute "sudo modprobe -r ${module}"
done
}
if [[ "$1" == "-d" ]]
then
DRY_RUN=1
shift 1
fi
# load config file
. /etc/default/nvidia-xrun
if [ "$1" == "on" ]
then
turn_on_gpu
load_modules
elif [ "$1" == "off" ]
then
unload_modules
turn_off_gpu
else
echo "Usage: $0 [on|off]"
fi