Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grimshot: add notify action to open file or directory #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion grimshot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +85 to +89
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ "$action" = "file" ]; then
xdg-open "$FILE"
elif [ "$action" = "dir" ]; then
xdg-open "$(dirname "$FILE")"
fi
if [ "$action" = "dir" ]; then
xdg-open "$(dirname "$FILE")"
else
xdg-open "$FILE"
fi

With notification programs like mako, you can't select the action. So make opening file as default would be better.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this suggestion makes it always open the file, ignore that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an idea for this?

fi
}
notifyOk() {
[ "$NOTIFY" = "no" ] && return
Expand Down Expand Up @@ -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)
Expand Down
Loading