#!/usr/bin/env python3 """ HSRename - Native Linux GUI for mass renaming files. Inspired by Bulk Rename Utility (Windows); supports preview and flexible rules. """ import sys import traceback from pathlib import Path # Ensure project root is on path when run as script or module _root = Path(__file__).resolve().parent if str(_root) not in sys.path: sys.path.insert(0, str(_root)) from PyQt6.QtWidgets import QApplication from PyQt6.QtCore import Qt from gui.main_window import MainWindow def _install_exception_logger() -> None: log_dir = Path.home() / ".config" / "HSRename" log_dir.mkdir(parents=True, exist_ok=True) log_file = log_dir / "crash.log" def _hook(exc_type, exc, tb): try: log_file.write_text( "".join(traceback.format_exception(exc_type, exc, tb)), encoding="utf-8", ) except OSError: pass sys.__excepthook__(exc_type, exc, tb) sys.excepthook = _hook def main(): _install_exception_logger() QApplication.setHighDpiScaleFactorRoundingPolicy( Qt.HighDpiScaleFactorRoundingPolicy.PassThrough ) app = QApplication(sys.argv) app.setOrganizationName("HSRename") app.setOrganizationDomain("hisora.dev") app.setApplicationName("HSRename") version_file = _root / "VERSION" app.setApplicationVersion(version_file.read_text().strip() if version_file.is_file() else "") win = MainWindow() win.show() sys.exit(app.exec()) if __name__ == "__main__": main()