diff options
Diffstat (limited to '.local/bin/screenshot.sh')
-rwxr-xr-x | .local/bin/screenshot.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.local/bin/screenshot.sh b/.local/bin/screenshot.sh new file mode 100755 index 0000000..dff8701 --- /dev/null +++ b/.local/bin/screenshot.sh @@ -0,0 +1,37 @@ +#!/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 |