Skip to content

Commit

Permalink
Use single rendering script for all variations
Browse files Browse the repository at this point in the history
- uses single render-assets.sh for all variations
- single rendering script takes care of all assets
  used in gtk variations and xfwm variations
- reduces repo size and better automation
- No need to include .png files with repo as
  they can be generated during building deb packaging
- better rendering of assets for new themes like gtk-4.0
- original rendering scripts has been kept back but can be removed
  • Loading branch information
hsbasu committed May 9, 2022
1 parent 0c6f6fe commit f973e82
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 16 deletions.
64 changes: 64 additions & 0 deletions src/Mint-Y/render-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#! /bin/bash

INKSCAPE="/usr/bin/inkscape"
OPTIPNG="/usr/bin/optipng"

INDEX="assets.txt"
if [ -z $1 ]; then
SRC_FILE="assets.svg"
ASSETS_DIR="assets"
else
SRC_FILE="assets"$1".svg"
ASSETS_DIR="assets"$1
fi
mkdir -p $ASSETS_DIR

render()
{
echo Rendering $1
if [[ "$1" == *"@2"* ]]; then
$INKSCAPE --export-id=$2 --export-dpi=192 \
"${INKSCAPE_OPTS[@]}" $1 $SRC_FILE >/dev/null 2>&1 \
&& $OPTIPNG -o7 --quiet $1
else
$INKSCAPE --export-id=$2 "${INKSCAPE_OPTS[@]}" $1 $SRC_FILE >/dev/null 2>&1 \
&& $OPTIPNG -o7 --quiet $1
fi
}

# Set options for Inkscape depending on version.
INKSCAPE_OPTS=( --export-id-only )
case $($INKSCAPE -V | cut -d' ' -f2) in
# NB: The export option (-e or -o) must be the last option in the INKSCAPE_OPTS array.
0.*) INKSCAPE_OPTS+=('-z' '-e');; # -z specifies not to launch GUI, -e is export
1.*) INKSCAPE_OPTS+=('-o');; # v1.0+ uses no GUI by default, -e replaced by -o
esac

for i in `cat $INDEX`
do
if [ -f $ASSETS_DIR/$i.png ]; then
echo $ASSETS_DIR/$i.png exists.
else
echo
render $ASSETS_DIR/$i.png $i &
# allow only to execute number of jobs in parallel
# equal to number of processors
if [[ $(jobs -r -p | wc -l) -gt $(nproc) ]]; then
# wait only for first job
wait $(jobs -p)
fi
fi
if [ -f $ASSETS_DIR/$i@2.png ]; then
echo $ASSETS_DIR/$i@2.png exists.
else
echo
render $ASSETS_DIR/$i@2.png $i &
# allow only to execute number of jobs in parallel
# equal to number of processors
if [[ $(jobs -r -p | wc -l) -gt $(nproc) ]]; then
# wait only for first job
wait $(jobs -p)
fi
fi
done
exit 0
38 changes: 22 additions & 16 deletions update-variations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def usage ():
sys.exit(1)

def update_color (color):
variation = "src/Mint-Y/variations/%s" % color
print("updating %s" % variation)
variation = curdir+"/src/Mint-Y/variations/%s" % color
rendering_script = curdir+"/src/Mint-Y/render-assets.sh"
print("updating %s" % color)
os.system("rm -rf %s" % variation)
os.system("mkdir -p %s/gtk-2.0" % variation)
os.system("mkdir -p %s/gtk-3.0" % variation)
Expand All @@ -38,14 +39,9 @@ def update_color (color):
files.append("gtk-2.0/assets")
files.append("gtk-2.0/assets-dark")
files.append("gtk-2.0/assets.txt")
files.append("gtk-2.0/render-assets.sh")
files.append("gtk-2.0/render-dark-assets.sh")
files.append("gtk-3.0/assets")
files.append("gtk-3.0/assets.txt")
files.append("gtk-3.0/render-assets.sh")
files.append("xfwm4/render-assets.sh")
files.append("xfwm4/assets.txt")
files.append("xfwm4-dark/render-assets.sh")
files.append("xfwm4-dark/assets.txt")

for file in files:
Expand All @@ -67,20 +63,27 @@ def update_color (color):

# Render assets
os.chdir(variation)
os.chdir("gtk-2.0")
os.chdir(variation+"/gtk-2.0")
os.system("rm -rf assets/*")
os.system("rm -rf assets-dark/*")
os.system("./render-assets.sh")
os.system("./render-dark-assets.sh")
os.chdir("../gtk-3.0/")
print("**Rendering gtk-2.0 assets...")
os.system(rendering_script)
print("**Rendering gtk-2.0 dark assets...")
os.system(rendering_script+" -dark")
print("**Rendering gtk-3.0 assets...")
os.chdir(variation+"/gtk-3.0/")
os.system("rm -rf assets/*")
os.system("./render-assets.sh")
os.chdir("../xfwm4/")
os.system(rendering_script)
os.chdir(variation+"/xfwm4/")
os.system("rm -rf *.png")
os.system("./render-assets.sh")
os.chdir("../xfwm4-dark/")
print("**Rendering xfwm4 assets...")
os.system(rendering_script)
os.system("mv assets/*.png ./ && rm -rf assets/")
os.chdir(variation+"/xfwm4-dark/")
os.system("rm -rf *.png")
os.system("./render-assets.sh")
print("**Rendering xfwm4 dark assets...")
os.system(rendering_script)
os.system("mv assets/*.png ./ && rm -rf assets/")
os.chdir(curdir)

if len(sys.argv) < 2:
Expand All @@ -92,6 +95,9 @@ def update_color (color):

# Mint-Y variations
curdir = os.getcwd()
# override for inkscape. when ulimit is set to "unlimited"
# inkscape fails with segfault
os.system("ulimit -s 1024")

if color_variation == "All":
for color in y_hex_colors1.keys():
Expand Down

0 comments on commit f973e82

Please sign in to comment.