~q3cpma/scripts

88ddc36c2d08d10b65930736f559431c3cf75d34 — q3cpma 5 months ago dfd8669
Truly silence waifu2x-converter-cpp output and forcibly disabl GPU usage
manga_pack_volume.sh: fix help crash and accept volume number with a dot
sed_rename.sh: fix dry-run using the wrong delimiter
wallpaper_cycle.sh: use relative instead of absolute symlinks
6 files changed, 21 insertions(+), 15 deletions(-)

M manga_convert_ereader.sh
M manga_pack_volume.sh
M sed_rename.sh
M util.sh
M w2x_denoise.sh
M wallpaper_cycle.sh
M manga_convert_ereader.sh => manga_convert_ereader.sh +7 -7
@@ 204,14 204,13 @@ then
	then
		if \$upscale
		then
			waifu2x-converter-cpp --jobs 1 --log-level 0 --png-compression 0 \
			waifu2x-converter-cpp --jobs 1 --disable-gpu --png-compression 0 \
				--mode noise-scale --noise-level 1 --scale-ratio \$r \
				--input "\$1" --output "\$out"
		else
			waifu2x-converter-cpp --jobs 1 --log-level 0 --png-compression 0 \
				--mode noise --noise-level 1 \
				--input "\$1" --output "\$out"
		fi
			waifu2x-converter-cpp --jobs 1 --disable-gpu --png-compression 0 \
				--mode noise --noise-level 1 --input "\$1" --output "\$out"
		fi >/dev/null 2>&1
		rm -- "\$1"
		set -- "\$out"
	fi


@@ 220,8 219,9 @@ else
	cat <<- EOF >>"$tempscript"
	if \$upscale
	then
		waifu2x-converter-cpp --jobs 1 --log-level 0 --png-compression 0 \
			--mode scale --scale-ratio \$r --input "\$1" --output "\$out"
		waifu2x-converter-cpp --jobs 1 --disable-gpu --png-compression 0 \
			--mode scale --scale-ratio \$r --input "\$1" --output "\$out" \
			>/dev/null 2>&1
		if [ "\$out" != "\$1" ]
		then
			rm -- "\$1"

M manga_pack_volume.sh => manga_pack_volume.sh +2 -1
@@ 71,8 71,9 @@ PATH=$selfdir:$PATH
. "$selfdir"/util.sh


if [ $# -lt 1 ] || is_help "$@" || ! match "$1" '[0-9]{2}'
if [ $# -lt 1 ] || is_help "$@" || ! match "$1" '[0-9]{2}(\.[0-9])?'
then
	name=$(basename "$(preadlinkf "$0")")
	die "Usage: $name VOLUME_NUMBER [COVER_FILE...]"
fi


M sed_rename.sh => sed_rename.sh +1 -1
@@ 107,7 107,7 @@ do
		b)  usebre=true;;
		h)  usage 0;;
		r)  dryrun=true
			fs=$(printf "\x31")
			fs=$(printf '\034')
			;;
		\?) usage 1;;
	esac

M util.sh => util.sh +6 -0
@@ 486,3 486,9 @@ pmktemp()
		*)  return 1;;
	esac
}

# discard stdin unless $1 exists and is not empty
discard()
{
	[ "${1:-}" ] && true || cat
}

M w2x_denoise.sh => w2x_denoise.sh +2 -2
@@ 156,8 156,8 @@ temp=$tempdir/temp.png
trap 'exit 1' HUP INT QUIT ABRT ALRM TERM
trap 'rm -r -- "$tempdir"' EXIT

waifu2x-converter-cpp ${PARALLEL_PID+--jobs 1} ${quiet:+--log-level 0} \
	--png-compression 0 -m noise --noise-level "$denoise" -i "$in" -o "$temp"
waifu2x-converter-cpp ${PARALLEL_PID+--jobs 1} --disable-gpu --png-compression 0 \
	-m noise --noise-level "$denoise" -i "$in" -o "$temp" 2>&1 | discard ${quiet-x}

$delete && rm -f -- "$in"
case "$out" in

M wallpaper_cycle.sh => wallpaper_cycle.sh +3 -4
@@ 91,11 91,10 @@ EOF
fi

[ ! -L "$1" ] && die "$1: not a symbolic link"
requirefile -d "$2"
walldir=$(preadlinkf "$2")
cd -- "$2"

flist=$(listfiles "$walldir" -type f -iname '*.jpg' -o -iname '*.jpeg' \
	-o -iname '*.png' -o -iname '*.gif' | natsort)
flist=$(listfiles . -type f -iname '*.jpg' -o -iname '*.jpeg' \
	-o -iname '*.png' -o -iname '*.gif' | sed 's#^\./##' | natsort)
first=$(pecho "$flist" | head -n1)

next()