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
|
|
|
# - boop.sh: uploads screenshot to boop.icu
|
2022-03-13 08:27:19 +02:00
|
|
|
# - Checks for SCREENSHOT_DIR environment variable
|
2020-11-11 02:49:54 +02:00
|
|
|
#
|
2022-03-13 08:32:10 +02:00
|
|
|
# Example global keybinds can be found in scrotsh.khotkeys
|
2020-11-11 02:49:54 +02:00
|
|
|
#
|
2022-03-13 08:27:19 +02:00
|
|
|
source ~/.profile # Workaround to avoid using /bin/bash
|
2022-03-13 03:08:15 +02:00
|
|
|
|
2022-03-13 08:27:19 +02:00
|
|
|
# Edit these to fit setup
|
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"
|
2022-10-10 13:41:07 +03:00
|
|
|
main_res="1920x1080+0+529"
|
2022-03-13 08:27:19 +02:00
|
|
|
secondary_res="1080x1920+1920+0"
|
2022-03-13 03:08:15 +02:00
|
|
|
|
2022-03-13 08:27:19 +02:00
|
|
|
# Ensure screenshot directory is there so the script will work
|
2022-03-13 03:08:15 +02:00
|
|
|
if [[ ! -d $SCREENSHOT_DIR ]]; then
|
|
|
|
mkdir -p $SCREENSHOT_DIR
|
|
|
|
fi
|
|
|
|
cd $SCREENSHOT_DIR
|
2020-11-11 02:49:54 +02:00
|
|
|
|
2022-03-13 08:27:19 +02:00
|
|
|
# Setup is 1920x1590: main = 1920x1080; secondary = 1080x1920
|
|
|
|
if [[ ${1} == "--main" ]]; then
|
|
|
|
resolution=$main_res
|
|
|
|
elif [[ ${1} == "--secondary" ]]; then
|
|
|
|
resolution=$secondary_res
|
2020-07-01 13:42:14 +03:00
|
|
|
fi
|
2020-12-20 20:30:34 +02:00
|
|
|
|
2022-03-13 08:27:19 +02:00
|
|
|
# Set maim arguments based on command arguments
|
|
|
|
args="-m 9 -u"
|
|
|
|
if [[ ${1} == "--select" ]]; then
|
|
|
|
args="$args ${1}"
|
|
|
|
elif [[ ${1} == "--main" || ${1} == "--secondary" ]]; then
|
|
|
|
args="$args -g $resolution"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Take the screenshot with maim
|
2022-01-08 18:52:51 +02:00
|
|
|
maim -B $args $filename > /dev/null 2>&1
|
|
|
|
|
2022-03-13 08:27:19 +02:00
|
|
|
# cleanup for main monitor
|
|
|
|
if [[ ${1} == "--main" ]]; then
|
2022-03-13 03:08:15 +02:00
|
|
|
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
|
|
|
|
2022-07-05 09:49:39 +03:00
|
|
|
# Play sound if ffplay is available
|
|
|
|
if [[ -n "$(which ffplay)" ]]; then
|
|
|
|
ffplay $sound -nodisp -autoexit -loglevel error
|
2022-03-13 08:27:19 +02:00
|
|
|
fi
|
2020-07-01 13:42:14 +03:00
|
|
|
|
2022-03-13 08:27:19 +02:00
|
|
|
# Upload to boop if boop.sh is available
|
|
|
|
if [[ -n "$(which boop.sh)" ]]; then
|
|
|
|
boop.sh "$SCREENSHOT_DIR/$filename"
|
|
|
|
fi
|