~/.local/bin/scr
#!/usr/bin/env bash
# Take a screenshot and display a notification.
# Created by Dylan Araps.
# Modifyed by Nietz
# Depends on: imagemagick, date, libnotify (patched with id support)
DUNST_APPNAME="Screenshot"
DUNST_SUMMARY_STRING="Desktop shot done"
TEMP_SHOT="/tmp/shot.png"
# Screenshot directory
scr_dir="${HOME}/screenshot/desktop"
mkdir -p "$scr_dir" || { printf "%s\n" "Error: Couldn't create screenshot directory"; exit; }
# Use printf to store the current date/time as variables.
printf -v date "%(%F)T"
printf -v time "%(%I:%M:%S)T"
format="png"
#format="jpg"
# Create current date format.
mkdir -p "${scr_dir}/${date}"
# Name the screenshot
scr="shot"
function prepare () {
paplay /usr/share/sounds/freedesktop/stereo/camera-shutter.oga
}
function final () {
convert -resize 250x "$scr" "$TEMP_SHOT"
# Send the notification
#notify-send -t 5000 -i "/tmp/shot.png" "Saved screenshot as ${scr/*\/}"
#notify-send -t 5000 -i "/tmp/shot.png" "Shot Done"
dunstify -p --appname=$DUNST_APPNAME -i "$TEMP_SHOT" "$DUNST_SUMMARY_STRING
Saved screentshot as" \
" Path: "$scr""
}
function screenshot_desktop () {
prepare
scr="${scr_dir}/${date}/${date}-${time}_3840x1080_Desktop.${format}"
import -window root "$scr"
final
}
function screenshot_left () {
prepare
scr="${scr_dir}/${date}/${date}-${time}_1920x1080_Left.${format}"
import -window root -gravity west -crop 1920x1080+0+0 "$scr"
final
}
function screenshot_right () {
prepare
scr="${scr_dir}/${date}/${date}-${time}_1920x1080_Right.${format}"
import -window root -gravity west -crop 1920x1080+1920+0 "$scr"
final
}
# Take the screenshot Args
case $1 in
l) screenshot_left ;;
r) screenshot_right ;;
5) sleep 5; screenshot_desktop ;;
3) sleep 3; screenshot_desktop ;;
1) sleep 1; screenshot_desktop ;;
*) screenshot_desktop ;;
esac