diff --git a/README.md b/README.md index ddbcf18..b020871 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Activate wayland overlay as described in [README](https://github.com/bsd-ac/wayl ### Optional Dependencies - hyprpicker (to freeze the screen contents with the `--freeze` flag) +- xdg-utils (to open image file in the default image viewer in response to a configured notification action.) ### Manual diff --git a/hyprshot b/hyprshot index 0fb976f..5660ab1 100755 --- a/hyprshot +++ b/hyprshot @@ -54,12 +54,19 @@ function send_notification() { return 0 fi - local message=$([ $CLIPBOARD -eq 1 ] && \ - echo "Image copied to the clipboard" || \ + local message=$([ $CLIPBOARD -eq 1 ] && + echo "Image copied to the clipboard" || echo "Image saved in ${1} and copied to the clipboard.") - notify-send "Screenshot saved" \ - "${message}" \ - -t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot + + action_option="" + command -v xdg-open &>/dev/null && action_option="--action=open_file=Open" + + local action=$(notify-send "Screenshot saved" \ + "${message}" \ + -t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot \ + "$action_option") + + [[ $action_option != "" && $action == "open_file" ]] && xdg-open "$1" & } function trim() {