i3wm-screenshot-tool/i3-screenshot-simple.sh
2025-03-06 07:26:45 +01:00

34 lines
921 B
Bash
Executable File

#!/bin/bash
# i3-screenshot-simple.sh - Simple tool for taking selective screenshots in i3
# This script uses maim and slop for direct area selection without freezing
# 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 maim with slop for area selection
maim -s "$SCREENSHOT_PATH"
# Check if screenshot was taken successfully
if [ $? -ne 0 ]; then
notify "Screenshot canceled"
exit 1
fi
# 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"