Skip to content

Commit 5c9c8af

Browse files
committed
Use xargs to multithread processing of files
1 parent 6eee5c1 commit 5c9c8af

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

solarize.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ ARC_NEED_DOWNLOAD=true
88
if [ -z $ARC_VERSION ]; then
99
ARC_VERSION="20210412"
1010
fi
11+
# Defaults to number of CPUs for multithreading the find/exec commands
12+
JOBS=`nproc`
1113

1214
usage()
1315
{
1416
echo "Calling this script with no arguments will download the most recently validated version \n"
1517
echo " of Arc theme and then process it. You can use --arc-version (or -v) to download a specific \n"
16-
echo " version of Arc theme, or use --arc-directory (or -d) to process a pre-downloaded Arc theme \n\n"
18+
echo " version of Arc theme, or use --arc-directory (or -d) to process a pre-downloaded Arc theme \n"
19+
echo " You may also use --jobs (or -j) to specify how many threads should be used during the build\n\n"
1720
echo "You may also see this message if you used invalid arguments. "
1821
}
1922

@@ -26,6 +29,9 @@ while [ "$1" != "" ]; do
2629
-v | --arc-version ) shift
2730
ARC_VERSION="$1"
2831
;;
32+
-j | --jobs ) shift
33+
JOBS="$1"
34+
;;
2935
-h | --help ) usage
3036
exit
3137
;;
@@ -250,7 +256,7 @@ cd "${CWD}"
250256
echo "### Applying patch(es)"
251257

252258
echo "### Optimising SVGs"
253-
find . -name "*.svg" -exec inkscape --actions="export-plain-svg;vacuum-defs" {} \;
259+
find . -name "*.svg" -print0|xargs -0 -P $JOBS -I % inkscape --actions="export-plain-svg;vacuum-defs" % ;
254260
FILETYPES=('.scss' '.svg' '.xpm' '.xml' 'rc' '.theme')
255261

256262
echo "### Replacing arc colors with solarized colors"
@@ -259,13 +265,13 @@ do
259265
echo "## Replacing in ${filetype}"
260266
for K in ${!REPLACE[@]}
261267
do
262-
find . -type f -name "*${filetype}" -exec sed -i "s/${K}/${REPLACE[$K]}/Ig" {} \;
268+
find . -type f -name "*${filetype}" -print0|xargs -0 -P $JOBS -I % sed -i "s/${K}/${REPLACE[$K]}/Ig" % ;
263269
done
264270
done
265271

266272
# Correct index.theme metadata & output directories
267273
for PATTERN in "index.theme*" "metacity-theme-*.xml"; do
268-
find "${CWD}/common" -name "${PATTERN}" -exec sed -i "s/Arc/SolArc/g" {} \;
274+
find "${CWD}/common" -name "${PATTERN}" -print0|xargs -0 -P $JOBS -I % sed -i "s/Arc/SolArc/g" % ;
269275
done
270276

271277
# Arc theme has fully switched to meson building as of version 20210412

0 commit comments

Comments
 (0)