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

Allow Opening File Folder When Clicking Notification #126

Merged
merged 4 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

grimblast: allow decimals for --wait

### 2025-01-21

grimblast: allow opening file directory when clicking on notification when --openfile is set

### 2024-12-01

grimblast: fix window selection on fullscreen
Expand Down
27 changes: 25 additions & 2 deletions grimblast/grimblast
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ env_editor_confirm() {
}

NOTIFY=no
OPENFILE_NOTIFICATION=no
CURSOR=
FREEZE=
WAIT=no
Expand All @@ -64,6 +65,10 @@ while [ $# -gt 0 ]; do
NOTIFY=yes
shift # past argument
;;
-o | --openfile)
OPENFILE_NOTIFICATION=yes
shift # past argument
;;
-c | --cursor)
CURSOR=yes
shift # past argument
Expand Down Expand Up @@ -104,7 +109,7 @@ FILE_EDITOR=${3:-$(tmp_editor_directory)/$(date -Ins).png}

if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "edit" ] && [ "$ACTION" != "copysave" ] && [ "$ACTION" != "check" ]; then
echo "Usage:"
echo " grimblast [--notify] [--cursor] [--freeze] [--wait N] [--scale <scale>] (copy|save|copysave|edit) [active|screen|output|area] [FILE|-]"
echo " grimblast [--notify] [--openfile] [--cursor] [--freeze] [--wait N] [--scale <scale>] (copy|save|copysave|edit) [active|screen|output|area] [FILE|-]"
echo " grimblast check"
echo " grimblast usage"
echo ""
Expand Down Expand Up @@ -134,6 +139,23 @@ notifyOk() {
notify "$@"
}

notifyOpen() {
if [ "$OPENFILE_NOTIFICATION" = "no" ]; then
notifyOk
else
outt=$(notify-send -A "default=open_folder" -a grimblast "$@")
if [ "$outt" == "default" ]; then
# this does not work for filenames with commas in them
if dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"$4" string:""; then
:
else
notify-send -t 3000 -a grimblast "Error displaying folder with dbus-send";
echo "Displayed: Error displaying folder with dbus-send";
fi
fi
fi
}

notifyError() {
if [ $NOTIFY = "yes" ]; then
TITLE=${2:-"Screenshot"}
Expand Down Expand Up @@ -248,7 +270,8 @@ elif [ "$ACTION" = "save" ]; then
if takeScreenshot "$FILE" "$GEOM" "$OUTPUT"; then
TITLE="Screenshot of $SUBJECT"
MESSAGE=$(basename "$FILE")
notifyOk "$TITLE" "$MESSAGE" -i "$FILE"
killHyprpicker
notifyOpen "$TITLE" "$MESSAGE" -i "$FILE"
echo "$FILE"
else
notifyError "Error taking screenshot with grim"
Expand Down
4 changes: 4 additions & 0 deletions grimblast/grimblast.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ grimblast - a helper for screenshots within hyprland
*--notify*
Show notifications to the user that a screenshot has been taken.

*--openfile*
Uses dbus to display the folder containing the file when interacting with the
notification, only works with --notify

*--cursor*
Include cursors in the screenshot.

Expand Down