You are not logged in.

#1 2014-05-02 18:47:47

duckie
Member
Registered: 2013-11-20
Posts: 4

Use your optimus nvidia graphic card at maximum power

Hello guys

I have a laptop with the Optimus technology in it. Optimus is supported in two different ways : using Bumblebee, wich allows to switch on and off the nvidia graphic card live. The Optimus technology is also supported by the nvidia driver as explained here. The drawback is that you cannot switch the card on and off at runtime, thus causing extra heat, extra power consumption, and therefore a decrease of comfort and lifetime of the battery (and maybe the overall laptop). Why use the official driver then ? I figured out two reasons :

  • Games work pretty well when using the "direct" driver, particularly source games via Steam (Portal 2 for instance, which doest not run at all with bumblebee on my machine, though it is officially supported by Steam). Windows games on Wine work well too in this case, and often not at all with Bumblebee.

  • Performances are better thanks to the use of an optimized libgl.

I would like to use both configurations : the official driver when gaming and the low consumption one for other uses. The problem is : the two bastards conflict regarding package dependencies. So I wrote a script to help me switch between them. It needs a reboot, but I dont care since my machine is booting/rebooting really fast thanks to the SSD.

It is not generic enough to be pushed in AUR, in my opinion, but In case it might serve you, here is the script. It needs to be read and understood before use, since a little previous configuration is needed (in short, a /etc/X11/xorg.conf.nvidia file, the yes program installed and a proper .xinitrc for the gaming config, in my case starting xfce with the righ xrandr calls).

#!/usr/bin/env bash

config=$1

BUMBLEBEE_SERVICE="bumblebeed.service"
WM_SERVICE="gdm"
XORG_CONF="/etc/X11/xorg.conf"
BULK_SUDO="sudo /usr/bin/env bash -c"


# Force lang to make "yes" portable
export LANG=C 

function run() {
  # Rebuilds properly the command line for display
  cmd=""
  for arg in "$@"; do
    case "${var}" in
      *\ * ):
        cmd="${cmd} \"${arg}\""
        ;;
      *)
        cmd="${cmd} ${arg}"
        ;;
      esac
  done
  
  echo "Running:" ${cmd}
  "$@" > /dev/null
  ret=$?
  if [ "$?" != "0" ]; then
    echo "Command failed."
    exit $ret
  fi
}

function uninstall_if_installed() {
  to_uninstall=""
  for pkg in "$@"; do
    pacman -Q ${pkg} 2>1 > /dev/null
    if [ "$?" == "0" ]; then
     to_uninstall="${to_uninstall} ${pkg}"
    else
      echo "${pkg} is already uninstalled."
    fi
  done
  if [[ "${to_uninstall}" != "" ]]; then
    run sudo /usr/bin/env bash -c "yes|pacman -R ${to_uninstall}"
  fi
}

function load_play() {
  run sudo systemctl stop ${BUMBLEBEE_SERVICE}
  run sudo systemctl disable ${BUMBLEBEE_SERVICE}
  run sudo systemctl disable ${WM_SERVICE}
  uninstall_if_installed intel-dri lib32-intel-dri xf86-video-intel primus lib32-primus glamor-egl
  run ${BULK_SUDO} "yes|pacman -S nvidia-libgl lib32-nvidia-libgl" 
  if [[ ! -f "${XORG_CONF}" ]]; then
    run sudo ln -s /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
  fi
}

function load_normal() {
  run ${BULK_SUDO} "yes|sudo pacman -S mesa-libgl lib32-mesa-libgl intel-dri lib32-intel-dri xf86-video-intel bumblebee primus lib32-primus"
  run sudo systemctl enable ${BUMBLEBEE_SERVICE}
  run sudo systemctl enable ${WM_SERVICE}
  run sudo usermod ${USER} -a -G bumblebee
  if [ -h "${XORG_CONF}" ]; then
    run sudo rm /etc/X11/xorg.conf
  fi
}

"load_${config}"

Offline

Board footer

Powered by FluxBB