1
# Upstart job for Bumblebee daemon
3
description "Bumblebee supporting nVidia Optimus cards"
4
author "Lekensteyn <lekensteyn@gmail.com>"
6
# XXX: do we need to stop before / after a graphical DE like kdm?
7
start on (login-session-start or desktop-session-start)
8
stop on (desktop-shutdown)
10
# restart in case it crashed for some reason
16
# When the user installs a nvidia package that is unknown,
17
# ignore the paths in bumblebee.conf and use detected ones
18
if ! driver=$(grep -Po '^Driver=\K.*' /etc/bumblebee/bumblebee.conf) \
19
|| [ -z "$driver" ] || [ "$driver" = "nvidia" ]; then
20
# find LibraryPath setting of nvidia section
21
libpath=$(awk -F[=:] '/^\[driver-nvidia\]/{d=1}/^LibraryPath=/{if(d){print $2;exit}}' \
22
/etc/bumblebee/bumblebee.conf) || true
24
# pick the first available nvidia installation (not necessary
25
# the latest, e.g. nvidia-current over nvidia-experimental-310)
26
pkgname=$(ls -1d /usr/lib/nvidia*/libGL.so | cut -d/ -f4 | head -1) || true
28
# When the default library path does not contain nvidia drivers,
29
# it is possibly not installed. If no driver is installed (no
30
# /usr/lib/nvidia-*), assume that the auto-detection will use
31
# nouveau instead and do not override paths.
32
if [ ! -e "$libpath/libGL.so" -a -n "$pkgname" ] && \
33
modprobe -nq "$pkgname"; then
34
# assume nvidia driver even if nouveau is already loaded
35
libopts="$libopts --driver nvidia"
36
libopts="$libopts --driver-module $pkgname"
37
libopts="$libopts --ldpath /usr/lib/$pkgname:/usr/lib32/$pkgname"
38
libopts="$libopts --module-path /usr/lib/$pkgname/xorg,/usr/lib/xorg/modules"
42
# don't use --daemon as Upstart gets confused by that.
43
exec '/usr/sbin/bumblebeed' --use-syslog $libopts