Skip to content

Commit e0110f8

Browse files
committed
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.
1 parent 2d6e5a9 commit e0110f8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

grimshot

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,16 @@ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "savecop
7878
fi
7979

8080
notify() {
81-
notify-send -t 3000 -a grimshot "$@"
81+
if [ "$ACTION" = "copy" ]; then
82+
notify-send -t 3000 -a grimshot "$@"
83+
else
84+
action=$(notify-send -t 3000 -a grimshot --action=file='Open File' --action=dir='Open Directory' "$@")
85+
if [ "$action" = "file" ]; then
86+
xdg-open "$FILE"
87+
elif [ "$action" = "dir" ]; then
88+
xdg-open "$(dirname "$FILE")"
89+
fi
90+
fi
8291
}
8392
notifyOk() {
8493
[ "$NOTIFY" = "no" ] && return
@@ -139,6 +148,7 @@ if [ "$ACTION" = "check" ] ; then
139148
check wl-copy
140149
check jq
141150
check notify-send
151+
check xdg-open
142152
exit
143153
elif [ "$SUBJECT" = "area" ] ; then
144154
GEOM=$(slurp -d)

0 commit comments

Comments
 (0)