nixos-config/scripts/down_meme

28 lines
469 B
Bash
Executable file

#!/bin/sh
set -euo pipefail
cleanup() {
if test "$?" != 0; then
notify-send "Failed to download"
fi
}
trap cleanup EXIT INT
DIR=$(mktemp -d)
cd "$DIR"
yt-dlp --cookies-from-browser firefox --merge-output-format mp4 "$(wl-paste)"
FILENAME="$(ls | head -n1)"
mkdir -p "$HOME/Downloads/Memes"
cp "$FILENAME" "$HOME/Downloads/Memes/$FILENAME"
wl-copy-file "$HOME/Downloads/Memes/$FILENAME"
notify-send "Meme downloaded" "$FILENAME"
rm -rf "$DIR"