Skip to content

Open saved screenshot file when notification is clicked#4691

Open
dshcherb wants to merge 4 commits into
flameshot-org:masterfrom
dshcherb:2026-handle-notification-click
Open

Open saved screenshot file when notification is clicked#4691
dshcherb wants to merge 4 commits into
flameshot-org:masterfrom
dshcherb:2026-handle-notification-click

Conversation

@dshcherb

@dshcherb dshcherb commented May 18, 2026

Copy link
Copy Markdown

On GNOME (Wayland), clicking Flameshot's screenshot notification did nothing. The notification was sent via D-Bus with empty actions and only a KDE-specific x-kde-urls hint, which GNOME Shell ignores.

The change introduces:

  • Click-to-open logic: added a default action to the D-Bus notification when a file path is attached (per the freedesktop notification spec, this makes the notification body clickable). When the user clicks it, the notification daemon emits ActionInvoked, which a persistent actionHandler() singleton receives and calls QDesktopServices::openUrl() to open the file. The notification ID-to-path mapping is stored in a static map. We suppress the two non-actionable AbstractLogger::info() notifications (GNOME Wayland detected... and Capture saved to clipboard) by changing them to qDebug(). These sent competing notifications without a default action - if the user clicked one before the actionable Capture saved as <path> notification appeared, the click did nothing.

  • Daemon delegation (Flatpak on GNOME Wayland): The Flatpak D-Bus proxy routes ActionInvoked only to the sandbox whose unique bus ID called Notify(). Each flatpak run invocation creates a separate proxy instance, so when the CLI sends the notification and exits, the daemon never receives the click signal.
    This is fixed by having the CLI suppress its own Capture saved as... notification and sending the save path to the daemon via a new showSaveNotification D-Bus method. The daemon sends the notification itself, receives the click, and opens the file. The CLI exits immediately, allowing rapid successive screenshots.

Platform impact:

  • macOS/Windows: no change (guarded by platform #if)
  • Linux X11: minor, notification now includes default action
  • Linux Wayland/KDE: improvement, click-to-open alongside x-kde-urls
  • Linux Wayland/GNOME: fixed, click now opens the saved file

dshcherb added 4 commits May 18, 2026 14:13
On GNOME (Wayland), clicking Flameshot's screenshot notification did
nothing. The notification was sent via D-Bus with empty actions and
only a KDE-specific x-kde-urls hint, which GNOME Shell ignores.

Add a "default" action to the D-Bus notification when a file path is
attached (per the freedesktop notification spec, this makes the
notification body clickable). When the user clicks it, GNOME Shell
emits the ActionInvoked signal, which the new handler receives and
calls QDesktopServices::openUrl() to open the file.

https://specifications.freedesktop.org/notification/1.3/basic-design.html

SystemNotification instances are short-lived stack locals in
AbstractLogger, so a persistent singleton (actionHandler) is used to
receive the D-Bus signal. The notification ID-to-path mapping is
stored in a static map.

In the CLI capture flow, delay process exit by 10 seconds when
notifications are pending, so the D-Bus handler stays alive long
enough to receive the user's click.

Platform impact:
- macOS/Windows: no change (guarded by platform #if)
- Linux X11: minor, notification now includes default action
- Linux Wayland/KDE: improvement, click-to-open alongside x-kde-urls
- Linux Wayland/GNOME: fixed, click now opens the saved file
The previous commit added qApp->exit() in onActionInvoked to exit the
CLI process after the user clicks a notification. But the daemon also
takes screenshots (e.g. via tray icon) and sends notifications with
the same code path — calling qApp->exit() there kills the daemon.

Guard the exit with a static flag (s_exitOnLastAction) that is only
set to true in the CLI flow (requestCaptureAndWait). The daemon never
sets it, so clicking notifications opened from daemon-triggered
screenshots opens the file without terminating the daemon.
The Flatpak D-Bus proxy only routes ActionInvoked signals to the
sandbox that created the notification. When the CLI sends the
notification and exits, the daemon never receives the click signal.

This can be fixed by having the CLI suppress its own notification
and sending the save path to the daemon via D-Bus. The daemon
sends the notification itself, receives the click, and opens
the file. The CLI exits immediately, allowing successive
screenshots without a 10-second wait.
The notification delegation code uses QDBusConnection and QDBusMessage
which are unavailable on Windows and macOS. Wrap it with the existing
platform guard so non-Linux builds fall back to the simple exit path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant