#!/bin/sh img_path=~/Pictures/Screenshots/"$(date +%Y-%m-%d_%H-%m-%s)".png current_screen() { MONITORS=$(xrandr | grep -o '[0-9]*x[0-9]*[+-][0-9]*[+-][0-9]*') for mon in ${MONITORS}; do # Parse the geometry of the monitor MONW=$(echo "${mon}" | awk -F "[x+]" '{print $1}') MONH=$(echo "${mon}" | awk -F "[x+]" '{print $2}') MONX=$(echo "${mon}" | awk -F "[x+]" '{print $3}') MONY=$(echo "${mon}" | awk -F "[x+]" '{print $4}') done } case $1 in selected-region) # Take a screenshot of the selected region maim -s "${img_path}" ;; selected-window) # Take a screenshot of the selected window maim -i $(xdotool getactivewindow) "${img_path}" ;; save-to-clipboard) # Take a screenshot and save it to the clipboard current_screen maim -g "${MONW}x${MONH}+${MONX}+${MONY}" | xclip -selection clipboard -t image/png exit 0 ;; *) # Take a screenshot of the currently focused output and save it into screenshots current_screen maim -g "${MONW}x${MONH}+${MONX}+${MONY}" "${img_path}" exit 0 ;; esac