grimshot: Add a separate flag for notifications
Make notifications a separate flag. Personally, I trigger grimshot myself most of the time (via sway bindsym) rather than by some external means, so I don't need to be notified of it happening. However, keep a flag with this functionality there for those scenarios there it's necessary to inform the user. Also print the file location when saving the screenshot.
This commit is contained in:
parent
1191a41fb2
commit
b10b6b552b
|
@ -26,13 +26,20 @@ getTargetDirectory() {
|
||||||
echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}
|
echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ $1 == "--notify" ]; then
|
||||||
|
NOTIFY=yes
|
||||||
|
shift 1
|
||||||
|
else
|
||||||
|
NOTIFY=no
|
||||||
|
fi
|
||||||
|
|
||||||
ACTION=${1:-usage}
|
ACTION=${1:-usage}
|
||||||
SUBJECT=${2:-screen}
|
SUBJECT=${2:-screen}
|
||||||
FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
|
FILE=${3:-$(getTargetDirectory)/$(date -Ins).png}
|
||||||
|
|
||||||
if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
|
if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " grimshot (copy|save) [active|screen|output|area|window] [FILE]"
|
echo " grimshot [--notify] (copy|save) [active|screen|output|area|window] [FILE]"
|
||||||
echo " grimshot check"
|
echo " grimshot check"
|
||||||
echo " grimshot usage"
|
echo " grimshot usage"
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -55,14 +62,20 @@ notify() {
|
||||||
notify-send -t 3000 -a grimshot "$@"
|
notify-send -t 3000 -a grimshot "$@"
|
||||||
}
|
}
|
||||||
notifyOk() {
|
notifyOk() {
|
||||||
|
[ $NOTIFY = "no" ] && return
|
||||||
|
|
||||||
TITLE=${2:-"Screenshot"}
|
TITLE=${2:-"Screenshot"}
|
||||||
MESSAGE=${1:-"OK"}
|
MESSAGE=${1:-"OK"}
|
||||||
notify "$TITLE" "$MESSAGE"
|
notify "$TITLE" "$MESSAGE"
|
||||||
}
|
}
|
||||||
notifyError() {
|
notifyError() {
|
||||||
|
if [ $NOTIFY = "yes" ]; then
|
||||||
TITLE=${2:-"Screenshot"}
|
TITLE=${2:-"Screenshot"}
|
||||||
MESSAGE=${1:-"Error taking screenshot with grim"}
|
MESSAGE=${1:-"Error taking screenshot with grim"}
|
||||||
notify -u critical "$TITLE" "$MESSAGE"
|
notify -u critical "$TITLE" "$MESSAGE"
|
||||||
|
else
|
||||||
|
echo $1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
|
@ -137,6 +150,7 @@ else
|
||||||
TITLE="Screenshot of $SUBJECT"
|
TITLE="Screenshot of $SUBJECT"
|
||||||
MESSAGE=$(basename "$FILE")
|
MESSAGE=$(basename "$FILE")
|
||||||
notifyOk "$MESSAGE" "$TITLE"
|
notifyOk "$MESSAGE" "$TITLE"
|
||||||
|
echo $FILE
|
||||||
else
|
else
|
||||||
notifyError "Error taking screenshot with grim"
|
notifyError "Error taking screenshot with grim"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue