Changes to Celestia

This commit is contained in:
Kevin Alberts 2021-04-15 17:11:48 +02:00
parent f4c6430eb4
commit a033bde573
Signed by: Kurocon
GPG key ID: BCD496FEBA0C6BC1
5 changed files with 101 additions and 103 deletions

View file

@ -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())

View file

@ -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()