#!/bin/sh

if [ $1 = "clip" ]; then
    if grim -g "$(slurp)" - | wl-copy; then
        notify-send "screenshot" "Saved to clipboard"
    else
        notify-send "screenshot" "Canceled"
    fi
else
    filename="$HOME/Downloads/$(echo '' | bemenu --ifne -p "Enter filename:")"
    filename_ext="${filename%.png}.png"
    if grim -g "$(slurp)" "$filename_ext"; then
        notify-send "screenshot" "Saved as $filename_ext"
    else
        notify-send "screenshot" "Canceled"
    fi
fi
