#!/bin/sh # # Siina's bootleg screenshot capturer for use with global keybinds # # Requires: # - maim: takes the screenshot # - imagemagick: for custom resolution sizes # - boop.sh: uploads screenshot to boop.icu # - Checks for SCREENSHOT_DIR environment variable # # Example global keybinds can be found in scrotsh.khotkeys # 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+521" 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 ffplay is available if [[ -n "$(which ffplay)" ]]; then ffplay $sound -nodisp -autoexit -loglevel error fi # Upload to boop if boop.sh is available if [[ -n "$(which boop.sh)" ]]; then boop.sh "$SCREENSHOT_DIR/$filename" fi