#!/bin/sh # This script uses `dmenu` to display a list of screenshoting options. # After you choose one, a screenshot of the appropriate area is taken # using `scrot` after the specified amount of time. # It takes 1 argument, the directory where screenshots will be saved. # region: you select the region with your mouse. # all: all screens. # first: first screen (on my setup). # second: second screen (on my setup). # third: third screen (on my setup). # window: currently focused window. # Because they all differ in first letter, # you'll only need to enter 1 character to choose them. chosen=$(printf "region\nall\nfirst\nsecond\nthird\nwindow\nfirst f2s\nsecond s2s\nthird t2s\nall a2s\nregion r2s\nwindow w2s\nfirst f5s\nsecond s5s\nthird t5s\nall a5s\nregion r5s\nwindow w5s" | dmenu -fn 'monospace:size=16') if ! [[ -z $chosen ]]; then # first word modename=$(echo $chosen | awk '{print $1;}') # second to last character delay=$(echo -n "$chosen" | tail -c 2 | head -c 1) if [ "$delay" == "2" ] || [ "$delay" == "5" ]; then d="-d $delay" else if [ "$modename" == "region" ]; then d="-d 0.1" delay="0.1" else d="" delay="0" fi fi case "$modename" in "region") mode="-s" ;; "window") mode="-u" ;; "all") mode="" ;; "first") mode="-a 0,0,1920,1080" sleep $delay d="" ;; "second") mode="-a 1920,0,1920,1080" sleep $delay d="" ;; "third") mode="-a 3840,0,1080,1920" sleep $delay d="" ;; esac if (( $# > 1 )); then scrot $d $mode 'Screenshot_%Y-%m-%d_%H-%M-%S.png' -e 'cp $f ~/.s.png; mv $f '"$1" elif (( $# > 0 )); then scrot $d $mode 'Screenshot_%Y-%m-%d_%H-%M-%S.png' -e 'mv $f '"$1" else scrot $d $mode 'Screenshot_%Y-%m-%d_%H-%M-%S.png' fi fi