Пример #1
0
	def set(self):

		'''Trigger all environment checks'''

		# Check for Intel and export INTEL_BATCH
		if 'Intel' in self.glxinfo:
			print(' * Intel detected, exporting: INTEL_BATCH=1')
			os.environ['INTEL_BATCH'] = '1'

		# Check TFP and export LIBGL_ALWAYS_INDIRECT if needed
		if self.tfp != 'direct':
			print(' * No ' + tfp + ' with direct rendering context')
			if self.tfp == 'indirect':
				print(' ... present with indirect rendering, exporting: LIBGL_ALWAYS_INDIRECT=1')
				os.environ['LIBGL_ALWAYS_INDIRECT'] = '1'
			else:
				# If using Xgl with a proprietary driver, exports LD_PRELOAD=<mesa libGL>
				if self.Xgl and self.glx_vendor != 'SGI':
					print(' * Non-mesa driver on Xgl detected')
					from data import mesa_libgl_locations
					location = [l for l in mesa_libgl_locations if os.path.exists(l)]
					if location:
						print(' ... exporting: LD_PRELOAD=' + location[0])
						os.environ['LD_PRELOAD'] = location[0]
						if run(['glxinfo'], 'output').count(tfp) >= 3:
							self.tfp = 'direct'

					else:
						# kindly let the user know... but don't abort (maybe it will work :> )
						print(' ... no mesa libGL found for preloading, this may not work!')
				else:
					print(' ... nor with indirect rendering, this isn\'t going to work!')

		# Check for nvidia on Xorg
		if not self.Xgl and self.glx_vendor == 'NVIDIA Corporation':
			print(' * NVIDIA on Xorg detected, exporting: __GL_YIELD=NOTHING')
			os.environ['__GL_YIELD'] = 'NOTHING'
Пример #2
0
	def __init__(self):

		'''desktop: current desktop enviroment used to choose interface, fallback wm, and default decorator

glxinfo: output of glxinfo command

indirect_glxinfo: output of glxinfo with LIBGL_ALWAYS_INDIRECT

xvinfo: output of xvinfo

glx_vendor: 'client glx vendor:' usually one of SGI (for mesa-based drivers), NVIDIA Corporation, or ATI.

tfp: 'direct' if texture_from_pixmap is present with direct rendering (implying presence with indirect as well), 'indirect' if only present with indirect context, False if not present at all

Xgl: True in Xgl'''

		# Check for various desktop environments
		if os.getenv('XDG_CURRENT_DESKTOP') == 'MATE' or os.getenv('MATE_DESKTOP_SESSION_ID') is not None:
			self.desktop = 'mate'
		elif os.getenv('XDG_CURRENT_DESKTOP') == 'XFCE' or os.getenv('DESKTOP_SESSION') in ('xfce', 'xfce4', 'Xfce Session'):
			self.desktop = 'xfce'
		elif os.getenv('XDG_CURRENT_DESKTOP', '').endswith('GNOME') or os.getenv('GNOME_DESKTOP_SESSION_ID') is not None:
			self.desktop = 'gnome'
		elif os.getenv('XDG_CURRENT_DESKTOP') == 'KDE' or os.getenv('KDE_FULL_SESSION') is not None:
			self.desktop = 'kde'
		elif os.getenv('XDG_CURRENT_DESKTOP') == 'LXQt':
			self.desktop = 'lxqt'
		elif os.getenv("XDG_CURRENT_DESKTOP") is not None:
			self.desktop = os.getenv('XDG_CURRENT_DESKTOP', 'unknown').lower()
		else:
			self.desktop = os.getenv('DESKTOP_SESSION', 'unknown').lower()

		print(' * Detected Session: ' + self.desktop)


		## Save the output of glxinfo and xvinfo for later use:

		# don't try to run glxinfo unless it's installed
		if run(['which', 'glxinfo'], 'call', quiet=True) == 0:
			self.glxinfo = run('glxinfo', 'output')
		else:
			raise SystemExit(' * Error: glxinfo not installed!')

		# make a temp environment
		indirect_environ = os.environ.copy()
		indirect_environ['LIBGL_ALWAYS_INDIRECT'] = '1'
		self.indirect_glxinfo = run('glxinfo', 'output', env=indirect_environ)

		if run(['which', 'xvinfo'], 'call', quiet=True) == 0:
			self.xvinfo = run('xvinfo', 'output')
		else:
			raise SystemExit(' * Error: xvinfo not installed!')

		self.glx_vendor = None
		line = [l for l in self.glxinfo.splitlines() if 'client glx vendor string:' in l]
		if line:
			self.glx_vendor = ' '.join(line[0].split()[4:])

		## Texture From Pixmap / Indirect
		self.tfp = False
		if self.glxinfo.count(tfp) < 3:
			if self.indirect_glxinfo.count(tfp) == 3:
				self.tfp = 'indirect'
		else:
			self.tfp = 'direct'

		## Xgl
		if 'Xgl' in self.xvinfo:
			self.Xgl = True

		else:
			self.Xgl = False
