Make it possible to upload screenshots when a custom screenshot command was used. Warn if no custom command was given and scrot is missing. Warn if uploading was enabled and curl is missing. --- a/screenfetch-dev +++ b/screenfetch-dev @@ -226,10 +226,10 @@ printf " ${bold}-N${c0} Strip all color from output.\n" printf " ${bold}-t${c0} Truncate output based on terminal width (Experimental!).\n" printf " ${bold}-p${c0} Portrait output.\n" - printf " ${bold}-s(u)${c0} Using this flag tells the script that you want it\n" + printf " ${bold}-s [-u IMGHOST]${c0} Using this flag tells the script that you want it\n" printf " to take a screenshot. Use the -u flag if you would like\n" printf " to upload the screenshots to one of the pre-configured\n" - printf " locations. These include: teknik, pomf, imgur, mediacrush, and hmp.\n" + printf " locations. These include: teknik, pomf, imgur, mediacrush and hmp.\n" printf " ${bold}-c string${c0} You may change the outputted colors with -c. The format is\n" printf " as follows: [0-9][0-9],[0-9][0-9]. The first argument controls the\n" printf " ASCII logo colors and the label colors. The second argument\n" @@ -2053,8 +2053,19 @@ ####################### takeShot () { + take_screenshot="yes" if [[ -z $screenCommand ]]; then + screenCommand="scrot -cd3" + if ! type -p scrot >/dev/null 2>&1; then + errorOut "Cannot take screenshot! \`scrot' not in \$PATH" + take_screenshot="no" + fi + fi + if [[ "${take_screenshot}" == "yes" ]]; then if [[ "${upload}" == "1" ]]; then + if ! type -p curl >/dev/null 2>&1; then + errorOut "Cannot upload screenshot! \`curl' not in \$PATH" + else shotfiles[1]=${shotfile} if [ "$distro" == "Mac OS X" ]; then displays="$(system_profiler SPDisplaysDataType | grep 'Resolution:' | wc -l | tr -d ' ')" @@ -2063,7 +2074,7 @@ shotfiles[$i]="$(echo ${shotfile} | sed "s/\(.*\)\./\1_${i}./")" done printf "Taking shot in 3.. "; sleep 1; printf "2.. "; sleep 1; printf "1.. "; sleep 1; printf "0.\n"; screencapture -x ${shotfiles[@]} &> /dev/null - else scrot -cd3 "${shotfile}"; fi + else $screenCommand "${shotfile}"; fi if [ -f "${shotfile}" ]; then verboseOut "Screenshot saved at '${shotfiles[@]}'" printf "${bold}==>${c0} Uploading your screenshot now..." @@ -2120,6 +2131,7 @@ else errorOut "ERROR: Problem saving screenshot to ${shotfiles[@]}" fi + fi else shotfiles[1]=${shotfile} if [ "$distro" == "Mac OS X" ]; then @@ -2129,15 +2141,13 @@ shotfiles[$i]="$(echo ${shotfile} | sed "s/\(.*\)\./\1_${i}./")" done printf "Taking shot in 3.. "; sleep 1; printf "2.. "; sleep 1; printf "1.. "; sleep 1; printf "0.\n"; screencapture -x ${shotfiles[@]} &> /dev/null - else scrot -cd3 "${shotfile}"; fi + else $screenCommand "${shotfile}"; fi if [ -f "${shotfile}" ]; then verboseOut "Screenshot saved at '${shotfiles[@]}'" else errorOut "ERROR: Problem saving screenshot to ${shotfiles[@]}" fi fi - else - $screenCommand fi }