nix/modules/scripts/save_image.nix
2024-10-15 11:51:42 +02:00

26 lines
591 B
Nix

{ pkgs, ... }:
pkgs.writeShellScriptBin "saveimage" ''
# Check if an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <filename>"
exit 1
fi
# Create the assets directory if it doesn't exist
mkdir -p assets
# Set the output path in the assets directory
OUTPUT_PATH="assets/$1.png"
# Save the clipboard image to the specified file in assets directory
wl-paste --type image/png > "$OUTPUT_PATH"
# Check if the file was successfully saved
if [ $? -eq 0 ]; then
echo "Image saved to $OUTPUT_PATH"
else
echo "Failed to save the image"
fi
''