diff --git a/kuro/base.py b/kuro/base.py index fd7bc84..370c02f 100644 --- a/kuro/base.py +++ b/kuro/base.py @@ -1,6 +1,6 @@ from libqtile import layout as libqtile_layout, layout, bar, widget from libqtile.command import lazy -from libqtile.config import Key, Group, Screen, Drag, Click +from libqtile.config import Key, Group, Screen, Drag, Click, Match class BaseConfig: @@ -29,20 +29,14 @@ class BaseTheme: bring_front_click = False cursor_warp = False floating_layout = libqtile_layout.Floating(float_rules=[ - {'wmclass': 'confirm'}, - {'wmclass': 'dialog'}, - {'wmclass': 'download'}, - {'wmclass': 'error'}, - {'wmclass': 'file_progress'}, - {'wmclass': 'notification'}, - {'wmclass': 'splash'}, - {'wmclass': 'toolbar'}, - {'wmclass': 'confirmreset'}, # gitk - {'wmclass': 'makebranch'}, # gitk - {'wmclass': 'maketag'}, # gitk - {'wname': 'branchdialog'}, # gitk - {'wname': 'pinentry'}, # GPG key password entry - {'wmclass': 'ssh-askpass'}, # ssh-askpass + # Run the utility of `xprop` to see the wm class and name of an X client. + *layout.Floating.default_float_rules, + Match(wm_class='confirmreset'), # gitk + Match(wm_class='makebranch'), # gitk + Match(wm_class='maketag'), # gitk + Match(wm_class='ssh-askpass'), # ssh-askpass + Match(title='branchdialog'), # gitk + Match(title='pinentry'), # GPG key password entry ]) auto_fullscreen = True focus_on_window_activation = "smart" diff --git a/kuro/theme.py b/kuro/theme.py index ac322df..9e14eaa 100644 --- a/kuro/theme.py +++ b/kuro/theme.py @@ -7,7 +7,7 @@ from libqtile.log_utils import logger logger.error("Importing qtile theme requirements...") -from libqtile.config import Key, Screen, Group, Drag, Click +from libqtile.config import Key, Screen, Group, Drag, Click, Match from libqtile.command import lazy from libqtile import layout, bar, widget @@ -75,20 +75,14 @@ class Kuro(BaseTheme): # Floating layout override floating_layout = kuro_layouts.KuroFloating(float_rules=[ - {'wmclass': 'confirm'}, - {'wmclass': 'dialog'}, - {'wmclass': 'download'}, - {'wmclass': 'error'}, - {'wmclass': 'file_progress'}, - {'wmclass': 'notification'}, - {'wmclass': 'splash'}, - {'wmclass': 'toolbar'}, - {'wmclass': 'confirmreset'}, # gitk - {'wmclass': 'makebranch'}, # gitk - {'wmclass': 'maketag'}, # gitk - {'wname': 'branchdialog'}, # gitk - {'wname': 'pinentry'}, # GPG key password entry - {'wmclass': 'ssh-askpass'}, # ssh-askpass + # Run the utility of `xprop` to see the wm class and name of an X client. + *layout.Floating.default_float_rules, + Match(wm_class='confirmreset'), # gitk + Match(wm_class='makebranch'), # gitk + Match(wm_class='maketag'), # gitk + Match(wm_class='ssh-askpass'), # ssh-askpass + Match(title='branchdialog'), # gitk + Match(title='pinentry'), # GPG key password entry ]) def set_debug_text(self, text): @@ -242,14 +236,7 @@ class Kuro(BaseTheme): groups.append(Group("")) groups.append(Group("")) groups.append(Group("")) - groups.append(Group("", spawn=Config.get('apps_audio', "true"), layout='verticaltile', layouts=[ - layout.VerticalTile( - 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"), - ) - ])) + groups.append(Group("", spawn=Config.get('apps_audio', "true"))) groups.append(Group("", layout='floating', layouts=[ layout.Floating( border_focus="#990000", @@ -385,6 +372,7 @@ class Kuro(BaseTheme): 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), + update_interval=Config.get('updates_interval', 600), **self.widget_defaults ), widget.TextBox("#{}".format(x), name="default", **self.widget_defaults), @@ -591,11 +579,14 @@ class Kuro(BaseTheme): p.wait() self.log_info("Starting compositor...") - utils.execute_once("compton -b") + utils.execute_once("picom -b") self.log_info("Starting clipboard manager...") utils.execute_once("xfce4-clipman") + self.log_info("Starting notification daemon...") + utils.execute_once("dunst") + # Update color scheme self.initialize_colorscheme() @@ -627,9 +618,9 @@ class Kuro(BaseTheme): for r in dg.rules: pid = -1 # noinspection PyProtectedMember - for r2 in r.match._rules: - if r2[0] == "net_wm_pid": - pid = r2[1] + for m in r.matchlist: + if m._rules.get('net_wm_pid', None) is not None: + pid = m._rules.get('net_wm_pid') break if pid != -1: self.initial_windows.append((pid, r.group)) diff --git a/kuro/utils/general.py b/kuro/utils/general.py index da8d96b..ff5893f 100644 --- a/kuro/utils/general.py +++ b/kuro/utils/general.py @@ -12,7 +12,10 @@ from libqtile.bar import Bar from notify2 import Notification, URGENCY_NORMAL from libqtile.log_utils import logger -notify2.init("QTileWM") +try: + notify2.init("QTileWM") +except DBusException as e: + logger.error("Could not initialize notify2: {}".format(e)) BUTTON_LEFT = 1 BUTTON_MIDDLE = 2 @@ -100,6 +103,10 @@ def notify(title, content, urgency=URGENCY_NORMAL, timeout=5000, image=None): try: return notification.show() + except notify2.UninittedError: + logger.warning("Notify2 was uninitialized, initializing...") + notify2.init("qtile") + return notification.show() except DBusException as e: logger.warning("Showing notification failed: {}".format(e)) logger.warning(traceback.format_exc()) diff --git a/kuro/utils/layouts.py b/kuro/utils/layouts.py index c12007c..e74dee6 100644 --- a/kuro/utils/layouts.py +++ b/kuro/utils/layouts.py @@ -15,68 +15,53 @@ class KuroFloating(Floating): super(KuroFloating, self).__init__(*args, **kwargs) self.add_defaults(KuroFloating.defaults) - def configure(self, client, screen): - # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application, - # don't reposition it anywhere, let Java app to control it - cls = client.window.get_wm_class() or '' - is_java_dropdown = 'sun-awt-X11-XWindowPeer' in cls - if is_java_dropdown: - return - + def configure(self, client, screen_rect): if hasattr(client, "is_static_window") and client.is_static_window: - bc = client.group.qtile.color_pixel(self.border_static) + bc = self.border_static elif client.has_focus: - bc = client.group.qtile.color_pixel(self.border_focus) + bc = self.border_focus else: - bc = client.group.qtile.color_pixel(self.border_normal) + bc = self.border_normal + if client.maximized: bw = self.max_border_width elif client.fullscreen: bw = self.fullscreen_border_width else: bw = self.border_width - above = False - # We definitely have a screen here, so let's be sure we'll float on screen - try: - client.float_x - client.float_y - except AttributeError: - # this window hasn't been placed before, let's put it in a sensible spot - transient_for = client.window.get_wm_transient_for() - win = client.group.qtile.windows_map.get(transient_for) - if win is not None: - # if transient for a window, place in the center of the window - center_x = win.x + win.width / 2 - center_y = win.y + win.height / 2 - else: - center_x = screen.x + screen.width / 2 - center_y = screen.y + screen.height / 2 - above = True + # 'sun-awt-X11-XWindowPeer' is a dropdown used in Java application, + # don't reposition it anywhere, let Java app to control it + cls = client.window.get_wm_class() or '' + is_java_dropdown = 'sun-awt-X11-XWindowPeer' in cls + if is_java_dropdown: + client.paint_borders(bc, bw) + client.cmd_bring_to_front() - x = center_x - client.width / 2 - y = center_y - client.height / 2 + # alternatively, users may have asked us explicitly to leave the client alone + elif any(m.compare(client) for m in self.no_reposition_rules): + client.paint_borders(bc, bw) + client.cmd_bring_to_front() - # don't go off the right... - x = min(x, screen.x + screen.width) - # or left... - x = max(x, screen.x) - # or bottom... - y = min(y, screen.y + screen.height) - # or top - y = max(y, screen.y) + else: + above = False - if not (self.no_reposition_match and self.no_reposition_match.compare(client)): - client.x = int(round(x)) - client.y = int(round(y)) + # We definitely have a screen here, so let's be sure we'll float on screen + try: + client.float_x + client.float_y + except AttributeError: + # this window hasn't been placed before, let's put it in a sensible spot + above = self.compute_client_position(client, screen_rect) - client.place( - client.x, - client.y, - client.width, - client.height, - bw, - bc, - above, - ) + + client.place( + client.x, + client.y, + client.width, + client.height, + bw, + bc, + above, + ) client.unhide()