External monitor not working Nvidia Optimus

I am having a Optimus machine with Intel/Nvidia graphics card:

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 650M Mac Edition] (rev a1)

And my xrandr can detect the external monitor and its resolutions.