Пример #3
0
 def launch(self):
     print(' * Launching ' + self.label)
     run(self.command)
Пример #4
0
    def __init__(self, data):
        print(' * Searching for installed applications...')

        ### Compiz Detection
        bins = {}
        for name in ('compiz', 'compiz.real'):
            bin = run(['which', name], 'output')
            if bin:
                bins[name] = bin

        if 'compiz' in bins and 'compiz.real' in bins:
            if bins['compiz'].split(os.sep)[:-1] == bins['compiz.real'].split(
                    os.sep)[:-1]:
                compiz = 'compiz.real'
            else:
                compiz = 'compiz'

        elif 'compiz.real' in bins:
            compiz = 'compiz.real'

        elif 'compiz' in bins:
            compiz = 'compiz'

        else:
            compiz = None

        output = ''

        for name in bins:
            if len(bins) > 1 and name == compiz:
                selected = ' <*>'
            else:
                selected = ''
            output += ' -- ' + bins[name] + selected

        ### Everything Else
        self.wms = data.wms.copy()
        for wm in data.wms:
            which = run(['which', data.wms[wm][0]], 'output')
            if which:
                output += ' -- ' + which
            else:
                del self.wms[wm]

        if compiz:
            data.compiz_args.insert(0, compiz)
            self.wms['compiz'] = (compiz, data.compiz_args, 'Compiz', None,
                                  None, None)

        self.decorators = data.decorators.copy()
        for decorator in data.decorators:
            which = run(['which', data.decorators[decorator][0]], 'output')
            if which:
                output += ' -- ' + which
            else:
                del self.decorators[decorator]

        self.apps = data.apps.copy()
        for app in data.apps:
            which = run(['which', data.apps[app][0]], 'output')
            if which:
                output += ' -- ' + which
            else:
                del self.apps[app]

        if parser_options.verbose:
            print(output.rstrip())

        compiz_optionlist = []

        self.options = data.options.copy()

        if compiz:
            compiz_help = run([compiz, '--help'], 'output')
            for item in compiz_help.split():
                item = item[1:].strip(" \r\n\t]")
                if item.startswith('--'):
                    compiz_optionlist.append(item)

        for option in data.options:
            if data.options[option][1] not in compiz_optionlist:
                del self.options[option]
Пример #5
0
def is_running(app):
    'Use pgrep to determine if an app is running'

    if run(['pgrep', app], 'call', quiet=True) == 0:
        return True
Пример #6
0
    def start(self):
        'Start the active window manager'

        self.__set_old()

        if self.active == 'compiz' and self.old and self[self.old].killcmd:
            if run(['which', self[self.old].killcmd[0]], 'call',
                   quiet=True) == 0:
                run(self[self.old].killcmd, 'call')
                time.sleep(1)

        if self.active and self.old and 'noreplace' in self[self.active].flags:
            run(['killall', self[self.old].base], 'call')
            time.sleep(1)

        if self.active == 'compiz':
            # use a copy, not the original
            compiz_command = self['compiz'].command[:]
            for option in options:
                if options[option].enabled:
                    if options[option].switch is not None:
                        compiz_command.append(options[option].switch)

            kill_list = ['killall']
            for decorator in decorators:
                kill_list.append(decorators[decorator].base)
            run(kill_list, 'call')

            time.sleep(0.5)

            # do it
            print(' ... executing: ' + ' '.join(compiz_command))
            run(compiz_command, quiet=False)

        elif self.active:
            run(self[self.active].command)

        else:
            print(' * No active WM set; not going to do anything.')
