An (outdated) collection of plugins for Qtile.
git clone https://github.com/m-col/qtools
Files | Refs | Readme

Commit 4c04fa3656b506ea4c546d2650320afafff1fa0a
Parent: 748b65674ec86fc3e3d4af4929c4544ab9dce98d
Author: mcol <mcol@posteo.net>
Date: 2020-02-29 10:07:49 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-02-29 10:07:49 +0000

Notification server determines screen using libqtile mouse position

qtools/notification/notification.py Modified

@@ -55,6 +55,10 @@
 
     """
     defaults = [
+        ('x', 32, 'x position on screen to start drawing notifications.'),
+        ('y', 64, 'y position on screen to start drawing notifications.'),
+        ('width', 192, 'Width of notifications.'),
+        ('height', 64, 'Height of notifications.'),
         ('format', '{summary}\n{body}', 'Text format.'),
         (
             'foreground',
@@ -96,6 +100,7 @@
         ('sticky_history', True, 'Disable timeout when browsing history.'),
         ('icon_size', 36, 'Pixel size of any icons.'),
         ('fullscreen', 'show', 'What to do when in fullscreen: show, hide, or queue.'),
+        ('screen', 'focus', 'How to select a screen: focus, mouse, or an int.'),
     ]
     capabilities = {'body', 'body-markup'}
     # specification: https://developer.gnome.org/notification-spec/
@@ -187,12 +192,13 @@
             self._queue.append(notif)
             return
 
-        if self.qtile.current_window.fullscreen and self.fullscreen != 'show':
-            if self.fullscreen == 'queue':
-                if self._unfullscreen not in hook.subscriptions:
-                    hook.subscribe.float_change(self._unfullscreen)
-                self._queue.append(notif)
-            return
+        if self.qtile.current_window and self.qtile.current_window.fullscreen:
+            if self.fullscreen != 'show':
+                if self.fullscreen == 'queue':
+                    if self._unfullscreen not in hook.subscriptions:
+                        hook.subscribe.float_change(self._unfullscreen)
+                    self._queue.append(notif)
+                return
 
         if notif.replaces_id:
             for popup in self._shown:
@@ -235,7 +241,7 @@
         popup.id = self._current_id
         if popup not in self._shown:
             self._shown.append(popup)
-        popup.x, popup.y = self._positions[len(self._shown) - 1]
+        popup.x, popup.y = self._get_coordinates()
         icon = self._load_icon(notif)
 
         popup.background = self.background[urgency]
@@ -287,6 +293,16 @@
             app_name = pangocffi.markup_escape_text(notif.app_name)
         return self.format.format(summary=summary, body=body, app_name=app_name)
 
+    def _get_coordinates(self):
+        x, y = self._positions[len(self._shown) - 1]
+        if isinstance(self.screen, int):
+            screen = self.qtile.screens[self.screen]
+        elif self.screen == 'focus':
+            screen = self.qtile.current_screen
+        elif self.screen == 'mouse':
+            screen = self.qtile.find_screen(*self.qtile.mouse_position)
+        return x + screen.x, y + screen.y
+
     def _close(self, popup, nid=None):
         """
         Close the specified Popup instance.
@@ -315,14 +331,18 @@
             if notif.app_icon in self._icons:
                 return self._icons.get(notif.app_icon)
             else:
-                img = images.Img.from_path(notif.app_icon)
-                if img.width > img.height:
-                    img.resize(width=self.icon_size)
-                else:
-                    img.resize(height=self.icon_size)
-                self._icons[notif.app_icon] = _decode_image(
-                    img.bytes_img, img.width, img.height
-                )
+                try:
+                    img = images.Img.from_path(notif.app_icon)
+                    if img.width > img.height:
+                        img.resize(width=self.icon_size)
+                    else:
+                        img.resize(height=self.icon_size)
+                    self._icons[notif.app_icon] = _decode_image(
+                        img.bytes_img, img.width, img.height
+                    )
+                except (FileNotFoundError, libqtile.images.LoadingError) as e :
+                    logger.exception(e)
+                    self._icons[notif.app_icon] = None
                 return self._icons[notif.app_icon]
         else:
             return None
@@ -389,6 +409,7 @@
             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)