diff --git a/.gitignore b/.gitignore index 07b41ff..6d47603 100644 --- a/.gitignore +++ b/.gitignore @@ -46,10 +46,11 @@ test_release.zip test_release/ DiscoReaper-* -REAPER-*/ +# App data files ReaperFiles-*/ Reaper-*/ DISCORD-*/ FLUXER-*/ REAPER-*/ EXPORT-*/ +screenshots/ diff --git a/disco-reaper.py b/disco-reaper.py index 1949111..2de0517 100644 --- a/disco-reaper.py +++ b/disco-reaper.py @@ -58,6 +58,12 @@ def relaunch_in_terminal(): continue def main(): + import os + # Ensure screenshots directory exists and is configured + shot_path = os.path.abspath("screenshots") + os.makedirs(shot_path, exist_ok=True) + os.environ["TEXTUAL_SCREENSHOT_LOCATION"] = shot_path + relaunch_in_terminal() setup_logging() run_disco_reaper_tui() diff --git a/src/ui/main_app.py b/src/ui/main_app.py index 60edf19..e149592 100644 --- a/src/ui/main_app.py +++ b/src/ui/main_app.py @@ -452,11 +452,36 @@ class ConfigScreen(Screen): # ────────────────────────────────────────────────────────────────────────────── class ReaperApp(App): - def on_mount(self) -> None: self.push_screen(ConfigSelectionScreen()) self.theme = "dracula" + def action_screenshot(self, filename: str | None = None, path: str | None = None) -> None: + """Action to take a screenshot.""" + self.deliver_screenshot(filename, path) + + def deliver_screenshot( + self, + filename: str | None = None, + path: str | None = None, + time_format: str | None = None, + ) -> str | None: + """Deliver a screenshot by saving it locally and notifying the user.""" + # Use our local screenshots folder if no path provided + save_path = path or os.path.abspath("screenshots") + try: + # Ensure directory exists + os.makedirs(save_path, exist_ok=True) + + # Using save_screenshot to write directly to disk + actual_path = self.save_screenshot(filename=filename, path=save_path, time_format=time_format) + self.notify(f"Screenshot saved to: {os.path.basename(actual_path)}", title="Screenshot", severity="information") + return actual_path + except Exception as e: + self.notify(f"Failed to save screenshot: {e}", title="Screenshot", severity="error") + logger.error(f"Screenshot delivery failed: {e}", exc_info=True) + return None + def run_disco_reaper_tui(): app = ReaperApp()