Skip to content
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
43 changes: 33 additions & 10 deletions hyprshot
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ function send_notification() {
return 0
fi

local message=$([ $CLIPBOARD -eq 1 ] && \
echo "Image copied to the clipboard" || \
echo "Image saved in <i>${1}</i> and copied to the clipboard.")
local message
if [ $CLIPBOARD -eq 1 ]; then
message="Image copied to the clipboard."
else
message="Image saved in <i>${1}</i> and copied to the clipboard."
fi

notify-send "Screenshot saved" \
"${message}" \
-t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot
}


function trim() {
Print "Geometry: %s\n" "${1}"
local geometry="${1}"
Expand Down Expand Up @@ -108,6 +113,13 @@ function trim() {

function save_geometry() {
local geometry="${1}"

# Check for empty geometry
if [ -z "$geometry" ]; then
Print "Selection canceled or invalid. Exiting.\n"
return 1
fi

local output=""

if [ $RAW -eq 1 ]; then
Expand All @@ -130,6 +142,7 @@ function save_geometry() {
send_notification $output
}


function checkRunning() {
sleep 1
while [[ 1 == 1 ]]; do
Expand All @@ -147,34 +160,44 @@ function begin_grab() {
HYPRPICKER_PID=$!
fi
local option=$1
local geometry=""

case $option in
output)
if [ $CURRENT -eq 1 ]; then
local geometry=`grab_active_output`
geometry=`grab_active_output`
elif [ -z $SELECTED_MONITOR ]; then
local geometry=`grab_output`
geometry=`grab_output`
else
local geometry=`grab_selected_output $SELECTED_MONITOR`
geometry=`grab_selected_output $SELECTED_MONITOR`
fi
;;
region)
local geometry=`grab_region`
geometry=`grab_region`
;;
window)
if [ $CURRENT -eq 1 ]; then
local geometry=`grab_active_window`
geometry=`grab_active_window`
else
local geometry=`grab_window`
geometry=`grab_window`
fi
geometry=`trim "${geometry}"`
geometry=`trim "${geometry}"`
;;
esac

if [ -z "$geometry" ]; then
Print "No geometry selected. Cancelling.\n"
return 1
fi

if [ ${DELAY} -gt 0 ] 2>/dev/null; then
sleep ${DELAY}
fi

save_geometry "${geometry}"
}


function grab_output() {
slurp -or
}
Expand Down