From e0110f808b2d90d8324d3cc07a5e8b557ea7c4e2 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Wed, 4 Sep 2024 09:31:28 -0700 Subject: [PATCH] grimshot: add notify action to open file or directory If grimshot is called with --notify and the file was saved to disk, provide two notification actions to open the file or the containing directory. Use xdg-open to open the file/directory, so also add that to the check command. --- grimshot | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grimshot b/grimshot index 5aaf479..dc1c619 100755 --- a/grimshot +++ b/grimshot @@ -78,7 +78,16 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "savecop fi notify() { - notify-send -t 3000 -a grimshot "$@" + if [ "$ACTION" = "copy" ]; then + notify-send -t 3000 -a grimshot "$@" + else + action=$(notify-send -t 3000 -a grimshot --action=file='Open File' --action=dir='Open Directory' "$@") + if [ "$action" = "file" ]; then + xdg-open "$FILE" + elif [ "$action" = "dir" ]; then + xdg-open "$(dirname "$FILE")" + fi + fi } notifyOk() { [ "$NOTIFY" = "no" ] && return @@ -139,6 +148,7 @@ if [ "$ACTION" = "check" ] ; then check wl-copy check jq check notify-send + check xdg-open exit elif [ "$SUBJECT" = "area" ] ; then GEOM=$(slurp -d)