~droetker/ubuntu/saucy/bumblebee/fix-for-1250745

« back to all changes in this revision

Viewing changes to debian/bumblebee.bumblebeed.upstart

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-05-03 03:04:38 UTC
  • Revision ID: package-import@ubuntu.com-20130503030438-uvmvja55iicztpxf
Tags: upstream-3.2.1
ImportĀ upstreamĀ versionĀ 3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Upstart job for Bumblebee daemon
 
2
 
 
3
description "Bumblebee supporting nVidia Optimus cards"
 
4
author      "Lekensteyn <lekensteyn@gmail.com>"
 
5
 
 
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)
 
9
 
 
10
# restart in case it crashed for some reason
 
11
respawn
 
12
 
 
13
script
 
14
        libopts=
 
15
 
 
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
 
23
 
 
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
 
27
 
 
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"
 
39
                fi
 
40
        fi
 
41
 
 
42
        # don't use --daemon as Upstart gets confused by that.
 
43
        exec '/usr/sbin/bumblebeed' --use-syslog $libopts
 
44
end script