70 lines
1.8 KiB
Bash
Executable File
70 lines
1.8 KiB
Bash
Executable File
#!/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
|
|
# - Checks for SCREENSHOT_DIR environment variable
|
|
#
|
|
# Example global keybinds:
|
|
#
|
|
# TYPE CMD KEYBIND
|
|
#
|
|
# Fullscreen scrot.sh Print
|
|
# Main monitor scrot.sh --main Meta+Ctrl+Print
|
|
# Active window/Select scrot.sh --select Meta+Print
|
|
#
|
|
# TODO: Figure out how to capture a specific monitor, not just main
|
|
# TODO: Remove hardcoded shutter sound path
|
|
|
|
source ~/.profile # Workaround to avoid using /bin/bash
|
|
|
|
# Edit these to fit setup
|
|
sound="$HOME/Projects/local-bin/sounds/shutter.ogg"
|
|
filename="$(date +'%Y%m%d_%H%M%S').png"
|
|
main_res="1920x1080+0+510"
|
|
secondary_res="1080x1920+1920+0"
|
|
|
|
# Ensure screenshot directory is there so the script will work
|
|
if [[ ! -d $SCREENSHOT_DIR ]]; then
|
|
mkdir -p $SCREENSHOT_DIR
|
|
fi
|
|
cd $SCREENSHOT_DIR
|
|
|
|
# Setup is 1920x1590: main = 1920x1080; secondary = 1080x1920
|
|
if [[ ${1} == "--main" ]]; then
|
|
resolution=$main_res
|
|
elif [[ ${1} == "--secondary" ]]; then
|
|
resolution=$secondary_res
|
|
fi
|
|
|
|
# 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
|
|
maim -B $args $filename > /dev/null 2>&1
|
|
|
|
# cleanup for main monitor
|
|
if [[ ${1} == "--main" ]]; then
|
|
magick convert $filename -trim +repage $SCREENSHOT_DIR/$filename
|
|
fi
|
|
|
|
# Play sound if mpv is available
|
|
if [[ -n "$(which mpv)" ]]; then
|
|
mpv $sound
|
|
fi
|
|
|
|
# Upload to boop if boop.sh is available
|
|
if [[ -n "$(which boop.sh)" ]]; then
|
|
boop.sh "$SCREENSHOT_DIR/$filename"
|
|
fi
|