Skip to content

Commit

Permalink
chore(screengrab): add comment about auto-delete screenshot file (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
dynobo authored Apr 26, 2024
1 parent d093000 commit 7e82883
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
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

0 comments on commit 7e82883

Please sign in to comment.