My collection of plugins for the Qtile window manager.
git clone https://mcol.xyz/code/qtools
Log | Files | Refs | README

commit f77a91d0e3b99446651957494b52233de68bc715
parent 5b45f1633695d4cb7a5c24b8a240b5006f605a03
Author: mcol <mcol@posteo.net>
Date:   Sat, 29 Feb 2020 10:16:15 +0000

move notification icon decoder into Server method

Diffstat:
Mqtools/notification/notification.py | 20+++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/qtools/notification/notification.py b/qtools/notification/notification.py @@ -14,11 +14,10 @@ Example usage: """ -from libqtile import configurable, hook, images, pangocffi, window +from libqtile import configurable, hook, images, pangocffi from libqtile.lazy import lazy -from libqtile.notify import notifier -from libqtile.drawer import Drawer from libqtile.log_utils import logger +from libqtile.notify import notifier from qtools import Popup @@ -48,7 +47,6 @@ class Server(configurable.Configurable): - overflow - select screen / follow mouse/keyboard focus - critical notifications to replace any visible non-critical notifs immediately? - - icons position (left/right/None) - hints: image-path, desktop-entry (for icon) - hints: Server parameters set for single notification? - hints: progress value e.g. int:value:42 with drawing @@ -337,10 +335,11 @@ class Server(configurable.Configurable): img.resize(width=self.icon_size) else: img.resize(height=self.icon_size) - self._icons[notif.app_icon] = _decode_image( + surface, _ = images._decode_to_image_surface( img.bytes_img, img.width, img.height ) - except (FileNotFoundError, libqtile.images.LoadingError) as e : + self._icons[notif.app_icon] = surface, surface.get_height() + except (FileNotFoundError, images.LoadingError, IsADirectoryError) as e: logger.exception(e) self._icons[notif.app_icon] = None return self._icons[notif.app_icon] @@ -408,12 +407,3 @@ class Server(configurable.Configurable): self._paused = True while self._shown: self._close(self._shown[0]) - - -def _decode_image(bytes_img, width, height): - try: - surface, _ = images._decode_to_image_surface(bytes_img, width, height) - return surface, surface.get_height() - except Exception as e: - logger.exception(f'Could not load notification icon') - return None