Пример #7
0
 def kill_others(self):
     killall = ['killall']
     for decorator in [x for x in self.decorators if x != self.name]:
         killall.append(self.decorators[decorator].base)
     run(killall, 'call')
Пример #8
0
	def launch(self):
		print(' * Launching ' + self.label)
		run(self.command)
Пример #9
0
def is_running(app):
	'Use pgrep to determine if an app is running'

	if run(['pgrep', app], 'call', quiet=True) == 0:
		return True
Пример #10
0
	def __init__(self, data):
		print(' * Searching for installed applications...')

		### Compiz Detection
		bins = {}
		for name in ('compiz', 'compiz.real'):
			bin = run(['which', name], 'output')
			if bin:
				bins[name] = bin

		if 'compiz' in bins and 'compiz.real' in bins:
			if bins['compiz'].split(os.sep)[:-1] == bins['compiz.real'].split(os.sep)[:-1]:
				compiz = 'compiz.real'
			else:
				compiz = 'compiz'

		elif 'compiz.real' in bins:
			compiz = 'compiz.real'

		elif 'compiz' in bins:
			compiz = 'compiz'

		else:
			compiz = None

		output = ''

		for name in bins:
			if len(bins) > 1 and name == compiz:
				selected = ' <*>'
			else:
				selected = ''
			output += ' -- ' + bins[name] + selected

		### Everything Else
		self.wms = data.wms.copy()
		for wm in data.wms:
			which = run(['which', data.wms[wm][0]], 'output')
			if which:
				output += ' -- ' + which
			else:
				del self.wms[wm]

		if compiz:
			data.compiz_args.insert(0, compiz)
			self.wms['compiz'] = (compiz, data.compiz_args, 'Compiz', None, None, None)

		self.decorators = data.decorators.copy()
		for decorator in data.decorators:
			which = run(['which', data.decorators[decorator][0]], 'output')
			if which:
				output += ' -- ' + which
			else:
				del self.decorators[decorator]

		self.apps = data.apps.copy()
		for app in data.apps:
			which = run(['which', data.apps[app][0]], 'output')
			if which:
				output += ' -- ' + which
			else:
				del self.apps[app]

		if parser_options.verbose:
			print(output.rstrip())

		compiz_optionlist = []

		self.options = data.options.copy()

		if compiz:
			compiz_help = run([compiz, '--help'], 'output')
			for item in compiz_help.split():
				item = item[1:].strip(" \r\n\t]")
				if item.startswith('--'):
					compiz_optionlist.append(item)

		for option in data.options:
			if data.options[option][1] not in compiz_optionlist:
				del self.options[option]
Пример #11
0
	def kill_others(self):
		killall = ['killall']
		for decorator in [x for x in self.decorators if x != self.name]:
			killall.append(self.decorators[decorator].base)
		run(killall, 'call')
Пример #12
0
	def start(self):
		'Start the active window manager'

		self.__set_old()

		if self.active == 'compiz' and self.old and self[self.old].killcmd:
			if run(['which', self[self.old].killcmd[0]], 'call', quiet=True) == 0:
				run(self[self.old].killcmd, 'call')
				time.sleep(1)

		if self.active and self.old and 'noreplace' in self[self.active].flags:
			run(['killall', self[self.old].base], 'call')
			time.sleep(1)

		if self.active == 'compiz':
			# use a copy, not the original
			compiz_command = self['compiz'].command[:]
			for option in options:
				if options[option].enabled:
					if options[option].switch is not None:
						compiz_command.append(options[option].switch)

			kill_list = ['killall']
			for decorator in decorators:
				kill_list.append(decorators[decorator].base)
			run(kill_list, 'call')

			time.sleep(0.5)

			# do it
			print(' ... executing: ' + ' '.join(compiz_command))
			run(compiz_command, quiet=False)

		elif self.active:
			run(self[self.active].command)

		else:
			print(' * No active WM set; not going to do anything.')