def __init__(self, installed): # Open CompizConfig context if parser_options.verbose: print(' * Opening CompizConfig context') context = compizconfig.Context() # Either Compiz 0.9.x or Compiz 0.8.x. if 'decor' in context.Plugins: self.command = context.Plugins['decor'].Screen['command'] else: self.command = context.Plugins['decoration'].Display['command'] for decorator in installed.decorators: self[decorator] = CompizDecorator(decorator, self, installed) self.default = None decorator = [d for d in self if self[d].desktop == env.desktop] if decorator: self.default = decorator[0] elif 'emerald' in self: self.default = 'emerald' elif self: self.default = next(iter(self))
class CompizPlugin: context = compizconfig.Context() def __init__(self, name): self._plugin = self.context.Plugins[name] @classmethod def set_plugin_active(cls, name, active): try: plugin = cls.context.Plugins[name] plugin.Enabled = int(active) cls.context.Write() except: pass @classmethod def get_plugin_active(cls, name): try: plugin = cls.context.Plugins[name] return bool(plugin.Enabled) except: return False def set_enabled(self, bool): self._plugin.Enabled = int(bool) self.save() def get_enabled(self): return self._plugin.Enabled def save(self): self.context.Write() def resolve_conflict(self): conflicts = self.get_enabled() and self._plugin.DisableConflicts or \ self._plugin.EnableConflicts conflict = ccm.PluginConflict(self._plugin, conflicts) return conflict.Resolve() @classmethod def is_available(cls, name, setting): return name in cls.context.Plugins and \ setting in cls.context.Plugins[name].Screen def create_setting(self, key, target): settings = self._plugin.Screen if type(settings) == list: return settings[0][key] else: return settings[key]
import sys, os import compizconfig configfile = sys.argv[-1] context = compizconfig.Context() context.Import(os.path.abspath(configfile)) grid_settings = sorted([setting for setting in context.Plugins['grid'].Screen]) grid_setting_values = [ context.Plugins['grid'].Screen[setting].Value for setting in grid_settings ] for s, v in zip(grid_settings, grid_setting_values): print("{}: {}".format(s, v))
def setUp (self): self.context = compizconfig.Context ()
def update_context(cls): if system.has_ccm() and system.has_right_compiz(): import compizconfig as ccs load_ccm() cls.context = ccs.Context()
class CompizPlugin: if system.has_ccm() and system.has_right_compiz() == 1: import compizconfig as ccs context = ccs.Context() elif system.has_right_compiz() == 0: context = None error = False @classmethod def update_context(cls): if system.has_ccm() and system.has_right_compiz(): import compizconfig as ccs load_ccm() cls.context = ccs.Context() @classmethod def set_plugin_active(cls, name, active): try: plugin = cls.context.Plugins[name] plugin.Enabled = int(active) cls.context.Write() except: pass @classmethod def get_plugin_active(cls, name): try: plugin = cls.context.Plugins[name] return bool(plugin.Enabled) except: return False def __init__(self, name): self.__plugin = self.context.Plugins[name] def set_enabled(self, bool): self.__plugin.Enabled = int(bool) self.save() def get_enabled(self): return self.__plugin.Enabled def save(self): self.context.Write() def resolve_conflict(self): conflicts = self.get_enabled() and self.__plugin.DisableConflicts \ or self.__plugin.EnableConflicts conflict = ccm.PluginConflict(self.__plugin, conflicts) return conflict.Resolve() @classmethod def is_available(cls, name, setting): if ccm.Version >= '0.9.2': target = 'Screen' else: target = 'Display' return cls.context.Plugins.has_key(name) and \ getattr(cls.context.Plugins[name], target).has_key(setting) def create_setting(self, key, target): settings = (self.__plugin, target) #TODO remove it in the future if ccm.Version >= '0.9.2': target = 'Screen' else: if not target: target = 'Display' settings = getattr(self.__plugin, target) if type(settings) == list: return settings[0][key] else: return settings[key]