First, due to hardware differences, not all machines may be suitable for a setup with multiple monitors. This article tries to describe pointers to get started and tries to help troubleshooting specific issues with dual monitor setups on Optimus laptops. Your mileage may vary.
Optimus laptops have two video chips: an integrated Intel and a discrete nVidia one. If the port (DisplayPort / HDMI / VGA) is wired to the Intel chip, you do not need to do anything special to get external monitors to work.
When the port is wired into the nvidia chip, you cannot currently expand the screen over monitors. The monitor may still be used as extra screen (with no desktop running on it) or to run the full desktop on it (with no output on the Intel LVDS output, a.k.a. "the laptop display").
Check and see if you have the tool 'intel-virtual-output' installed. This is included in 'xf86-video-intel' =< v2.99, aprox date released is 22/Dec/2014
Running 'intel-virtual-output' without any extra parameters will daemonize itself and detect attached displays in the background. It will then perform all the trickery of virtualizing and cloning so that the newly attached screen can be used via conventinal screen management methods, such as cloning/extending with xrandr.
The tool itself can be run with a standard bumblebee installation, as it will switch bumblebee for access to the nvidia chipset. If no displays are attached, or you are using the laptop display only, the tool can be killed so that bumblebeed can then disable the nvidia chipset for powersaving.
To make it easier to kill 'intel-virtual-output' after running, start it in a console with the -f switch.
Usage: intel-virtual-output [OPTION]... [TARGET_DISPLAY]... -d <source display> source display -f keep in foreground (do not detach from console and daemonize) -b start bumblebee -a connect to all local displays (e.g. :1, :2, etc) -S disable use of a singleton and launch a fresh intel-virtual-output process -v all verbose output, implies -f -V <category> specific verbose output, implies -f -h this help If no target displays are parsed on the commandline, intel-virtual-output will attempt to connect to any local display and then start bumblebee.
Games can be run on the external display via "export DISPLAY=:8", however they will not grab the mouse or keyboard properly. You will also need to start games with "primusrun" or "optirun" as per usual.
Note: Screens should be attached before running the program.
In order to use an external monitor through the nvidia chip, power management
must be disabled for this. Edit
/etc/bumblebee/bumblebee.conf and change
(blob only) In
KeepUnusedXServer=true. Remove the
Option "AutoAddDevices" "false" lines in
Trigger a start of the X server with
Before running an application on the external monitor, adjust the library
path if necessary (or remove it for
nouveau) and run:
export DISPLAY=:8 LD_LIBRARY_PATH=/usr/lib/nvidia-current:$LD_LIBRARY_PATH
Then start your program at your choice (without optirun), it should show up on the external monitor. TODO
Because everything is rendered through the nvidia chip, the nvidia card must stay on (see above for disabling PM) and the OpenGL library path must be set to nvidia' libGL.so directory. Alternatively, uninstall Bumblebee as it does currently not fully support external monitors. If you want to keep bumblebee and have desktop on external monitor, you can do it killing bumblebee, setting your nvidia graphic card on (/proc/acpi/bbswitch), then you need to export your nvidia library export LD_LIBRARY_PATH=/usr/lib32/nvidia:/usr/lib/nvidia:$LD_LIBRARY_PATH on archlinux
Section "ServerLayout" Identifier "Layout0" EndSection Section "Device" Identifier "Device1" Driver "nvidia" VendorName "NVIDIA Corporation" Option "NoLogo" "true" Option "ConnectedMonitor" "DFP" EndSection #For the configuration with bumblebee installed #Section that follows come from archlinux adapt it from your distro if necessary. Section "Files" ModulePath "/usr/lib/nvidia/xorg/" ModulePath "/usr/lib/xorg/modules/" EndSection
DFP to something else if necessary (e.g.
CRT). For more details on
DFP/CRT, see https://github.com/Bumblebee-Project/Bumblebee/issues/21.
After creating the file, restart the X server or reboot. Note for novice
users: you may get a black screen which indicated failure, reboot into
recovery mode and remove configuration with
rm /etc/X11/xorg.conf. Check
/var/log/Xorg.0.log.old for details.
For a dual screen configuration (nvidia wired output + intel wired laptop screen)
adapted from this http://download.nvidia.com/XFree86/Linux-x86/319.32/README/randr14.html
and what is written above you can have a dual screen rendered by your nvidia card
with the nvidia proprietary driver.You need nvidia driver >= 319.2. If you keep bumblebee
installed and you have a recent version of the intel driver you do not need the modesetting
driver. You can use this alternate
xorg.conf (adapt it if needed) and follow the steps given
before. Additionnaly you need to run
xrandr --setprovideroutputsource Intel NVIDIA-0 to enable your laptop screen.
Section "ServerLayout" Identifier "layout" Screen 0 "nvidia" Inactive "intel" EndSection Section "Device" Identifier "nvidia" Driver "nvidia" BusID "PCI:1:0:0" EndSection Section "Screen" Identifier "nvidia" Device "nvidia" # Uncomment this line if your computer has no display devices connected to # the NVIDIA GPU. Leave it commented if you have display devices # connected to the NVIDIA GPU that you would like to use. # Option "UseDisplayDevice" "none" EndSection Section "Device" Identifier "intel" Driver "intel" Option "AccelMethod" "uxa" EndSection Section "Screen" Identifier "intel" Device "intel" EndSection Section "Files" ModulePath "/usr/lib/nvidia/xorg/" ModulePath "/usr/lib/xorg/modules/" EndSection
If you can't get it to work with the two above methods you might try the following:
0) sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf_bak
1) Do as described above: In /etc/bumblebee/bumblebee.conf, change KeepUnusedXServer=false to KeepUnusedXServer=true. Remove the UseEDID and Option "AutoAddDevices" "false" lines in /etc/bumblebee/xorg.conf.nvidia. (possibly also "Edit /etc/bumblebee/bumblebee.conf and change PmMethod=auto to PmMethod=none (twice)." though it seems to work without it.)
2) when you start your laptop: BEFORE logging in switch to tty1(press CTRL+ALT+F1, login in there and do the following
a) sudo service lightdm stop
b) export DISPLAY=:8.0
c) optirun wmii& (or other like startlxde)
Now you should have a session showing up on your external monitor. TODO: whatever you type will be shown and executed on tty1. to prevent that you can logout (CTRL+d) and switch to tty7 (ALT+F7), but this is an ugly workaround.
ALTERNATIVELY you can try with two sessions sharing the mouse pointer as described here: http://www.webupd8.org/2012/08/get-hdmi-working-with-nvidia-optimus-on.html (This worked in combination with step 1) from here).
These instructions will help you set up your laptop so that you are using up to three screens (one/two external and the attached laptop screen), and will still allow you to make use of the power saving features when the external screens are not in use. This has only been tested with the proprietary NVidia drivers.
This tutorial assumes that you have an external keyboard and mouse available.
NOTE: Even though all three screens are in use, you will not be able to move windows between the screens.
If possible, before installing bumblebee, install nvidia-current (without bumblebee) and get an xorg.conf file that has your external screen(s) working how you want them. Save this xorg.conf file somewhere you can get to it later. If you can't do this for some reason, try following the instructions in the 'Desktop on external monitor' section of this page to create an xorg.conf file.
Follow the appropriate instructions to install bumblebee depending on your distro.
Once installed, reboot your computer. You should see output on your internal
laptop screen only. Open
/etc/bumblebee/bumblebee.conf as root with your favorite editor.
VirtualDisplay. At this writing, it defaults to
Driveris set to
XorgConfFileto point to the xorg.conf file you created earlier.
At this point, you need to figure out which devices are your external keyboard and mouse and which devices are your internal keyboard and internal trackpad/trackpoint. The reason this is necessary is because if you don't separate the input devices for the different X sessions, your mouse and keyboard will control both simultaneously.
xinput --list in a terminal. You should see something like this:
⎡ Virtual core pointer id=2 [master pointer (3)] ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)] ⎜ ↳ USB Optical Mouse id=12 [slave pointer (2)] ⎜ ↳ AlpsPS/2 ALPS DualPoint TouchPad id=15 [slave pointer (2)] ⎜ ↳ DualPoint Stick id=14 [slave pointer (2)] ⎣ Virtual core keyboard id=3 [master keyboard (2)] ↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] ↳ Power Button id=6 [slave keyboard (3)] ↳ Video Bus id=7 [slave keyboard (3)] ↳ Video Bus id=8 [slave keyboard (3)] ↳ Power Button id=9 [slave keyboard (3)] ↳ Sleep Button id=10 [slave keyboard (3)] ↳ Dell Dell USB Keyboard id=11 [slave keyboard (3)] ↳ Dell WMI hotkeys id=16 [slave keyboard (3)] ↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
In this example:
Now that you (hopefully) know the names of your input devices, copy this script and paste it into a text editor:
#! /bin/bash # Starts a separate X session using Optimus # and uses separate input devices for each # must be run as root, with 'optirun' if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi # First, disable external inputs on internal screen's X server # Replace these with the names of your EXTERNAL input devices. xinput disable "USB Optical Mouse" xinput disable "Dell Dell USB Keyboard" # Save current DISPLAY variable so we can use it later ORIGDISPLAY=$DISPLAY # Set display ID to the external screen's X server DISPLAY=':8' #<-- This should be the value of 'VirtualDisplay' from earlier. # Disable internal inputs # Replace these with the names of your INTERNAL input devices xinput disable "AT Translated Set 2 keyboard" xinput disable "DualPoint Stick" # Start another session. This example is for XFCE or Xubuntu, look up the appropriate # command for your desktop environment of choice and replace 'xfce4-session'. # Remember to replace USERNAME with your username. su -c xfce4-session USERNAME > /dev/null 2>&1 # (this script pauses here until the new session ends) # Switch back to the internal screen's X server DISPLAY=$ORIGDISPLAY # Re-enable external inputs on the internal screen's X server xinput enable "USB Optical Mouse" xinput enable "Dell Dell USB Keyboard"
You MUST edit this and change settings where appropriate. Double and triple check it to make sure you changed everything! Save it as something like 'OptimusStart.sh' and make it executable (chmod +x OptimusStart.sh).
Now, when you run the script AS ROOT, WITH OPTIRUN, you should have all three screens going.
sudo optirun ./OptimusStart.sh
If the OptimusStart.sh script exits without doing anything, double check that you replaced USERNAME with a valid user.
If you keep getting this error message when you launch programs in a terminal in the new X session:
ERROR: ld.so: object 'libdlfaker.so' from LD_PRELOAD cannot be preloaded: ignored.
You can fix it by following one of the two steps outlined here: http://www.virtualgl.org/vgldoc/2_1/#hd0010
Option "CustomEDID" "DFP-0: /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid"
find /sys/devices/ -iname edid