Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use single rendering script for all variations #386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [[ $1 != "-dark" ]]; 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
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 [[ $1 == "s2" ]]; then
if [ -f $ASSETS_DIR/$i@2.png ]; then
echo $ASSETS_DIR/$i@2.png exists.
else
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
fi
done
exit 0
48 changes: 32 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 @@ -66,21 +62,38 @@ def update_color (color):
os.system("sed -i s'/%(accent)s/%(color_accent)s/gI' %(file)s" % {'accent': accent, 'color_accent': y_hex_colors4[color], 'file': asset_path})

# Render assets
# TODO: need better idea to do '-dark'
# and '@2' arguments
os.chdir(variation)
os.chdir("gtk-2.0")
os.chdir(variation+"/gtk-2.0")
print("**Rendering gtk-2.0 assets...")
os.system("rm -rf assets/*")
os.system(rendering_script)

print("**Rendering gtk-2.0 dark assets...")
os.system("rm -rf assets-dark/*")
os.system("./render-assets.sh")
os.system("./render-dark-assets.sh")
os.chdir("../gtk-3.0/")
os.system(rendering_script+" -dark")
# os.system("rm -rf assets/*@2.png")

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+" s2")

print("**Rendering xfwm4 assets...")
os.chdir(variation+"/xfwm4/")
os.system("rm -rf *.png")
os.system("./render-assets.sh")
os.chdir("../xfwm4-dark/")
os.system(rendering_script)
# os.system("rm -rf assets/*@2.png")
os.system("mv assets/*.png ./ && rm -rf assets/")

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

if len(sys.argv) < 2:
Expand All @@ -92,6 +105,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