diff options
author | Justine Smithies <justine@openbsd-desktop.localdomain> | 2025-10-07 20:51:04 +0100 |
---|---|---|
committer | Justine Smithies <justine@openbsd-desktop.localdomain> | 2025-10-07 20:51:04 +0100 |
commit | d85ad60a74c75af5cc9ad0a8e1127d0bf41a7af4 (patch) | |
tree | f498e8c7f694f24ea3b45c44bd0cb38b7cab937b /.local/bin/screenshot.sh | |
parent | e737b64c4b5c56c2ffbf182138147a0763912a02 (diff) |
Initial commit
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 |