Multiple changes:
- Wrap topbar in own class for customization purposes. - Add stub methods for popup creation - Add method and shortcut to display the WM class in a notification - Add keyboard backlight control module, to control my keyboard backlight based on which app has focus - Add debugging bar to easily display debugging messages - Add display brightness shortcut keys - Move some global vars into the theme class - Lower update intervals for widgets to lower CPU usage - Add debugging configuration for use with Xephyr
This commit is contained in:
parent
19de16c8b7
commit
b9224b667d
8 changed files with 755 additions and 30 deletions
140
kuro/theme.py
140
kuro/theme.py
|
@ -3,10 +3,12 @@ from libqtile.command import lazy
|
|||
from libqtile import layout, bar, widget
|
||||
|
||||
# Import theme util functions
|
||||
from kuro import utils
|
||||
from kuro.utils import general as utils
|
||||
|
||||
# Import variables
|
||||
from kuro.base import BaseTheme
|
||||
from kuro.utils.general import display_wm_class
|
||||
from kuro.utils.kb_backlight import handle_focus_change as kb_handle_focus_change
|
||||
|
||||
try:
|
||||
from kuro.config import Config
|
||||
|
@ -18,7 +20,7 @@ except ImportError:
|
|||
raise ImportError("Could not load theme Config or BaseConfig!")
|
||||
|
||||
# Initialize logging
|
||||
from libqtile.log_utils import logger as log
|
||||
from libqtile.log_utils import logger
|
||||
|
||||
|
||||
class Kuro(BaseTheme):
|
||||
|
@ -27,17 +29,46 @@ class Kuro(BaseTheme):
|
|||
|
||||
# Show debug messages
|
||||
debug = Config.get('debug', False)
|
||||
debug_textfields = []
|
||||
debug_bars = []
|
||||
|
||||
# Screen count
|
||||
num_screens = 0
|
||||
|
||||
# Top bars
|
||||
topbars = []
|
||||
|
||||
# Window manager name
|
||||
wmname = "QTile"
|
||||
|
||||
def set_debug_text(self, text):
|
||||
for field in self.debug_textfields:
|
||||
field.text = text
|
||||
for bar in self.debug_bars:
|
||||
bar.draw()
|
||||
|
||||
def log_debug(self, text):
|
||||
if Config.get('verbose', False):
|
||||
self.set_debug_text(text)
|
||||
logger.debug(text)
|
||||
|
||||
def log_info(self, text):
|
||||
self.set_debug_text(text)
|
||||
logger.info(text)
|
||||
|
||||
def initialize(self):
|
||||
log.debug("Initializing Kuro Theme...")
|
||||
self.log_debug("Initializing Kuro Theme...")
|
||||
|
||||
super(Kuro, self).initialize()
|
||||
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
# Update keys with keys for groups and layouts
|
||||
self.update_keys()
|
||||
|
||||
def init_keys(self):
|
||||
log.debug("Initializing keys")
|
||||
self.log_debug("Initializing keys")
|
||||
|
||||
return [
|
||||
# Switch between windows in current stack pane
|
||||
|
@ -76,23 +107,42 @@ class Kuro(BaseTheme):
|
|||
Key([self.mod, "shift"], "r", lazy.spawncmd()),
|
||||
|
||||
|
||||
# Backlight keys
|
||||
Key([], "XF86MonBrightnessUp", lazy.spawn(Config.get('cmd_brightness_up', 'xbacklight -inc 10'))),
|
||||
Key([], "XF86MonBrightnessDown", lazy.spawn(Config.get('cmd_brightness_down', 'xbacklight -dec 10'))),
|
||||
|
||||
# Toggle between different layouts as defined below
|
||||
Key([self.mod], "Tab", lazy.next_layout()),
|
||||
|
||||
# Kill the current window
|
||||
Key([self.mod], "w", lazy.window.kill()),
|
||||
|
||||
# Restart QTile
|
||||
Key([self.mod, "control"], "r", lazy.restart()),
|
||||
|
||||
# Redraw the top bar
|
||||
Key([self.mod, "shift", "control"], "r", lazy.function(self.redraw_bar)),
|
||||
|
||||
# Shutdown QTile
|
||||
Key([self.mod, "control"], "q", lazy.shutdown()),
|
||||
# Key([self.mod, "shift"], "e", self.evaluate()),
|
||||
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Debug keyboard shortcuts
|
||||
##
|
||||
Key([self.mod, "control"], "w", lazy.function(display_wm_class))
|
||||
]
|
||||
|
||||
def init_groups(self):
|
||||
log.debug("Initializing groups")
|
||||
self.log_debug("Initializing groups")
|
||||
|
||||
# http://fontawesome.io/cheatsheet
|
||||
return [Group(i) for i in ""]
|
||||
|
||||
def init_layouts(self):
|
||||
log.debug("Initializing layouts")
|
||||
self.log_debug("Initializing layouts")
|
||||
|
||||
return [
|
||||
layout.Wmii(
|
||||
|
@ -112,7 +162,7 @@ class Kuro(BaseTheme):
|
|||
]
|
||||
|
||||
def init_widget_defaults(self):
|
||||
log.debug("Initializing widget_defaults")
|
||||
self.log_debug("Initializing widget_defaults")
|
||||
|
||||
return {
|
||||
"font": Config.get('font_topbar', "Sans"),
|
||||
|
@ -121,20 +171,17 @@ class Kuro(BaseTheme):
|
|||
}
|
||||
|
||||
def init_screens(self):
|
||||
log.debug("Initializing screens")
|
||||
self.log_debug("Initializing screens")
|
||||
|
||||
num_screens = utils.get_screen_count()
|
||||
if num_screens == 0:
|
||||
num_screens = 1
|
||||
self.num_screens = utils.get_screen_count()
|
||||
if self.num_screens == 0:
|
||||
self.num_screens = 1
|
||||
|
||||
screens = []
|
||||
for x in range(num_screens):
|
||||
for x in range(self.num_screens):
|
||||
self.log_info("Initializing bars for screen {}".format(x))
|
||||
widgets = []
|
||||
widgets.extend([
|
||||
utils.AppLauncherIcon(
|
||||
filename=Config.get('applauncher_image', 'apps.png')
|
||||
),
|
||||
utils.bar_separator(Config),
|
||||
widget.GroupBox(
|
||||
active=Config.get('colour_groupbox_icon_active', '#ffffff'),
|
||||
borderwidth=Config.get('width_groupbox_border', 1),
|
||||
|
@ -148,7 +195,6 @@ class Kuro(BaseTheme):
|
|||
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.TaskList(
|
||||
|
@ -171,7 +217,8 @@ class Kuro(BaseTheme):
|
|||
foreground_alert=Config.get('thermal_colour_alert', '#ff0000'),
|
||||
tag_sensor=Config.get('thermal_sensor', 'temp1'),
|
||||
chip=Config.get('thermal_chip', None),
|
||||
threshold=Config.get('thermal_threshold', 70)
|
||||
threshold=Config.get('thermal_threshold', 70),
|
||||
update_interval=5,
|
||||
),
|
||||
|
||||
widget.CPUGraph(
|
||||
|
@ -181,6 +228,7 @@ class Kuro(BaseTheme):
|
|||
border_width=Config.get('cpu_graph_width', 0),
|
||||
line_width=Config.get('cpu_line_width', 1),
|
||||
samples=Config.get('cpu_samples', 10),
|
||||
frequency=2,
|
||||
),
|
||||
|
||||
widget.MemoryGraph(
|
||||
|
@ -190,6 +238,7 @@ class Kuro(BaseTheme):
|
|||
border_width=Config.get('mem_graph_width', 0),
|
||||
line_width=Config.get('mem_line_width', 1),
|
||||
samples=Config.get('mem_samples', 10),
|
||||
frequency=2,
|
||||
),
|
||||
|
||||
widget.HDDBusyGraph(
|
||||
|
@ -199,6 +248,7 @@ class Kuro(BaseTheme):
|
|||
border_width=Config.get('hdd_border_width', 0),
|
||||
line_width=Config.get('hdd_line_width', 1),
|
||||
samples=Config.get('hdd_samples', 10),
|
||||
frequency=2,
|
||||
),
|
||||
|
||||
widget.NetGraph(
|
||||
|
@ -208,6 +258,7 @@ class Kuro(BaseTheme):
|
|||
border_width=Config.get('net_border_width', 0),
|
||||
line_width=Config.get('net_line_width', 1),
|
||||
samples=Config.get('net_samples', 10),
|
||||
frequency=2,
|
||||
),
|
||||
|
||||
widget.BatteryIcon(
|
||||
|
@ -277,29 +328,40 @@ class Kuro(BaseTheme):
|
|||
),
|
||||
widget.TextBox("#{}".format(x), name="default", **self.widget_defaults),
|
||||
])
|
||||
screens.append(Screen(top=bar.Bar(
|
||||
|
||||
topbar = utils.KuroTopBar(
|
||||
theme=self,
|
||||
background=Config.get('bar_background', '#000000'),
|
||||
opacity=Config.get('bar_opacity', 1.0),
|
||||
widgets=widgets,
|
||||
size=Config.get('height_groupbox', 30)
|
||||
)))
|
||||
)
|
||||
|
||||
self.topbars.append(topbar)
|
||||
|
||||
screens.append(Screen(top=topbar))
|
||||
|
||||
# Add debug bars on each window if debugging is enabled
|
||||
if Config.get('debug', False):
|
||||
for x in range(num_screens):
|
||||
self.debug_textfields = []
|
||||
for x in range(self.num_screens):
|
||||
textfield = widget.TextBox("...", name="debugtext", **self.widget_defaults)
|
||||
self.debug_textfields.append(textfield)
|
||||
widgets = []
|
||||
widgets.extend([
|
||||
widget.TextBox(" Debugging bar ", name="default", **self.widget_defaults),
|
||||
widget.Notify(),
|
||||
widget.DebugInfo()
|
||||
textfield,
|
||||
])
|
||||
screens[x].bottom = bar.Bar(
|
||||
widgets=widgets,
|
||||
size=Config.get('height_debugbar', 30)
|
||||
)
|
||||
self.debug_bars.append(screens[x].bottom)
|
||||
|
||||
return screens
|
||||
|
||||
def init_mouse(self):
|
||||
log.debug("Initializing mouse")
|
||||
self.log_debug("Initializing mouse")
|
||||
|
||||
# Drag floating layouts.
|
||||
mouse = [
|
||||
|
@ -313,7 +375,7 @@ class Kuro(BaseTheme):
|
|||
return mouse
|
||||
|
||||
def update_keys(self):
|
||||
log.debug("Updating keys")
|
||||
self.log_debug("Updating keys")
|
||||
|
||||
for i, g in enumerate(self.groups):
|
||||
# mod1 + number = switch to group
|
||||
|
@ -350,6 +412,32 @@ class Kuro(BaseTheme):
|
|||
)
|
||||
])
|
||||
|
||||
# Util functions
|
||||
@staticmethod
|
||||
def redraw_bar(qtile):
|
||||
for b in qtile.topbars:
|
||||
b.draw()
|
||||
|
||||
# QTile base callbacks
|
||||
def callback_startup(self):
|
||||
utils.execute("sleep 3")
|
||||
|
||||
self.log_info("Restoring wallpaper...")
|
||||
utils.execute_once("nitrogen --restore")
|
||||
#
|
||||
# display = os.environ['DISPLAY']
|
||||
#
|
||||
# if not display:
|
||||
# display = ":0"
|
||||
#
|
||||
# # Start compton for each screen
|
||||
# for x in range(self.num_screens):
|
||||
# self.log_info("Launching compton for screen {}.{}".format(display, x))
|
||||
# utils.execute_once("compton --config ~/.config/compton.conf -b -d {}.{}".format(display, x))
|
||||
|
||||
# def callback_screen_change(self, *args, **kwargs):
|
||||
# self.num_screens = utils.get_screen_count()
|
||||
# return True
|
||||
|
||||
def callback_focus_change(self, *args, **kwargs):
|
||||
kb_handle_focus_change(self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue