local-bin/common/scrot.sh

52 lines
1.2 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:
# - maim: takes the screenshot
# - imagemagick: for custom resolution sizes
# - mpv: plays audio file upon completion
# - boop.sh: uploads screenshot to boop.icu
#
# Example global keybinds:
#
# TYPE CMD KEYBIND
#
# Fullscreen scrot.sh Print
# Main monitor scrot.sh -m Meta+Ctrl+Print
# Active window/Selct scrot.sh -s Meta+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/Screenshots"
2020-12-20 20:30:34 +02:00
sound="$HOME/Projects/local-bin/sounds/shutter.ogg"
filename="$(date +'%Y%m%d_%H%M%S').png"
resolution="1920x1080"
# For desktop multi-monitor
if [[ ${2} == "-d" ]]; then
resolution="1920x1590"
fi
args="-m 9 -u"
2020-07-01 13:42:14 +03:00
cd $screendir
if [[ ${1} == "-m" ]]; then
args="${args} -g ${resolution}+0+0" # for standard 1080p single monitor
else
args="${args} ${1}"
2020-07-01 13:42:14 +03:00
fi
2020-12-20 20:30:34 +02:00
maim -B $args $filename > /dev/null 2>&1
# cleanup for my dual-monitor setup
if [[ ${2} == "-d" ]]; then
magick convert $filename -trim +repage $screendir/$filename
fi
mpv $sound
$HOME/.local/bin/boop.sh "$screendir/$filename"
2020-07-01 13:42:14 +03:00