diff --git a/src/utils/conversion.py b/src/utils/conversion.py index 650e660..05d533e 100644 --- a/src/utils/conversion.py +++ b/src/utils/conversion.py @@ -1,3 +1,4 @@ +from fabric.utils import logger import threading import time from concurrent.futures import ThreadPoolExecutor @@ -99,7 +100,7 @@ class CurrencyCache: "timestamp": current_time, } except Exception as je: - print(f"Failed to parse JSON for {from_code}: {je}") + logger.error(f"Failed to parse JSON for {from_code}: {je}") else: print( f"Background fetch for {from_code} returned status { @@ -108,7 +109,7 @@ class CurrencyCache: ) except Exception as e: - print(f"Background currency fetch failed for {from_code}: {e}") + logger.error(f"Background currency fetch failed for {from_code}: {e}") finally: # Mark request as complete with self._cache_lock: diff --git a/src/utils/dbus_helper.py b/src/utils/dbus_helper.py index 60ca14e..e56ed7c 100644 --- a/src/utils/dbus_helper.py +++ b/src/utils/dbus_helper.py @@ -1,4 +1,4 @@ -from fabric.utils import Gio, GLib +from fabric.utils import Gio, GLib, logger class GioDBusHelper: @@ -67,8 +67,8 @@ class GioDBusHelper: """Unsubscribe a previously registered signal using its subscription id.""" try: self.bus.signal_unsubscribe(subscription_id) - except Exception: - pass + except Exception as e: + logger.error(f"An error occurred: {e}") def set_property(self, interface_name, property_name, value_variant): """Sets a D-Bus property using the standard D-Bus Properties interface.""" diff --git a/src/utils/inhibit.py b/src/utils/inhibit.py index 9899483..3e511b8 100644 --- a/src/utils/inhibit.py +++ b/src/utils/inhibit.py @@ -1,3 +1,4 @@ +from fabric.utils import logger # From https://github.com/stwa/wayland-idle-inhibitor # License: WTFPL Version 2 @@ -78,10 +79,10 @@ def kill_existing_inhibit_processes(): except subprocess.CalledProcessError: # No processes found - print("No existing inhibit processes were running") + logger.error("No existing inhibit processes were running") return 0 except Exception as e: - print(f"Error stopping existing processes: {e}") + logger.error(f"Error stopping existing processes: {e}") return 0 @@ -182,8 +183,8 @@ def main() -> None: shutdown() except Exception as e: - print(f"Error: {str(e)}") - print("Make sure you're running this under a Wayland session.") + logger.error(f"Error: {str(e)}") + logger.error("Make sure you're running this under a Wayland session.") sys.exit(1) diff --git a/src/utils/occlusion.py b/src/utils/occlusion.py index a7b8602..afa0f1d 100644 --- a/src/utils/occlusion.py +++ b/src/utils/occlusion.py @@ -1,3 +1,4 @@ +from fabric.utils import logger import json import subprocess @@ -19,7 +20,7 @@ def get_current_workspace(): if part == "ID" and i + 1 < len(parts): return int(parts[i + 1]) except Exception as e: - print(f"Error getting current workspace: {e}") + logger.error(f"Error getting current workspace: {e}") return -1 @@ -53,7 +54,7 @@ def get_screen_dimensions(): "height", data.CURRENT_HEIGHT ) except Exception as e: - print(f"Error getting screen dimensions: {e}") + logger.error(f"Error getting screen dimensions: {e}") # Default fallback values return data.CURRENT_WIDTH, data.CURRENT_HEIGHT @@ -103,7 +104,7 @@ def check_occlusion(occlusion_region, workspace=None): ) clients = json.loads(result.stdout) except Exception as e: - print(f"Error retrieving client windows: {e}") + logger.error(f"Error retrieving client windows: {e}") return False occ_x, occ_y, occ_width, occ_height = occlusion_region