Fixing proper main-monitor screenshot

This commit is contained in:
Siina Mashek 2022-03-13 03:08:15 +02:00
parent 49c32122ef
commit 42c3365a1b

View File

@ -19,33 +19,42 @@
# TODO: Autodetect mpv and boop.sh to make them optional # TODO: Autodetect mpv and boop.sh to make them optional
# TODO: Figure out how to capture a specific monitor, not just main # TODO: Figure out how to capture a specific monitor, not just main
screendir="$HOME/Screenshots" source ~/.profile # Workaround
# Checks for SCREENSHOT_DIR environment variable
#screendir="$HOME/Screenshots"
sound="$HOME/Projects/local-bin/sounds/shutter.ogg" sound="$HOME/Projects/local-bin/sounds/shutter.ogg"
filename="$(date +'%Y%m%d_%H%M%S').png" filename="$(date +'%Y%m%d_%H%M%S').png"
resolution="1920x1080" resolution="1920x1080"
# For desktop multi-monitor # For desktop multi-monitor
if [[ ${2} == "-d" ]]; then if [[ ${1} == "-d" ]]; then
resolution="1920x1590" resolution="1920x1590"
fi fi
args="-m 9 -u" args="-m 9 -u"
cd $screendir
if [[ ! -d $SCREENSHOT_DIR ]]; then
mkdir -p $SCREENSHOT_DIR
fi
echo "Entering $SCREENSHOT_DIR"
cd $SCREENSHOT_DIR
if [[ ${1} == "-m" ]]; then if [[ ${1} == "-m" ]]; then
args="${args} -g ${resolution}+0+0" # for standard 1080p single monitor args="${args} -g ${resolution}+0+510" # for standard 1080p single monitor
else else
args="${args} ${1}" args="${args}"
fi fi
maim -B $args $filename > /dev/null 2>&1 maim -B $args $filename > /dev/null 2>&1
# cleanup for my dual-monitor setup # cleanup for my dual-monitor setup
if [[ ${2} == "-d" ]]; then if [[ ${1} == "-d" ]]; then
magick convert $filename -trim +repage $screendir/$filename magick convert $filename -trim +repage $SCREENSHOT_DIR/$filename
fi fi
mpv $sound mpv $sound
$HOME/.local/bin/boop.sh "$screendir/$filename" $HOME/.local/bin/boop.sh "$SCREENSHOT_DIR/$filename"