From 94cbd6bb02c69ad39d72a82de81638b5f7869276 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 2 Oct 2016 20:23:02 +1100 Subject: [PATCH] Added working teknik support and new flags --- config/config | 7 ++++++- neofetch | 33 +++++++++------------------------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/config/config b/config/config index 2615fd60..86703683 100644 --- a/config/config +++ b/config/config @@ -402,7 +402,12 @@ scrot_dir="$HOME/Pictures/" # Scrot filename # What to name the screenshots # --scrot_name str -scrot_name="neofetch-$(date +%F-%T).png" +scrot_name="neofetch-$(date +%F-%I-%M).png" + +# Image upload host +# Where to upload the image. +# Possible values: teknik, +image_host="teknik" # }}} diff --git a/neofetch b/neofetch index be7bdb71..b36781ec 100755 --- a/neofetch +++ b/neofetch @@ -2290,44 +2290,25 @@ getimagebackend() { takescrot() { $scrot_cmd "${scrot_dir}${scrot_name}" + [ "$scrot_upload" == "on" ] && scrot_upload } # }}} # Screenshot Upload {{{ -image_host="imgur" - scrot_upload() { image_file="${scrot_dir}${scrot_name}" + printf "%s\n" "Uploading image..." case "$image_host" in "teknik") - baseurl='https://u.teknik.io' - uploadurl='https://api.teknik.io/v1/Upload' - ret="$(curl -sf -F file="@${image_file}" ${uploadurl})" - url="$(awk -F 'url:\"|\"' '{printf $2}' <<< "$ret")" - ;; - - "mediacrush") - baseurl='https://mediacru.sh' - uploadurl='https://mediacru.sh/api/upload/file' - ret="$(curl -sf -F file="@${image_file};type=image/png" ${uploadurl})" - filehash=$(echo "${ret}" | grep "hash" | cut -d '"' -f4) - desturl="${baseurl}/${filehash}" - ;; - - "imgur") - baseurl='http://imgur.com' - uploadurl='http://imgur.com/upload' - ret="$(curl -sf -F file="@${image_file}" ${uploadurl})" - filehash="${ret##*hash\":\"}" - filehash="${filehash%%\"*}" - desturl="${baseurl}/${filehash}" + image_url="$(curl -sf -F file="@${image_file}" 'https://api.teknik.io/v1/Upload')" + image_url="$(awk -F 'url:|,' '{printf $2}' <<< "${image_url//\"}")" ;; esac - printf "%s\n" "your screenshot can be viewed at $desturl" + [ "$image_url" ] && printf "%s\n" "$image_url" } # }}} @@ -3126,6 +3107,10 @@ getargs() { scrot_dir="${2/$scrot_name}" fi ;; + --upload | -su) + scrot="on" + scrot_upload="on" + ;; --scrot_cmd) scrot_cmd="$2" ;; # Other