From db695343aaed5403cd190f92c63feb13f4769518 Mon Sep 17 00:00:00 2001 From: geekmdtravis Date: Tue, 9 Sep 2025 00:35:26 -0700 Subject: [PATCH] On branch notify-icon-fix Changes to be committed: modified: hyprshot Addressed the following issues: * Allow the user to leverage their system settings for the timeout in `notify-send`. Previously, the timeout was hardcoded to 5000 ms, which is quite long for an information message. * Fix the icon for the notifications. The information icon was not displayed when a screenshot was taken since the priority of the message was not given as an argument to `notify-send`. By adding the 'dialog-information' priority, the icon is displayed conditionally when the screenshot is taken and not saved to a file. When saved to a file, the screenshot is used as the icon. * Improved readability of the notifications title and body text. The name of the tool, Hyprshot, is now displayed in the title, and the body includes clarifying text indicating the screenshot was taken rather than the more generic verbiage about an image being saved. --- hyprshot | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/hyprshot b/hyprshot index 0fb976f..a68c5fe 100755 --- a/hyprshot +++ b/hyprshot @@ -25,7 +25,7 @@ Options: -d, --debug print debug information -s, --silent don't send notification when screenshot is saved -r, --raw output raw image data to stdout - -t, --notif-timeout notification timeout in milliseconds (default 5000) + -t, --notif-timeout notification timeout in milliseconds (default is 5000, system setting if 0) --clipboard-only copy screenshot to clipboard and don't save image in disk -- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage @@ -55,11 +55,25 @@ function send_notification() { fi 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" \ + echo "Screenshot copied to the clipboard." || \ + echo "Screenshot saved to ${1} and copied to the clipboard.") + + local icon + if [ $CLIPBOARD -eq 1 ]; then + icon="dialog-information" + else + icon="${1}" + fi + + if [ $NOTIF_TIMEOUT -gt 0 ]; then + notify-send -u low "Hyprshot: Screenshot saved" \ "${message}" \ - -t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot + -t "$NOTIF_TIMEOUT" -i "$icon" -a Hyprshot + else + notify-send -u low -i dialog-information "Hyprshot: Screenshot saved" \ + "${message}" \ + -i "$icon" -a Hyprshot + fi } function trim() {