/usr/lib/ubiquity/plugins/myth-drivers.py is in mythbuntu-live-autostart 0.69.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | # -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Copyright (C) 2006, 2007, 2009 Canonical Ltd.
# Written by Colin Watson <cjwatson@ubuntu.com>.
# Copyright (C) 2007-2010 Mario Limonciello
#
# This file is part of Ubiquity.
#
# Ubiquity is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Ubiquity is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ubiquity. If not, see <http://www.gnu.org/licenses/>.
from ubiquity.plugin import *
from ubiquity import misc
from mythbuntu_common.dictionaries import get_graphics_dictionary
from mythbuntu_common.installer import *
from ubiquity import install_misc
import xkit.xutils
import os
NAME = 'myth-drivers'
AFTER = 'myth-remote'
WEIGHT = 10
class PageGtk(MythPageGtk):
plugin_title = 'ubiquity/text/driver_heading_label'
def __init__(self, controller, *args, **kwargs):
with misc.raised_privileges():
self.drivers = get_graphics_dictionary()
if len(self.drivers) > 0:
self.ui_file = 'mythbuntu_stepDrivers'
MythPageGtk.__init__(self, controller, *args, **kwargs)
self.populate_video()
def populate_video(self):
"""Finds the currently active video driver"""
if len(self.drivers) > 0:
driver_model = self.video_driver.get_model()
for driver in self.drivers:
driver_model.append([driver])
driver_model.append(["Open Source Driver"])
self.video_driver.set_active(len(self.drivers))
self.tvoutstandard.set_active(0)
self.tvouttype.set_active(0)
def toggle_tv_out (self,widget):
"""Called when the tv-out type is toggled"""
if (self.tvouttype.get_active() == 0):
self.tvoutstandard.set_active(0)
elif ((self.tvouttype.get_active() == 1 or self.tvouttype.get_active() == 2) and (self.tvoutstandard.get_active() == 0 or self.tvoutstandard.get_active() >= 11 )):
self.tvoutstandard.set_active(10)
elif self.tvouttype.get_active() == 3:
self.tvoutstandard.set_active(11)
def toggle_tv_standard(self,widget):
"""Called when the tv standard is toggled"""
if (self.tvoutstandard.get_active() >= 11):
self.tvouttype.set_active(3)
elif (self.tvoutstandard.get_active() < 11 and self.tvoutstandard.get_active() > 0 and self.tvouttype.get_active() == 0):
self.tvouttype.set_active(1)
elif (self.tvoutstandard.get_active() < 11 and self.tvouttype.get_active() ==3):
self.tvouttype.set_active(1)
elif (self.tvoutstandard.get_active() == 0):
self.tvouttype.set_active(0)
def video_changed (self,widget):
"""Called whenever the modify video driver option is toggled or its kids"""
if (widget is not None and widget.get_name() == 'video_driver'):
self.controller.allow_go_forward(True)
type = widget.get_active()
if (type < len(self.drivers)):
self.tvout_vbox.set_sensitive(True)
else:
self.tvout_vbox.set_sensitive(False)
self.tvoutstandard.set_active(0)
self.tvouttype.set_active(0)
def set_driver(self,name,value):
"""Preseeds the status of a driver"""
lists = [{'video_driver': self.video_driver,
'tvout': self.tvouttype,
'tvstandard': self.tvoutstandard}]
preseed_list(lists,name,value)
def get_drivers(self):
model = self.video_driver.get_model()
iterator = self.video_driver.get_active_iter()
active_video_driver = model.get_value(iterator, 0)
for item in self.drivers:
if (active_video_driver == item):
active_video_driver=self.drivers[item]
break
return build_static_list([{'video_driver': active_video_driver,
'tvout': self.tvouttype,
'tvstandard': self.tvoutstandard}])
class Page(Plugin):
def prepare(self):
#drivers
drivers = self.ui.get_drivers()
questions = []
for this_driver in drivers:
answer = self.db.get('mythbuntu/' + this_driver)
if answer != '':
self.ui.set_driver(this_driver,answer)
questions.append('^mythbuntu/' + this_driver)
return (['/usr/share/ubiquity/ask-mythbuntu','drivers'], questions)
def ok_handler(self):
drivers = self.ui.get_drivers()
for this_driver in drivers:
if drivers[this_driver] is True or drivers[this_driver] is False:
self.preseed_bool('mythbuntu/' + this_driver, drivers[this_driver])
else:
self.preseed('mythbuntu/' + this_driver, drivers[this_driver])
Plugin.ok_handler(self)
class Install(InstallPlugin):
def enable_nvidia(self, type, fmt):
"""Enables an NVIDIA graphics driver using xkit"""
xorg_conf=xkit.xutils.XUtils()
extra_conf_options={'NoLogo': '1',
'DPI': '100x100'}
if type == 'Composite Video Output':
extra_conf_options["ConnectedMonitor"]="TV"
extra_conf_options["TVOutFormat"]="COMPOSITE"
extra_conf_options["TVStandard"]=fmt
elif type == 'S-Video Video Output':
extra_conf_options["ConnectedMonitor"]="TV"
extra_conf_options["TVOutFormat"]="SVIDEO"
extra_conf_options["TVStandard"]=fmt
elif type == 'Component Video Output':
extra_conf_options["ConnectedMonitor"]="TV"
extra_conf_options["TVOutFormat"]="COMPONENT"
extra_conf_options["TVStandard"]=fmt
#Set up extension section
extensions = xorg_conf.make_section('Extensions')
xorg_conf.add_option('Extensions', 'Composite', 'Disable', option_type='Option', position=extensions)
#Set up device section
relevant_devices = []
if len(xorg_conf.globaldict['Device']) == 0:
device = xorg_conf.make_section('Device', identifier='Default Device')
relevant_devices.append(device)
xorg_conf.set_driver('Device', 'nvidia', device)
else:
devices = xorg_conf.get_devices_in_use()
if len(devices) > 0:
relevant_devices = devices
else:
relevant_devices = list(xorg_conf.globaldict['Device'].keys())
for device in relevant_devices:
xorg_conf.set_driver('Device', 'nvidia', device)
for device_section in relevant_devices:
for k, v in extra_conf_options.items():
xorg_conf.add_option('Device', k, v, option_type='Option', position=device_section)
#Set up screen section
if len(xorg_conf.globaldict['Screen']) == 0:
screen = xorg_conf.make_section('Screen', identifier='Default Screen')
xorg_conf.add_option('Screen', 'DefaultDepth', '24', position=0, prefix='')
xorg_conf.write(self.target + "/etc/X11/xorg.conf")
def enable_amd(self):
"""Enables an AMD graphics driver using xkit"""
xorg_conf=xkit.xutils.XUtils()
#Set up device section
relevant_devices = []
if len(xorg_conf.globaldict['Device']) == 0:
device = xorg_conf.make_section('Device', identifier='Default Device')
relevant_devices.append(device)
xorg_conf.set_driver('Device', 'fglrx', device)
else:
devices = xorg_conf.get_devices_in_use()
if len(devices) > 0:
relevant_devices = devices
else:
relevant_devices = list(xorg_conf.globaldict['Device'].keys())
for device in relevant_devices:
xorg_conf.set_driver('Device', 'fglrx', device)
#Set up screen section
if len(xorg_conf.globaldict['Screen']) == 0:
screen = xorg_conf.make_section('Screen', identifier='Default Screen')
xorg_conf.add_option('Screen', 'DefaultDepth', '24', position=0, prefix='')
xorg_conf.write(self.target + "/etc/X11/xorg.conf")
def install(self, target, progress, *args, **kwargs):
progress.info('ubiquity/install/drivers')
self.target = target
to_install = []
video_driver = progress.get('mythbuntu/video_driver')
if video_driver != "Open Source Driver":
#Install driver
to_install.append(video_driver)
#Build tvout/tvstandard
out = progress.get('mythbuntu/tvout')
standard = progress.get('mythbuntu/tvstandard')
#Enabling xorg.conf stuff
if 'nvidia' in video_driver:
self.enable_nvidia(out,standard)
else:
self.enable_amd()
#Mark new items
install_misc.record_installed(to_install)
return InstallPlugin.install(self, target, progress, *args, **kwargs)
|