#!/bin/bash # i3-screenshot.sh - A tool for taking selective screenshots in i3 window manager # This script allows selecting an area for screenshot with multi-monitor support # Default save location - user's Pictures directory SAVE_DIR="$HOME/Pictures/Screenshots" TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S) SCREENSHOT_PATH="$SAVE_DIR/screenshot_$TIMESTAMP.png" # Create the save directory if it doesn't exist mkdir -p "$SAVE_DIR" # Function to display notification notify() { notify-send "Screenshot Tool" "$1" -i camera-photo } # Use slop to select an area and maim to take the screenshot directly # This works better with multiple monitors notify "Select an area to capture" SELECTION=$(slop -f "%x,%y,%w,%h") if [ $? -ne 0 ]; then # User canceled the selection notify "Screenshot canceled" exit 1 fi # Extract coordinates and dimensions IFS=',' read -r X Y W H <<< "$SELECTION" # Take the screenshot of the selected area maim -g "${W}x${H}+${X}+${Y}" "$SCREENSHOT_PATH" # Copy to clipboard xclip -selection clipboard -t image/png -i "$SCREENSHOT_PATH" # Notify user notify "Screenshot saved to $SCREENSHOT_PATH and copied to clipboard" echo "Screenshot saved to: $SCREENSHOT_PATH"