202 lines
7.4 KiB
Python
202 lines
7.4 KiB
Python
import logging
|
|
import os
|
|
|
|
from libqtile.config import Key, Screen, Group, Drag, Click
|
|
from libqtile.command import lazy
|
|
from libqtile import layout, bar, widget
|
|
|
|
# Import theme util functions
|
|
from kuro import utils
|
|
|
|
# Import variables
|
|
from kuro.base import BaseTheme
|
|
|
|
try:
|
|
from kuro.config import Config
|
|
except ImportError:
|
|
try:
|
|
from kuro.baseconfig import BaseConfig as Config
|
|
except ImportError:
|
|
Config = None
|
|
raise ImportError("Could not load theme Config or BaseConfig!")
|
|
|
|
# Initialize logging
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class Kuro(BaseTheme):
|
|
# Shorthand for modifier key
|
|
mod = Config.get("modifier", "mod4")
|
|
|
|
# Show debug messages
|
|
debug = Config.get('debug', False)
|
|
|
|
def initialize(self):
|
|
log.debug("Initializing Kuro Theme...")
|
|
|
|
super(Kuro, self).initialize()
|
|
|
|
# Update keys with keys for groups
|
|
self.update_keys()
|
|
|
|
def init_keys(self):
|
|
log.debug("Initializing keys")
|
|
|
|
return [
|
|
# Switch between windows in current stack pane
|
|
Key([self.mod], "k", lazy.layout.down()),
|
|
Key([self.mod], "j", lazy.layout.up()),
|
|
|
|
# Move windows up or down in current stack
|
|
Key([self.mod, "control"], "k", lazy.layout.shuffle_down()),
|
|
Key([self.mod, "control"], "j", lazy.layout.shuffle_up()),
|
|
|
|
# Switch window focus to other pane(s) of stack
|
|
Key([self.mod], "space", lazy.layout.next()),
|
|
|
|
# Swap panes of split stack
|
|
Key([self.mod, "shift"], "space", lazy.layout.rotate()),
|
|
|
|
# Toggle between split and unsplit sides of stack.
|
|
# Split = all windows displayed
|
|
# Unsplit = 1 window displayed, like Max layout, but still with
|
|
# multiple stack panes
|
|
Key([self.mod, "shift"], "Return", lazy.layout.toggle_split()),
|
|
Key([self.mod], "Return", lazy.spawn(Config.get('app_terminal', "xterm"))),
|
|
|
|
# Toggle between different layouts as defined below
|
|
Key([self.mod], "Tab", lazy.next_layout()),
|
|
Key([self.mod], "w", lazy.window.kill()),
|
|
|
|
Key([self.mod, "control"], "r", lazy.restart()),
|
|
Key([self.mod, "control"], "q", lazy.shutdown()),
|
|
Key([self.mod], "r", lazy.spawncmd()),
|
|
# Key([self.mod, "shift"], "e", self.evaluate()),
|
|
]
|
|
|
|
def init_groups(self):
|
|
log.debug("Initializing groups")
|
|
|
|
# http://fontawesome.io/cheatsheet
|
|
return [Group(i) for i in ""]
|
|
|
|
def init_layouts(self):
|
|
log.debug("Initializing layouts")
|
|
|
|
return [
|
|
layout.Matrix(columns=2,
|
|
border_focus=Config.get('colour_border_focus', "#ffffff"),
|
|
border_normal=Config.get('colour_border_normal', "#777777"),
|
|
border_width=Config.get('width_border', "1"),
|
|
margin=Config.get('margin_layout', "0"),
|
|
),
|
|
layout.Max(),
|
|
layout.Stack(num_stacks=2)
|
|
]
|
|
|
|
def init_widget_defaults(self):
|
|
log.debug("Initializing widget_defaults")
|
|
|
|
return {
|
|
"font": Config.get('font_default', "Sans"),
|
|
"fontsize": Config.get('fontsize_default', 16),
|
|
"padding": 3,
|
|
}
|
|
|
|
def init_screens(self):
|
|
log.debug("Initializing screens")
|
|
|
|
num_screens = utils.get_screen_count()
|
|
|
|
screens = []
|
|
for x in range(num_screens):
|
|
widgets = []
|
|
widgets.extend([
|
|
utils.bar_separator(Config),
|
|
widget.GroupBox(
|
|
active=Config.get('colour_groupbox_icon_active', '#ffffff'),
|
|
borderwidth=Config.get('width_groupbox_border', 1),
|
|
disable_drag=Config.get('bool_groupbox_disable_drag', False),
|
|
font=Config.get('font_groupbox', 'Arial'),
|
|
fontsize=Config.get('fontsize_groupbox', 15),
|
|
highlight_color=Config.get("colour_groupbox_border_normal", '#444444'),
|
|
inactive=Config.get('colour_groupbox_icon_inactive', '#444444'),
|
|
rounded=Config.get('bool_groupbox_rounded_borders', True),
|
|
this_current_screen_border=Config.get('colour_groupbox_border_focus', '#ffffff'),
|
|
this_screen_border=Config.get('colour_groupbox_border_focus', '#ffffff'),
|
|
margin=Config.get('margin_groupbox', 0)
|
|
),
|
|
utils.bar_separator(Config),
|
|
widget.Prompt(**self.widget_defaults),
|
|
|
|
widget.WindowName(**self.widget_defaults),
|
|
|
|
widget.CPUGraph(
|
|
width=25,
|
|
border_color="#000000",
|
|
border_width=0,
|
|
line_width=1,
|
|
samples=10,
|
|
),
|
|
widget.BatteryIcon(
|
|
battery_name=Config.get('battery_name', 'BAT0'),
|
|
energy_full_file=Config.get('battery_energy_full_file', 'charge_full'),
|
|
energy_now_file=Config.get('battery_energy_now_file', 'charge_now'),
|
|
theme_path=Config.get('battery_theme_path', '/home/docs/checkouts/readthedocs.org/user_builds/qtile/checkouts/latest/libqtile/resources/battery-icons'),
|
|
update_delay=Config.get('battery_update_delay', 30)
|
|
),
|
|
])
|
|
|
|
# Systray only on first screen
|
|
if x == 0:
|
|
widgets.append(widget.Systray(**self.widget_defaults))
|
|
|
|
widgets.extend([
|
|
utils.bar_separator(Config),
|
|
widget.Clock(format="%a %d %b, %H:%M", **self.widget_defaults),
|
|
utils.CheckUpdatesYaourt(
|
|
colour_no_updates=Config.get('updates_colour_none', '#ffffff'),
|
|
colour_have_updates=Config.get('updates_colour_available', '#ff0000'),
|
|
display_format=Config.get('updates_display_format', 'Updates: {updates}'),
|
|
execute=Config.get('updates_execute_command', None),
|
|
**self.widget_defaults
|
|
),
|
|
widget.TextBox("#{}".format(x), name="default", **self.widget_defaults),
|
|
])
|
|
screens.append(Screen(top=bar.Bar(
|
|
widgets=widgets,
|
|
size=Config.get('height_groupbox', 30)
|
|
)))
|
|
|
|
return screens
|
|
|
|
def init_mouse(self):
|
|
log.debug("Initializing mouse")
|
|
|
|
# Drag floating layouts.
|
|
return [
|
|
Drag([self.mod], "Button1", lazy.window.set_position_floating(),
|
|
start=lazy.window.get_position()),
|
|
Drag([self.mod], "Button3", lazy.window.set_size_floating(),
|
|
start=lazy.window.get_size()),
|
|
Click([self.mod], "Button2", lazy.window.bring_to_front())
|
|
]
|
|
|
|
def update_keys(self):
|
|
log.debug("Updating keys")
|
|
|
|
for i, g in enumerate(self.groups):
|
|
# mod1 + number = switch to group
|
|
self.keys.append(
|
|
Key([self.mod], str(i + 1), lazy.group[g.name].toscreen())
|
|
)
|
|
|
|
# mod1 + shift + number = switch to & move focused window to group
|
|
self.keys.append(
|
|
Key([self.mod, "shift"], str(i + 1), lazy.window.togroup(g.name))
|
|
)
|
|
|
|
def callback_startup(self):
|
|
utils.execute("sleep 3")
|
|
utils.execute_once("nitrogen --restore")
|