wallpaper: improve list script speed

This commit is contained in:
Vincent Bernat 2024-08-03 23:31:12 +02:00
parent bbc61d70ea
commit 1f451156ec

View file

@ -1,10 +1,18 @@
#!/bin/zsh
find -regextype posix-extended -iregex '.*\.(jpe?g|png|webp)' -print0 \
| xargs -0 identify -format "%[fx:w*h] %[w]x%[h] %i\n" \
| while read pixels resolution name; do
count=$(getfattr --only-values -n user.count $name 2> /dev/null || echo 0)
printf "%s\t%9s\t%5d\t%s\n" $pixels $resolution $count $name
join \
-1 3 -2 1 \
<(
find -regextype posix-extended -iregex '.*\.(jpe?g|png|webp)' -print0 \
| xargs -r0n10 -P$(nproc) identify -format "%[fx:w*h] %[w]x%[h] %i\n" \
| sort -k 3b,3) \
<(
getfattr --absolute-names -n user.count ./* 2> /dev/null \
| awk '/^# file:/ {file=substr($0, 8)} /^user.count=/ {printf("%s %s\n", file, substr($0, 13))}' \
| sed 's/"$//' \
| sort -k 1b,1) \
| while read name pixels resolution count; do
printf "%s\t%9s\t%5d\t%s\n" $pixels $resolution $count $name
done \
| sort -g -b -k3,3r -k1,1 \
| cut -f2-