feat: sanity checks in sample screenshotter

pull/135/head
NotAShelf 7 months ago
parent e201da1e55
commit 25a32b3879
No known key found for this signature in database
GPG Key ID: 02D1DD3FA08B6B29

@ -1,26 +1,67 @@
#!/usr/bin/env bash
# Script Configuration
IMAGEPATH="$HOME/Pictures"
IMAGENAME="ass"
FILE="${IMAGEPATH}/${IMAGENAME}.png"
LOG_DIR=$(pwd)
CONFIG_FILE="config.sh"
# Load configuration if available
# Load configuration file if available
# this is useful if you want to source keys from a secret file
CONFIG_FILE="config.sh"
if [ -f "$CONFIG_FILE" ]; then
# shellcheck disable=1090
source "${CONFIG_FILE}"
fi
LOG_DIR=$(pwd)
if [ ! -d "$LOG_DIR" ]; then
echo "The directory you have specified to save the logs does not exist."
echo "Please create the directory with the following command:"
echo "mkdir -p $LOG_DIR"
echo -en "Or specify a different LOG_DIR\n"
exit 1
fi
IMAGE_PATH="$HOME/Pictures"
if [ ! -d "$IMAGE_PATH" ]; then
echo "The directory you have specified to save the screenshot does not exist."
echo "Please create the directory with the following command:"
echo "mkdir -p $IMAGE_PATH"
echo -en "Or specify a different IMAGE_PATH\n"
exit 1
fi
IMAGE_NAME="ass"
FILE="${IMAGE_PATH}/${IMAGE_NAME}.png"
# Function to check if a tool is installed
check_tool() {
command -v "$1" >/dev/null 2>&1
}
# Function to take Flameshot screenshots
takeFlameshot() {
flameshot config -f "${IMAGENAME}"
flameshot gui -r -p "${IMAGEPATH}" >/dev/null
# check if flameshot tool is installed
REQUIRED_TOOLS=("flameshot")
for tool in "${REQUIRED_TOOLS[@]}"; do
if ! check_tool "$tool"; then
echo "Error: $tool is not installed. Please install it before using this script."
exit 1
fi
done
flameshot config -f "${IMAGE_NAME}"
flameshot gui -r -p "${IMAGE_PATH}" >/dev/null
}
# Function to take Wayland screenshots using grim + slurp
takeGrimshot() {
# check if grim and slurp are installed
REQUIRED_TOOLS=("grim" "slurp")
for tool in "${REQUIRED_TOOLS[@]}"; do
if ! check_tool "$tool"; then
echo "Error: $tool is not installed. Please install it before using this script."
exit 1
fi
done
grim -g "$(slurp)" "${FILE}" >/dev/null
}

Loading…
Cancel
Save