Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Linux NVidia Optimus with external monitor - enable/disable scripts tested on Ubuntu. Source article:
set /augeas/load/PHP/incl[last()] /etc/bumblebee/bumblebee.conf
set /augeas/load/Xorg/incl[last()] /etc/bumblebee/xorg.conf.nvidia
set /files/etc/bumblebee/bumblebee.conf/bumblebeed/KeepUnusedXServer false
set /files/etc/bumblebee/bumblebee.conf/driver-nvidia/PMMethod auto
set /files/etc/bumblebee/bumblebee.conf/driver-nouveau/PMMethod auto
set /files/etc/bumblebee/xorg.conf.nvidia/ServerLayout/Option[last() + 1] "AutoAddDevices"
set /files/etc/bumblebee/xorg.conf.nvidia/ServerLayout/Option[last()]/value "false"
set /files/etc/bumblebee/xorg.conf.nvidia/ServerLayout/Option[last() + 1] "AutoAddGPU"
set /files/etc/bumblebee/xorg.conf.nvidia/ServerLayout/Option[last()]/value "false"
set /files/etc/bumblebee/xorg.conf.nvidia/Device/Option[last() + 1] "UseEDID"
set /files/etc/bumblebee/xorg.conf.nvidia/Device/Option[last()]/value "false"
set /files/etc/bumblebee/xorg.conf.nvidia/Device/Option[last() + 1] "UseDisplayDevice"
set /files/etc/bumblebee/xorg.conf.nvidia/Device/Option[last()]/value "none"
set /augeas/load/PHP/incl[last()] /etc/bumblebee/bumblebee.conf
set /augeas/load/Xorg/incl[last()] /etc/bumblebee/xorg.conf.nvidia
set /files/etc/bumblebee/bumblebee.conf/bumblebeed/KeepUnusedXServer true
set /files/etc/bumblebee/bumblebee.conf/driver-nvidia/PMMethod none
set /files/etc/bumblebee/bumblebee.conf/driver-nouveau/PMMethod none
rm /files/etc/bumblebee/xorg.conf.nvidia/ServerLayout/Option[. = "AutoAddDevices"]
rm /files/etc/bumblebee/xorg.conf.nvidia/ServerLayout/Option[. = "AutoAddGPU"]
rm /files/etc/bumblebee/xorg.conf.nvidia/Device/Option[. = "UseDisplayDevice"]
rm /files/etc/bumblebee/xorg.conf.nvidia/Device/Option[. = "UseEDID"]
# You will need latest NVIDIA drivers installed. At the time of writing, version is 331.20.
# On ubuntu 13.10, it looks like this:
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get install nvidia-331
# Now we need to install bumblebee:
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get install bumblebee bumblebee-nvidia bbswitch-dkms
# Reboot
# Intel-virtual-output tool
# First, you will need latest xf86-video-intel driver installed (2.99). Ubuntu 13.10 comes with it,
# so you don’t need to update driver in that case. However, what made all of this possible is the
# latest release of intel-virtual-output tool, which comes bundled with xf86-video-intel driver
# source. But, ubuntu’s package does not bundle it, and we need to compile it from source. One
# MAJOR thing to note here is: DO NOT compile it from ubuntu’s deb-src package. That package is old,
# and current release has some major fixes for the tool that we will actually need in order to have
# everything working properly. So lets do it:
sudo apt-get install xorg-dev git autoconf automake libtool
cd /usr/src
git clone git://
cd xf86-video-intel
cd tools
sudo cp intel-virtual-output /usr/bin/
sudo chmod +x /usr/bin/intel-virtual-output
# Install scripts listed in this Gist and augtool:
sudo vim /usr/local/bin/nvidia-enable
sudo chmod +x /usr/local/bin/nvidia-enable
sudo vim /usr/local/bin/nvidia-disable
sudo chmod +x /usr/local/bin/nvidia-disable
sudo mkdir -p /etc/bumblebee/dual-monitor
sudo vim /etc/bumblebee/dual-monitor/enable.aug
sudo vim /etc/bumblebee/dual-monitor/disable.aug
sudo apt-get install augeas-tools
# Done, now enable external monitors with: `nvidia-enable` and disable with `nvidia-enable` command
PID=$(ps ax | grep Xorg | grep :8 | grep -v grep | awk '{print $1}')
# Kill the second X server.
if [ ! -z $PID ]; then
sudo kill -15 $PID
# Now you need to turn off nvidia card completely.
if lsmod | grep -q nvidia; then
sudo rmmod nvidia
sudo tee /proc/acpi/bbswitch <<<OFF
sudo augtool --noload --file /etc/bumblebee/dual-monitor/disable.aug
sudo service bumblebeed restart
sudo augtool --noload --file /etc/bumblebee/dual-monitor/enable.aug
sudo modprobe bbswitch
optirun true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.