diff --git a/.zshc/func.zsh b/.zshc/func.zsh index f2d0b7c..aa87095 100644 --- a/.zshc/func.zsh +++ b/.zshc/func.zsh @@ -36,6 +36,7 @@ function zipline { readonly file=${1:?Please provide the path to the file you want to upload.} readonly name=${2} readonly desktopentry=${3} + readonly contenttype=${4} readonly token=${ZIPLINE_TOKEN:?Environment variable ZIPLINE_TOKEN is not set. Please set it to your Zipline API token. I recommend placing it in a file at ~/.config/environment.d/zipline.conf} readonly url=${ZIPLINE_URL:?Environment variable ZIPLINE_URL is not set. Please set it to the URL of your Zipline instance. I recommend placing it in a file at ~/.config/environment.d/zipline.conf} @@ -71,18 +72,24 @@ function zipline { readonly use_send_notify=false fi - if curl -sS -fH "authorization: $token" "${url%/}/api/upload" -F file="@$file" -H "Content-Type: multipart/form-data" >"$temp_file" 2>&1; then + if [[ -z "${contenttype}" ]]; then + readonly content_type="multipart/form-data" + else + readonly content_type=$contenttype + fi + + if curl -sS -fH "authorization: $token" "${url%/}/api/upload" -F"file=@$file;type=$content_type" >"$temp_file" 2>&1; then readonly link=$(jq -r '.files[0]' <"$temp_file" | tr -d '\n') echo -n "$link" | clip echo "Upload successful. Link copied to clipboard: $link" if $use_send_notify; then - notify-send -a "$name" -u low -c transfer.complete -i "$file" -h "string:desktop-entry:$desktopentry" "Upload Successful" "Link copied to clipboard:\n$link" + notify-send -a "$name" -u low -c "transfer.complete" -i "$file" -h "string:desktop-entry:$desktopentry" "Upload Successful" "Link copied to clipboard:\n$link" fi rm -f "$temp_file" else echo "Upload failed. Error message: $(<"$temp_file")" if $use_send_notify; then - notify-send -a "$name" -u critical -c transfer.error -h "string:desktop-entry $desktopentry" "Upload Failed" "$(<"$temp_file")" + notify-send -a "$name" -u critical -c "transfer.error" -h "string:desktop-entry:$desktopentry" "Upload Failed" "$(<"$temp_file")" fi rm -f "$temp_file" return 1 @@ -110,6 +117,12 @@ function spectacle-screenshot { return 1 fi + if $save_recording; then + readonly content_type="video/webm" + else + readonly content_type="image/png" + fi + if [[ -z "${2}" ]]; then if $save_recording; then readonly file=$(mktemp /tmp/spectacle-recording.XXXXXXXX.webm) @@ -128,7 +141,7 @@ function spectacle-screenshot { fi [ ! -s "$file" ] && return 1 - zipline "$file" Spectacle org.kde.spectacle.desktop + zipline "$file" Spectacle org.kde.spectacle.desktop "$content_type" rm -f "$file" } @@ -156,7 +169,7 @@ function flameshot-screenshot { echo "Screenshot saved to $file" [ ! -s "$file" ] && return 1 - zipline "$file" Flameshot org.flameshot.Flameshot.desktop + zipline "$file" Flameshot org.flameshot.Flameshot.desktop image/png rm -f "$file" }