aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/screenshot.sh
diff options
context:
space:
mode:
authorJustine Smithies <justine@smithies.me.uk>2025-11-04 20:40:38 +0000
committerJustine Smithies <justine@smithies.me.uk>2025-11-04 20:40:38 +0000
commitaa66d791c82e02e6e5529d906d4009daf8bb34f9 (patch)
tree7f8d7b1d519a6e6ded08cd37146c371f04fbc5cb /.local/bin/screenshot.sh
parentb347fc3db35ef68103beb4b735a5e9df04b3a082 (diff)
Initial commit
Diffstat (limited to '.local/bin/screenshot.sh')
-rwxr-xr-x.local/bin/screenshot.sh37
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