local-bin/bin/scrot.sh

40 lines
1.0 KiB
Bash
Raw Normal View History

2020-07-01 13:42:14 +03:00
#!/bin/sh
#
# Siina's bootleg screenshot capturer for use with global keybinds
#
# Requires:
# - scrot: takes the screenshot
# - convert: from imagemagick, used to crop single-monitor scrot
# - mpv: plays audio file upon completion
# - boop.sh: uploads screenshot to boop.icu
#
# Example global keybinds:
#
# TYPE CMD KEYBIND
#
# Fullscreen scrot.sh Print
# Current monitor scrot.sh -a Meta+Shift+Print
# Active window scrot.sh -u Meta+Print
# Region scrot.sh -s Meta+Ctrl+Print
#
# TODO: Autodetect mpv and boop.sh to make them optional
# TODO: Figure out how to capture a specific monitor, not just main
2020-07-01 13:42:14 +03:00
screendir="$HOME/Nextcloud/Screenshots/"
sound="${HOME}/src/local-bin/sounds/shutter.ogg"
filename="$(date +'%Y%m%d_%H%M%S').png"
resolution="1920x1080"
2020-07-01 13:42:14 +03:00
cd $screendir
if [[ ${1} == "-a" ]]; then
scrot $filename
# Scrot doesn't capture per monitor so we're doing some jiggery
convert -crop 1920x1080\! $filename $filename
else
scrot $1 $filename
2020-07-01 13:42:14 +03:00
fi
mpv $sound
$HOME/.local/bin/boop.sh "$screendir$filename"
2020-07-01 13:42:14 +03:00