2020-07-01 13:42:14 +03:00
|
|
|
#!/bin/sh
|
2020-11-11 02:49:54 +02:00
|
|
|
#
|
|
|
|
# Siina's bootleg screenshot capturer for use with global keybinds
|
|
|
|
#
|
|
|
|
# Requires:
|
2020-11-21 10:17:18 +02:00
|
|
|
# - maim: takes the screenshot
|
2022-01-08 18:52:51 +02:00
|
|
|
# - imagemagick: for custom resolution sizes
|
2020-11-11 02:49:54 +02:00
|
|
|
# - mpv: plays audio file upon completion
|
|
|
|
# - boop.sh: uploads screenshot to boop.icu
|
|
|
|
#
|
|
|
|
# Example global keybinds:
|
|
|
|
#
|
|
|
|
# TYPE CMD KEYBIND
|
|
|
|
#
|
|
|
|
# Fullscreen scrot.sh Print
|
2022-01-08 18:52:51 +02:00
|
|
|
# Main monitor scrot.sh -m Meta+Ctrl+Print
|
2020-11-21 10:17:18 +02:00
|
|
|
# Active window/Selct scrot.sh -s Meta+Print
|
2020-11-11 02:49:54 +02:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
2022-03-13 03:08:15 +02:00
|
|
|
source ~/.profile # Workaround
|
|
|
|
|
|
|
|
# Checks for SCREENSHOT_DIR environment variable
|
|
|
|
#screendir="$HOME/Screenshots"
|
2020-12-20 20:30:34 +02:00
|
|
|
sound="$HOME/Projects/local-bin/sounds/shutter.ogg"
|
2020-11-11 02:49:54 +02:00
|
|
|
filename="$(date +'%Y%m%d_%H%M%S').png"
|
|
|
|
resolution="1920x1080"
|
2022-01-08 18:52:51 +02:00
|
|
|
|
|
|
|
# For desktop multi-monitor
|
2022-03-13 03:08:15 +02:00
|
|
|
if [[ ${1} == "-d" ]]; then
|
2022-01-08 18:52:51 +02:00
|
|
|
resolution="1920x1590"
|
|
|
|
fi
|
|
|
|
|
2020-11-21 10:17:18 +02:00
|
|
|
args="-m 9 -u"
|
2020-07-01 13:42:14 +03:00
|
|
|
|
2022-03-13 03:08:15 +02:00
|
|
|
|
|
|
|
if [[ ! -d $SCREENSHOT_DIR ]]; then
|
|
|
|
mkdir -p $SCREENSHOT_DIR
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Entering $SCREENSHOT_DIR"
|
|
|
|
cd $SCREENSHOT_DIR
|
2020-11-11 02:49:54 +02:00
|
|
|
|
2022-01-08 18:52:51 +02:00
|
|
|
if [[ ${1} == "-m" ]]; then
|
2022-03-13 03:08:15 +02:00
|
|
|
args="${args} -g ${resolution}+0+510" # for standard 1080p single monitor
|
2020-11-11 02:49:54 +02:00
|
|
|
else
|
2022-03-13 03:08:15 +02:00
|
|
|
args="${args}"
|
2020-07-01 13:42:14 +03:00
|
|
|
fi
|
2020-12-20 20:30:34 +02:00
|
|
|
|
2022-01-08 18:52:51 +02:00
|
|
|
maim -B $args $filename > /dev/null 2>&1
|
|
|
|
|
|
|
|
# cleanup for my dual-monitor setup
|
2022-03-13 03:08:15 +02:00
|
|
|
if [[ ${1} == "-d" ]]; then
|
|
|
|
magick convert $filename -trim +repage $SCREENSHOT_DIR/$filename
|
2022-01-08 18:52:51 +02:00
|
|
|
fi
|
2020-11-21 10:17:18 +02:00
|
|
|
|
2020-11-13 05:57:04 +02:00
|
|
|
mpv $sound
|
2022-03-13 03:08:15 +02:00
|
|
|
$HOME/.local/bin/boop.sh "$SCREENSHOT_DIR/$filename"
|
2020-07-01 13:42:14 +03:00
|
|
|
|