{ pkgs, ... }: { home.packages = with pkgs; [ (writeShellScriptBin "clipboard-save" '' # Script to automatically save copied images and text in specified directories while ${clipnotify}/bin/clipnotify do image_location="/tmp/clipboard/images" text_location="/tmp/clipboard/text" [[ -d $image_location ]] || mkdir -p $image_location [[ -d $text_location ]] || mkdir -p $text_location case "$(xclip -selection clipboard -t TARGETS -o)" in *image*) echo "$(${xclip}/bin/xclip -selection clipboard -t TARGETS -o)" filename=$(${xclip}/bin/xclip -selection clipboard -t image/png -o | ${openssl}/bin/openssl sha1 | cut -b 49-) file_exists=$(ls $image_location | grep $filename | sed "s/\..*//") [[ $filename != "$file_exists" ]] && xclip -selection clipboard -t image/png -o > "$image_location/$filename.png" && notify-send -t 5000 "Image Copied" "$image_location/$filename.png" ;; *UTF8_STRING*) echo "$(${xclip}/bin/xclip -selection clipboard -t TARGETS -o)" filename=$(${xclip}/bin/xclip -selection clipboard -t UTF8_STRING -o | ${openssl}/bin/openssl sha1 | cut -b 49-) file_exists=$(ls "$text_location" | grep "$filename" | sed "s/\..*//") echo "$filename" "$file_exists" [[ "$filename" != "$file_exists" ]] && xclip -selection clipboard -t UTF8_STRING -o > "$text_location/$filename" echo "$text_location/$filename" touch "$text_location/$filename" ;; esac done '') ]; }