|
|
@ -18,7 +18,7 @@
|
|
|
|
# Author(s): crdlb
|
|
|
|
# Author(s): crdlb
|
|
|
|
# Copyright 2007 Christopher Williams <christopherw@verizon.net>
|
|
|
|
# Copyright 2007 Christopher Williams <christopherw@verizon.net>
|
|
|
|
|
|
|
|
|
|
|
|
import os, compizconfig, ConfigParser, time
|
|
|
|
import os, compizconfig, configparser, time
|
|
|
|
import data as _data
|
|
|
|
import data as _data
|
|
|
|
from parser import options as parser_options
|
|
|
|
from parser import options as parser_options
|
|
|
|
from environment import env
|
|
|
|
from environment import env
|
|
|
@ -44,7 +44,7 @@ class Application(object):
|
|
|
|
self.label = installed.apps[name][2]
|
|
|
|
self.label = installed.apps[name][2]
|
|
|
|
|
|
|
|
|
|
|
|
def launch(self):
|
|
|
|
def launch(self):
|
|
|
|
print ' * Launching %s' %self.label
|
|
|
|
print(' * Launching %s' %self.label)
|
|
|
|
run(self.command)
|
|
|
|
run(self.command)
|
|
|
|
|
|
|
|
|
|
|
|
class Applications(dict):
|
|
|
|
class Applications(dict):
|
|
|
@ -69,7 +69,7 @@ class CompizOption(object):
|
|
|
|
return self.config.getboolean('compiz options', self.name)
|
|
|
|
return self.config.getboolean('compiz options', self.name)
|
|
|
|
|
|
|
|
|
|
|
|
def __set(self, value):
|
|
|
|
def __set(self, value):
|
|
|
|
print ' * Setting option %s to %s' %(self.label, value)
|
|
|
|
print(' * Setting option %s to %s' %(self.label, value))
|
|
|
|
self.config.set('compiz options', self.name, str(bool(value)).lower())
|
|
|
|
self.config.set('compiz options', self.name, str(bool(value)).lower())
|
|
|
|
self.config.write(open(self.config.config_file, 'w'))
|
|
|
|
self.config.write(open(self.config.config_file, 'w'))
|
|
|
|
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ class WindowManagers(dict):
|
|
|
|
self.fallback = wm[0]
|
|
|
|
self.fallback = wm[0]
|
|
|
|
|
|
|
|
|
|
|
|
elif self:
|
|
|
|
elif self:
|
|
|
|
self.fallback = self.keys()[0]
|
|
|
|
self.fallback = list(self.keys())[0]
|
|
|
|
|
|
|
|
|
|
|
|
self.__set_old()
|
|
|
|
self.__set_old()
|
|
|
|
|
|
|
|
|
|
|
@ -128,9 +128,9 @@ class WindowManagers(dict):
|
|
|
|
def __set(self, value):
|
|
|
|
def __set(self, value):
|
|
|
|
|
|
|
|
|
|
|
|
if value in wms:
|
|
|
|
if value in wms:
|
|
|
|
print ' * Setting window manager to', wms[value].label
|
|
|
|
print(' * Setting window manager to', wms[value].label)
|
|
|
|
elif not value:
|
|
|
|
elif not value:
|
|
|
|
print ' * Setting window manager to empty value'
|
|
|
|
print(' * Setting window manager to empty value')
|
|
|
|
|
|
|
|
|
|
|
|
self.config.set('window manager', 'active wm', str(value))
|
|
|
|
self.config.set('window manager', 'active wm', str(value))
|
|
|
|
self.config.write(open(self.config.config_file, 'w'))
|
|
|
|
self.config.write(open(self.config.config_file, 'w'))
|
|
|
@ -171,22 +171,22 @@ class WindowManagers(dict):
|
|
|
|
time.sleep(0.5)
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
|
|
|
|
|
|
|
# do it
|
|
|
|
# do it
|
|
|
|
print ' ... executing:', ' '.join(compiz_command)
|
|
|
|
print(' ... executing:', ' '.join(compiz_command))
|
|
|
|
run(compiz_command, quiet=False)
|
|
|
|
run(compiz_command, quiet=False)
|
|
|
|
|
|
|
|
|
|
|
|
elif self.active:
|
|
|
|
elif self.active:
|
|
|
|
run(self[self.active].command)
|
|
|
|
run(self[self.active].command)
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print ' * No active WM set; not going to do anything.'
|
|
|
|
print(' * No active WM set; not going to do anything.')
|
|
|
|
|
|
|
|
|
|
|
|
def restart(self):
|
|
|
|
def restart(self):
|
|
|
|
if wms.active:
|
|
|
|
if wms.active:
|
|
|
|
print ' * Reloading %s' %wms.active
|
|
|
|
print(' * Reloading %s' %wms.active)
|
|
|
|
self.start()
|
|
|
|
self.start()
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print ' * Not reloading, no active window manager set'
|
|
|
|
print(' * Not reloading, no active window manager set')
|
|
|
|
|
|
|
|
|
|
|
|
active = property(__get, __set)
|
|
|
|
active = property(__get, __set)
|
|
|
|
|
|
|
|
|
|
|
@ -213,7 +213,7 @@ class CompizDecorators(dict):
|
|
|
|
|
|
|
|
|
|
|
|
# Open CompizConfig context
|
|
|
|
# Open CompizConfig context
|
|
|
|
if parser_options.verbose:
|
|
|
|
if parser_options.verbose:
|
|
|
|
print ' * Opening CompizConfig context'
|
|
|
|
print(' * Opening CompizConfig context')
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
context = compizconfig.Context( \
|
|
|
|
context = compizconfig.Context( \
|
|
|
@ -236,24 +236,24 @@ class CompizDecorators(dict):
|
|
|
|
self.default = 'emerald'
|
|
|
|
self.default = 'emerald'
|
|
|
|
|
|
|
|
|
|
|
|
elif self:
|
|
|
|
elif self:
|
|
|
|
self.default = self.keys()[0]
|
|
|
|
self.default = list(self.keys())[0]
|
|
|
|
|
|
|
|
|
|
|
|
def __set(self, decorator):
|
|
|
|
def __set(self, decorator):
|
|
|
|
if decorator in self:
|
|
|
|
if decorator in self:
|
|
|
|
self.command.Plugin.Context.ProcessEvents()
|
|
|
|
self.command.Plugin.Context.ProcessEvents()
|
|
|
|
print ' * Setting decorator to %s ("%s")' \
|
|
|
|
print(' * Setting decorator to %s ("%s")' \
|
|
|
|
%(self[decorator].label, self[decorator].command)
|
|
|
|
%(self[decorator].label, self[decorator].command))
|
|
|
|
self.command.Value = self[decorator].command
|
|
|
|
self.command.Value = self[decorator].command
|
|
|
|
self.command.Plugin.Context.Write()
|
|
|
|
self.command.Plugin.Context.Write()
|
|
|
|
elif not decorator:
|
|
|
|
elif not decorator:
|
|
|
|
print ' * Not setting decorator to none'
|
|
|
|
print(' * Not setting decorator to none')
|
|
|
|
|
|
|
|
|
|
|
|
def __get(self):
|
|
|
|
def __get(self):
|
|
|
|
_decorator = [d for d in self if self.command.Value == self[d].command]
|
|
|
|
_decorator = [d for d in self if self.command.Value == self[d].command]
|
|
|
|
if _decorator:
|
|
|
|
if _decorator:
|
|
|
|
decorator = _decorator[0]
|
|
|
|
decorator = _decorator[0]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print ' * Decorator "%s" is invalid.' %self.command.Value
|
|
|
|
print(' * Decorator "%s" is invalid.' %self.command.Value)
|
|
|
|
self.active = self.default
|
|
|
|
self.active = self.default
|
|
|
|
decorator = self.command.Value
|
|
|
|
decorator = self.command.Value
|
|
|
|
return decorator
|
|
|
|
return decorator
|
|
|
@ -263,7 +263,7 @@ class CompizDecorators(dict):
|
|
|
|
class Installed(object):
|
|
|
|
class Installed(object):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, data):
|
|
|
|
def __init__(self, data):
|
|
|
|
print ' * Searching for installed applications...'
|
|
|
|
print(' * Searching for installed applications...')
|
|
|
|
|
|
|
|
|
|
|
|
### Compiz Detection
|
|
|
|
### Compiz Detection
|
|
|
|
bins = {}
|
|
|
|
bins = {}
|
|
|
@ -326,7 +326,7 @@ class Installed(object):
|
|
|
|
del self.apps[app]
|
|
|
|
del self.apps[app]
|
|
|
|
|
|
|
|
|
|
|
|
if parser_options.verbose:
|
|
|
|
if parser_options.verbose:
|
|
|
|
print output.rstrip()
|
|
|
|
print(output.rstrip())
|
|
|
|
|
|
|
|
|
|
|
|
compiz_optionlist = []
|
|
|
|
compiz_optionlist = []
|
|
|
|
|
|
|
|
|
|
|
@ -343,11 +343,11 @@ class Installed(object):
|
|
|
|
if data.options[option][1] not in compiz_optionlist:
|
|
|
|
if data.options[option][1] not in compiz_optionlist:
|
|
|
|
del self.options[option]
|
|
|
|
del self.options[option]
|
|
|
|
|
|
|
|
|
|
|
|
class Configuration(ConfigParser.ConfigParser):
|
|
|
|
class Configuration(configparser.ConfigParser):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, data):
|
|
|
|
def __init__(self, data):
|
|
|
|
|
|
|
|
|
|
|
|
ConfigParser.ConfigParser.__init__(self)
|
|
|
|
configparser.ConfigParser.__init__(self)
|
|
|
|
self.config_folder = data.config_folder
|
|
|
|
self.config_folder = data.config_folder
|
|
|
|
self.config_file = data.config_file
|
|
|
|
self.config_file = data.config_file
|
|
|
|
|
|
|
|
|
|
|
@ -356,12 +356,12 @@ class Configuration(ConfigParser.ConfigParser):
|
|
|
|
# Configuration file setup
|
|
|
|
# Configuration file setup
|
|
|
|
if not os.path.exists(self.config_folder):
|
|
|
|
if not os.path.exists(self.config_folder):
|
|
|
|
if parser_options.verbose:
|
|
|
|
if parser_options.verbose:
|
|
|
|
print ' * Creating configuration folder...'
|
|
|
|
print(' * Creating configuration folder...')
|
|
|
|
os.makedirs(self.config_folder)
|
|
|
|
os.makedirs(self.config_folder)
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(self.config_file):
|
|
|
|
if not os.path.exists(self.config_file):
|
|
|
|
if parser_options.verbose:
|
|
|
|
if parser_options.verbose:
|
|
|
|
print ' * Creating configuration file...'
|
|
|
|
print(' * Creating configuration file...')
|
|
|
|
self.create_config_file()
|
|
|
|
self.create_config_file()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -374,9 +374,9 @@ class Configuration(ConfigParser.ConfigParser):
|
|
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
# back it up and make a new one
|
|
|
|
# back it up and make a new one
|
|
|
|
print ' * Configuration file (%s) invalid' %self.config_file
|
|
|
|
print(' * Configuration file (%s) invalid' %self.config_file)
|
|
|
|
self.reset_config_file()
|
|
|
|
self.reset_config_file()
|
|
|
|
print ' * Generating new configuration file'
|
|
|
|
print(' * Generating new configuration file')
|
|
|
|
self.create_config_file()
|
|
|
|
self.create_config_file()
|
|
|
|
|
|
|
|
|
|
|
|
def create_config_file(self):
|
|
|
|
def create_config_file(self):
|
|
|
@ -405,9 +405,9 @@ class Configuration(ConfigParser.ConfigParser):
|
|
|
|
config_backup = '%s.backup.%s' \
|
|
|
|
config_backup = '%s.backup.%s' \
|
|
|
|
%(self.config_file, time.strftime('%Y%m%d%H%M%S'))
|
|
|
|
%(self.config_file, time.strftime('%Y%m%d%H%M%S'))
|
|
|
|
os.rename(self.config_file, config_backup)
|
|
|
|
os.rename(self.config_file, config_backup)
|
|
|
|
print ' ... backed up to:', config_backup
|
|
|
|
print(' ... backed up to:', config_backup)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print ' ... no configuration file found'
|
|
|
|
print(' ... no configuration file found')
|
|
|
|
|
|
|
|
|
|
|
|
# Instantiate...
|
|
|
|
# Instantiate...
|
|
|
|
_installed = Installed(_data)
|
|
|
|
_installed = Installed(_data)
|
|
|
|