Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(screengrab): add comment about auto-delete screenshot file #621

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

## v0.5.5 (upcoming)

- All: Add russian translation. Thanks, @ViktorOn! ([#611](https://github.com/dynobo/normcap/pull/611))
- All: Update spanish translation. Thanks, @haggen88! ([#614](https://github.com/dynobo/normcap/pull/614))
- All: Add russian translation. Thanks, [@ViktorOn](https://github.com/ViktorOn)! ([#611](https://github.com/dynobo/normcap/pull/611))
- All: Update spanish translation. Thanks, [@haggen88](https://github.com/haggen88)! ([#614](https://github.com/dynobo/normcap/pull/614))
- Linux: Add `xsel` as another clipboard handler. Try `--clipboard-handler xsel` if
Normcap's result isn't copied to the clipboard correctly.
- Linux: Fix clipboard on Gnome 46 + Wayland. ([#620](https://github.com/dynobo/normcap/pull/620))
- Linux: Auto-remove screenshot file from pictures-directory on Wayland. Thanks, [@PavelDobCZ23](https://github.com/PavelDobCZ23)! ([#600](https://github.com/dynobo/normcap/issues/600))

## v0.5.4 (2024-01-15)

Expand Down
16 changes: 11 additions & 5 deletions normcap/screengrab/handlers/dbus_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import random
import re
import sys
import os
from pathlib import Path
from typing import Optional
from urllib.parse import urlparse

Expand Down Expand Up @@ -198,12 +198,18 @@ def _exception_triggered(uri: Exception) -> None:
raise error

uri = result[0]
image_path = urlparse(uri).path
parsed_uri = urlparse(uri)

image_path = Path(parsed_uri.path)
image = QtGui.QImage(image_path)

# XDG Portal save the image file to the users xdg-pictures directory. To not let
# them pile up, we try to remove it:
try:
os.remove(image_path)
except:
logger.warn(f"Failed to remove leftover screenshot file \"{image_path}\"!")
image_path.unlink()
except PermissionError:
logger.warning("Missing permission to remove screenshot file '%s'!", image_path)

return image


Expand Down