Skip to content

Commit

Permalink
Close #42
Browse files Browse the repository at this point in the history
  • Loading branch information
ProMix0 committed Jun 2, 2024
1 parent 840b2a1 commit 8ef70db
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions hyprshot
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function send_notification() {
return 0
fi

local message=$([ $CLIPBOARD -eq 1 ] && \
local message=$([ -z "$1" ] && \
echo "Image copied to the clipboard" || \
echo "Image saved in <i>${1}</i> and copied to the clipboard.")
notify-send "Screenshot saved" \
Expand Down Expand Up @@ -105,23 +105,30 @@ function save_geometry() {
local geometry="${1}"
local output=""

if [ $RAW -eq 1 ]; then
grim -g "${geometry}" -
return 0
fi
local SCREEN_COMMAND='grim -g '"'${geometry}'"' -'

if [ $CLIPBOARD -eq 0 ]; then
mkdir -p "$SAVEDIR"
grim -g "${geometry}" "$SAVE_FULLPATH"
output="$SAVE_FULLPATH"
wl-copy < "$output"
[ -z "$COMMAND" ] || {
"$COMMAND" "$output"
}
else
wl-copy < <(grim -g "${geometry}" -)
SCREEN_COMMAND="$SCREEN_COMMAND"' | tee '"'$SAVE_FULLPATH'"
fi

SCREEN_COMMAND="$SCREEN_COMMAND"' | tee >(wl-copy)'

if [ ! -z "$COMMAND" ]; then
SCREEN_COMMAND="$SCREEN_COMMAND"'| tee >('"$COMMAND"
if [ ! -z "$output" ]; then
SCREEN_COMMAND="$SCREEN_COMMAND"' '"$output"
fi
SCREEN_COMMAND="$SCREEN_COMMAND"')'
fi

if [ $RAW -eq 0 ]; then
SCREEN_COMMAND="$SCREEN_COMMAND"' > /dev/null'
fi

Print "Executing: %s\n" "$SCREEN_COMMAND"
eval "$SCREEN_COMMAND"

send_notification $output
}

Expand Down

0 comments on commit 8ef70db

Please sign in to comment.