diff options
| -rwxr-xr-x | .config/sxiv/exec/key-handler | 8 | ||||
| -rwxr-xr-x | .local/bin/convwall | 14 | 
2 files changed, 13 insertions, 9 deletions
| diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler index 00f6fa23..bfad867f 100755 --- a/.config/sxiv/exec/key-handler +++ b/.config/sxiv/exec/key-handler @@ -38,12 +38,12 @@ flip() {  linkwall() {  	tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read -r file; do -		walldir="${HOME}/pictures/wallpapers/" +		walldir="$HOME/pictures/wallpapers/"  		name=$(basename "$file") -		if [ ! -e "${walldir}${name}" ]; then -			convwall "$file" "${walldir}${name}" || ln -s "$file" "${walldir}"  +		if [ ! -e "$walldir$name" ]; then +			convwall "$file" "$walldir$name" || ln -s "$file" "$walldir"   		else -			notify-send 'error' "${name} exist" +			notify-send 'error' "$name exist"  		fi  	done  } diff --git a/.local/bin/convwall b/.local/bin/convwall index 326a3de9..5249aead 100755 --- a/.local/bin/convwall +++ b/.local/bin/convwall @@ -1,6 +1,7 @@  #!/bin/sh  # 16:9 screen resolution ratio +# 16*100/9 == 177  wratio=16  hratio=9  chopnum=99% @@ -8,19 +9,22 @@ chopnum=99%  width=$(identify -format '%w' "$1")  height=$(identify -format '%h' "$1") +ratio=$(echo "$wratio*100/$hratio" | bc)  dim=$(echo "$width*100/$height" | bc) -if [ "$dim" -ne 177 ]; then -	if [ "$dim" -lt 177 ]; then +if [ "$dim" -ne "$ratio" ]; then +	if [ "$dim" -lt "$ratio" ]; then  		chopgeom="${chopnum}x0"	  		width=$(echo "$height*$wratio/$hratio" | bc)  	else -		chopgeom="0x${chopnum}"	 +		chopgeom="0x$chopnum"	  		height=$(echo "$width*$hratio/$wratio" | bc)  	fi -	extgeom="${width}x${height}" +	# may throw error sort: write failed: 'standard output': Broken pipe \n sort: write error +	# caused by head exit (or close stdin) before sort output complete, can ignore +	# https://stackoverflow.com/questions/46202653/bash-error-in-sort-sort-write-failed-standard-output-broken-pipe  	bgcolor=$(convert "$1" -gravity center -chop "$chopgeom" -define histogram:unique-colors=true -format %c histogram:info:- | sort -rn | head -n1 | awk \{print\ \$3\} | cut -c1-7) -	convert "$1" -gravity center -background "$bgcolor" -extent "$extgeom" "$2" +	convert "$1" -gravity center -background "$bgcolor" -extent "${width}x$height" "$2"  else  	echo 'same resolution ratio, no need to convert' >&2  	exit 1 | 
