132 lines
5.2 KiB
Python
132 lines
5.2 KiB
Python
# Copyright (c) 2010 Aldo Cortesi
|
|
# Copyright (c) 2010, 2014 dequis
|
|
# Copyright (c) 2012 Randall Ma
|
|
# Copyright (c) 2012-2014 Tycho Andersen
|
|
# Copyright (c) 2012 Craig Barnes
|
|
# Copyright (c) 2013 horsik
|
|
# Copyright (c) 2013 Tao Sauvage
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in
|
|
# all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
|
|
# Import Theme
|
|
from libqtile import hook
|
|
from libqtile.log_utils import logger
|
|
import traceback
|
|
|
|
try:
|
|
from kuro.theme import Kuro
|
|
Theme = Kuro()
|
|
except ImportError as e:
|
|
logger.error(traceback.format_exc())
|
|
logger.error("Could not load Kuro Theme. Trying to load BaseTheme. Error: {}".format(e))
|
|
try:
|
|
from kuro.base import BaseTheme as Kuro
|
|
Theme = Kuro()
|
|
except ImportError as e:
|
|
Kuro = None
|
|
logger.error(traceback.format_exc())
|
|
raise ImportError("Could not load theme Config or BaseTheme! Error: {}".format(e))
|
|
|
|
# Import theme configuration
|
|
try:
|
|
from kuro.config import Config
|
|
except ImportError as e:
|
|
logger.error(traceback.format_exc())
|
|
logger.error("Could not load Kuro Config. Trying to load BaseConfig. Error: {}".format(e))
|
|
try:
|
|
from kuro.base import BaseConfig as Config
|
|
except ImportError as e:
|
|
Config = None
|
|
logger.error(traceback.format_exc())
|
|
raise ImportError("Could not load theme Config or BaseConfig! Error: {}".format(e))
|
|
|
|
|
|
try:
|
|
logger.info("Initializing theme...")
|
|
# Initialize the Theme
|
|
Theme.initialize()
|
|
logger.info("Initialize done")
|
|
|
|
logger.info("Hooking theme into callbacks...")
|
|
# Hook theme into all hooks we know of
|
|
hook.subscribe.startup_once(Theme.callback_startup_once)
|
|
hook.subscribe.startup(Theme.callback_startup)
|
|
hook.subscribe.startup_complete(Theme.callback_startup_complete)
|
|
hook.subscribe.setgroup(Theme.callback_setgroup)
|
|
hook.subscribe.addgroup(Theme.callback_addgroup)
|
|
hook.subscribe.delgroup(Theme.callback_delgroup)
|
|
hook.subscribe.changegroup(Theme.callback_changegroup)
|
|
hook.subscribe.focus_change(Theme.callback_focus_change)
|
|
hook.subscribe.float_change(Theme.callback_float_change)
|
|
hook.subscribe.group_window_add(Theme.callback_group_window_add)
|
|
hook.subscribe.client_new(Theme.callback_client_new)
|
|
hook.subscribe.client_managed(Theme.callback_client_managed)
|
|
hook.subscribe.client_killed(Theme.callback_client_killed)
|
|
hook.subscribe.client_focus(Theme.callback_client_focus)
|
|
hook.subscribe.client_mouse_enter(Theme.callback_client_mouse_enter)
|
|
hook.subscribe.client_name_updated(Theme.callback_client_name_updated)
|
|
hook.subscribe.client_urgent_hint_changed(Theme.callback_client_urgent_hint_changed)
|
|
hook.subscribe.layout_change(Theme.callback_layout_change)
|
|
hook.subscribe.net_wm_icon_change(Theme.callback_net_wm_icon_change)
|
|
hook.subscribe.selection_notify(Theme.callback_selection_notify)
|
|
hook.subscribe.selection_change(Theme.callback_selection_change)
|
|
hook.subscribe.screen_change(Theme.callback_screen_change)
|
|
hook.subscribe.current_screen_change(Theme.callback_current_screen_change)
|
|
logger.info("Hooking done")
|
|
|
|
logger.info("Initializing theme variables")
|
|
# Initialize variables from theme
|
|
keys = Theme.keys
|
|
mouse = Theme.mouse
|
|
groups = Theme.groups
|
|
layouts = Theme.layouts
|
|
widget_defaults = Theme.widget_defaults
|
|
screens = Theme.screens
|
|
dgroups_key_binder = Theme.dgroups_key_binder
|
|
dgroups_app_rules = Theme.dgroups_app_rules
|
|
main = Theme.main
|
|
follow_mouse_focus = Theme.follow_mouse_focus
|
|
bring_front_click = Theme.bring_front_click
|
|
cursor_warp = Theme.cursor_warp
|
|
floating_layout = Theme.floating_layout
|
|
auto_fullscreen = Theme.auto_fullscreen
|
|
focus_on_window_activation = Theme.focus_on_window_activation
|
|
extensions = Theme.extensions
|
|
wmname = Theme.wmname
|
|
logger.info("Variable initialization done")
|
|
except Exception as e:
|
|
Theme = None
|
|
Config = None
|
|
logger.error(traceback.format_exc())
|
|
raise AttributeError("Could not configure theme! Error: {}".format(e))
|
|
|
|
|
|
def main(qtile):
|
|
# set logging level
|
|
if Config.get('debug', False):
|
|
if Config.get('verbose', False):
|
|
qtile.cmd_debug()
|
|
else:
|
|
qtile.cmd_info()
|
|
else:
|
|
qtile.cmd_warning()
|
|
|
|
# Save theme instance in qtile
|
|
qtile.theme_instance = Theme
|