From 3a88dd1a64b3e7dd432343280b9c97b127a81dda Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 4 May 2023 14:21:10 -0400 Subject: [PATCH] Copy to web --- configs/nautilus/scripts/Copy to web | 36 ++++++++++++++++++++++++++++ install.conf.yaml | 4 ++++ 2 files changed, 40 insertions(+) create mode 100755 configs/nautilus/scripts/Copy to web diff --git a/configs/nautilus/scripts/Copy to web b/configs/nautilus/scripts/Copy to web new file mode 100755 index 0000000..9207a42 --- /dev/null +++ b/configs/nautilus/scripts/Copy to web @@ -0,0 +1,36 @@ +#! /bin/bash +set -e + +WEBSERVER_PATH=$HOME/www + +# If NAUTILUS_SCRIPT_SELECTED_FILE_PATHS is empty, error and exit +if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then + notify-send "Copy to web" "No local files selected" + exit 1 +fi + +# For every file in NAUTILUS_SCRIPT_SELECTED_FILE_PATHS +echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | while read file; do + # Get the last segment of the path + filename=$(basename "$file") + + # If the file comes from ~/Pictures/Screenshots, use a path in ~/$WEBSERVER_PATH/screenshots + if [[ "$file" == "$HOME/Pictures/Screenshots/"* ]]; then + OUTPUT_PATH="$WEBSERVER_PATH/screenshots/$filename" + RES_PATH="/screenshots/$filename" + mkdir -p "$WEBSERVER_PATH/screenshots" + else + OUTPUT_PATH="$WEBSERVER_PATH/$filename" + RES_PATH="/$filename" + fi + + # Copy the file to the webserver + cp -r "$file" "$OUTPUT_PATH" + + # Write the resource path to the clipbaord + echo -n "$RES_PATH" | xsel -i -b + +done + +# Show a success message +notify-send "Copy to web" "Files copied to ~/www" diff --git a/install.conf.yaml b/install.conf.yaml index d972857..b1f4e65 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -10,6 +10,7 @@ - ~/projects - ~/src - ~/www + - ~/.local/share/nautilus/scripts/ - link: ~/.gitconfig: configs/git/.gitconfig @@ -28,6 +29,9 @@ ~/bin/fetch-steamdeck-screenshots: path: configs/scripts/fetch-steamdeck-screenshots mode: 755 + ~/.local/share/nautilus/scripts/Copy to web: + path: configs/nautilus/scripts/Copy to web + mode: 755 - shell: - [git submodule update --init --recursive, Installing submodules]