From cceaa81ece746d646c3eb662f955c1d648351157 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Tue, 2 Apr 2024 00:46:21 +0200 Subject: [PATCH 1/4] Add bash shebang to all shell scripts --- scripts/xmb-convert.sh | 2 +- src/sounds/convert_ogg.sh | 10 ++++++---- src/xmb/convert_xmb_assets.sh | 2 ++ src/xmb/monochrome/export.sh | 5 +++-- src/xmb/monochrome/export_ozone.sh | 14 ++++++++------ 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/scripts/xmb-convert.sh b/scripts/xmb-convert.sh index fb4fa18be..d79e61c84 100755 --- a/scripts/xmb-convert.sh +++ b/scripts/xmb-convert.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # MonoChrome SVG to PNG Converter # diff --git a/src/sounds/convert_ogg.sh b/src/sounds/convert_ogg.sh index 0c4916241..111728917 100755 --- a/src/sounds/convert_ogg.sh +++ b/src/sounds/convert_ogg.sh @@ -1,14 +1,16 @@ +#!/usr/bin/env bash + # Script to convert to OGG, rename to lowercase and copy chosen sounds # requires ffmpeg and libvorbis/libogg SOUNDS="OK.wav CANCEL.wav BGM.wav UP.wav DOWN.wav LAUNCH.wav NOTICE.wav NOTICE_BACK.wav" mkdir -p ../../sounds for src in $SOUNDS; do - export dest=`echo $src | sed "s/.wav/.ogg/"` - export dest=`echo "$dest" | tr '[:upper:]' '[:lower:]'` + export dest=$(echo $src | sed "s/.wav/.ogg/") + export dest=$(echo "$dest" | tr '[:upper:]' '[:lower:]') echo "$src -> $dest" - + ffmpeg -i $src -acodec libvorbis ../../sounds/$dest done - + cp Licence.txt ../../sounds/Licence.txt diff --git a/src/xmb/convert_xmb_assets.sh b/src/xmb/convert_xmb_assets.sh index f6f37650a..ad868971d 100755 --- a/src/xmb/convert_xmb_assets.sh +++ b/src/xmb/convert_xmb_assets.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + convert_xmb_assets() { SRC_DIR="$1" diff --git a/src/xmb/monochrome/export.sh b/src/xmb/monochrome/export.sh index 3e7b880e6..609794352 100755 --- a/src/xmb/monochrome/export.sh +++ b/src/xmb/monochrome/export.sh @@ -1,6 +1,8 @@ +#!/usr/bin/env bash + for src in *.svg; do echo $src; - export dest=`echo $src | sed "s/.svg/.png/"` + export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../xmb/monochrome/png inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../xmb/monochrome/png/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../xmb/monochrome/png/$dest" @@ -10,4 +12,3 @@ for src in *.svg; do #convert "../png/$dest" -write mpr:temp -background black -alpha Remove mpr:temp -compose Copy_Opacity -composite "../png/$dest" #python2 ../../NPMApng2PMApng.py "../png/$dest" "../png/$dest" done - diff --git a/src/xmb/monochrome/export_ozone.sh b/src/xmb/monochrome/export_ozone.sh index a906db7d6..996241b9e 100755 --- a/src/xmb/monochrome/export_ozone.sh +++ b/src/xmb/monochrome/export_ozone.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + for src in *.svg do fletter="$(echo $src | head -c 1)" @@ -21,7 +23,7 @@ do echo "Exporting $src ($size x $size)" - export dest=`echo $src | sed "s/.svg/.png/"` + export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w $size -h $size -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" @@ -30,14 +32,14 @@ done # Override some icons (different size and color) src="clock.svg" -export dest=`echo $src | sed "s/.svg/.png/"` +export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 92 -h 92 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" optipng -o7 -strip all "../../../ozone/png/icons/$dest" for src in battery-*.svg; do - export dest=`echo $src | sed "s/.svg/.png/"` + export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 92 -h 92 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" @@ -45,21 +47,21 @@ for src in battery-*.svg; do done src="dialog-slice.svg" -export dest=`echo $src | sed "s/.svg/.png/"` +export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" optipng -o7 -strip all "../../../ozone/png/icons/$dest" src="key-hover.svg" -export dest=`echo $src | sed "s/.svg/.png/"` +export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" optipng -o7 -strip all "../../../ozone/png/icons/$dest" src="key.svg" -export dest=`echo $src | sed "s/.svg/.png/"` +export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" From ffd367a5958fe74b30291a88722aebfb555806fc Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Tue, 2 Apr 2024 00:52:59 +0200 Subject: [PATCH 2/4] Shell scripts: Check necessary software is installed before continuing --- scripts/xmb-convert.sh | 13 +++++++++++++ src/sounds/convert_ogg.sh | 20 ++++++++++++++++---- src/xmb/convert_xmb_assets.sh | 13 +++++++++++++ src/xmb/monochrome/export.sh | 14 ++++++++++++++ src/xmb/monochrome/export_ozone.sh | 14 ++++++++++++++ 5 files changed, 70 insertions(+), 4 deletions(-) diff --git a/scripts/xmb-convert.sh b/scripts/xmb-convert.sh index d79e61c84..ac0d2d9bb 100755 --- a/scripts/xmb-convert.sh +++ b/scripts/xmb-convert.sh @@ -17,6 +17,19 @@ # ./convert.sh monochrome battery-full # ./convert.sh flatui DOS +exitFlag=0 +checkCommand() { + if ! command -v "${1}" >/dev/null; then + echo "${1} not installed!" + exitFlag=1 + fi +} +checkCommand 'inkscape' +if [[ ${exitFlag} -eq 1 ]]; then + exit 1 +fi + + cd -- "$(cd -- "$(dirname -- "$0")" && pwd -P)" inkscape -z -e "$1/png/$2.png" -w 256 -h 256 "../src/xmb/$1/$2.svg" diff --git a/src/sounds/convert_ogg.sh b/src/sounds/convert_ogg.sh index 111728917..c0620d710 100755 --- a/src/sounds/convert_ogg.sh +++ b/src/sounds/convert_ogg.sh @@ -1,16 +1,28 @@ #!/usr/bin/env bash +exitFlag=0 +checkCommand() { + if ! command -v "${1}" >/dev/null; then + echo "${1} not installed!" + exitFlag=1 + fi +} +checkCommand 'ffmpeg' +if [[ ${exitFlag} -eq 1 ]]; then + exit 1 +fi + # Script to convert to OGG, rename to lowercase and copy chosen sounds # requires ffmpeg and libvorbis/libogg SOUNDS="OK.wav CANCEL.wav BGM.wav UP.wav DOWN.wav LAUNCH.wav NOTICE.wav NOTICE_BACK.wav" mkdir -p ../../sounds for src in $SOUNDS; do - export dest=$(echo $src | sed "s/.wav/.ogg/") - export dest=$(echo "$dest" | tr '[:upper:]' '[:lower:]') - echo "$src -> $dest" + export dest=$(echo $src | sed "s/.wav/.ogg/") + export dest=$(echo "$dest" | tr '[:upper:]' '[:lower:]') + echo "$src -> $dest" - ffmpeg -i $src -acodec libvorbis ../../sounds/$dest + ffmpeg -i $src -acodec libvorbis ../../sounds/$dest done cp Licence.txt ../../sounds/Licence.txt diff --git a/src/xmb/convert_xmb_assets.sh b/src/xmb/convert_xmb_assets.sh index ad868971d..023acd4c0 100755 --- a/src/xmb/convert_xmb_assets.sh +++ b/src/xmb/convert_xmb_assets.sh @@ -1,5 +1,18 @@ #!/usr/bin/env bash +exitFlag=0 +checkCommand() { + if ! command -v "${1}" >/dev/null; then + echo "${1} not installed!" + exitFlag=1 + fi +} +checkCommand 'convert' +checkCommand 'optipng' +if [[ ${exitFlag} -eq 1 ]]; then + exit 1 +fi + convert_xmb_assets() { SRC_DIR="$1" diff --git a/src/xmb/monochrome/export.sh b/src/xmb/monochrome/export.sh index 609794352..e20d830e8 100755 --- a/src/xmb/monochrome/export.sh +++ b/src/xmb/monochrome/export.sh @@ -1,5 +1,19 @@ #!/usr/bin/env bash +exitFlag=0 +checkCommand() { + if ! command -v "${1}" >/dev/null; then + echo "${1} not installed!" + exitFlag=1 + fi +} +checkCommand 'inkscape' +checkCommand 'magick' +checkCommand 'optipng' +if [[ ${exitFlag} -eq 1 ]]; then + exit 1 +fi + for src in *.svg; do echo $src; export dest=$(echo $src | sed "s/.svg/.png/") diff --git a/src/xmb/monochrome/export_ozone.sh b/src/xmb/monochrome/export_ozone.sh index 996241b9e..fc61a0126 100755 --- a/src/xmb/monochrome/export_ozone.sh +++ b/src/xmb/monochrome/export_ozone.sh @@ -1,5 +1,19 @@ #!/usr/bin/env bash +exitFlag=0 +checkCommand() { + if ! command -v "${1}" >/dev/null; then + echo "${1} not installed!" + exitFlag=1 + fi +} +checkCommand 'inkscape' +checkCommand 'magick' +checkCommand 'optipng' +if [[ ${exitFlag} -eq 1 ]]; then + exit 1 +fi + for src in *.svg do fletter="$(echo $src | head -c 1)" From afb4cf20910f81be0f5f4616597447b0e3e84876 Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Tue, 2 Apr 2024 00:57:18 +0200 Subject: [PATCH 3/4] Replace optipng with oxipng --- src/xmb/convert_xmb_assets.sh | 4 ++-- src/xmb/monochrome/export.sh | 4 ++-- src/xmb/monochrome/export_ozone.sh | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/xmb/convert_xmb_assets.sh b/src/xmb/convert_xmb_assets.sh index 023acd4c0..404e4980d 100755 --- a/src/xmb/convert_xmb_assets.sh +++ b/src/xmb/convert_xmb_assets.sh @@ -8,7 +8,7 @@ checkCommand() { fi } checkCommand 'convert' -checkCommand 'optipng' +checkCommand 'oxipng' if [[ ${exitFlag} -eq 1 ]]; then exit 1 fi @@ -65,7 +65,7 @@ convert_xmb_assets() else convert -background 'rgb(255,255,255)' -alpha Background "$SRC_FILE" -resize $SCALE_FACTOR "$DST_FILE" fi - optipng -quiet -o7 -strip all "$DST_FILE" + oxipng --quiet --zopfli --opt max --strip all "$DST_FILE" fi done diff --git a/src/xmb/monochrome/export.sh b/src/xmb/monochrome/export.sh index e20d830e8..a3222f86d 100755 --- a/src/xmb/monochrome/export.sh +++ b/src/xmb/monochrome/export.sh @@ -9,7 +9,7 @@ checkCommand() { } checkCommand 'inkscape' checkCommand 'magick' -checkCommand 'optipng' +checkCommand 'oxipng' if [[ ${exitFlag} -eq 1 ]]; then exit 1 fi @@ -20,7 +20,7 @@ for src in *.svg; do mkdir -p ../../../xmb/monochrome/png inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../xmb/monochrome/png/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../xmb/monochrome/png/$dest" - optipng -o7 -strip all "../../../xmb/monochrome/png/$dest" + oxipng --quiet --zopfli --opt max --strip all "../../../xmb/monochrome/png/$dest" #rsvg-convert -b none -w 256 -h 256 "$src" -o "../png/$dest" #convert -density 360 -background none "$src" "../png/$dest" #convert "../png/$dest" -write mpr:temp -background black -alpha Remove mpr:temp -compose Copy_Opacity -composite "../png/$dest" diff --git a/src/xmb/monochrome/export_ozone.sh b/src/xmb/monochrome/export_ozone.sh index fc61a0126..38cf2788b 100755 --- a/src/xmb/monochrome/export_ozone.sh +++ b/src/xmb/monochrome/export_ozone.sh @@ -9,7 +9,7 @@ checkCommand() { } checkCommand 'inkscape' checkCommand 'magick' -checkCommand 'optipng' +checkCommand 'oxipng' if [[ ${exitFlag} -eq 1 ]]; then exit 1 fi @@ -41,7 +41,7 @@ do mkdir -p ../../../ozone/png/icons inkscape -z -C -w $size -h $size -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" - optipng -o7 -strip all "../../../ozone/png/icons/$dest" + oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest" done # Override some icons (different size and color) @@ -50,14 +50,14 @@ export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 92 -h 92 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" -optipng -o7 -strip all "../../../ozone/png/icons/$dest" +oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest" for src in battery-*.svg; do export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 92 -h 92 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" - optipng -o7 -strip all "../../../ozone/png/icons/$dest" + oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest" done src="dialog-slice.svg" @@ -65,21 +65,21 @@ export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" -optipng -o7 -strip all "../../../ozone/png/icons/$dest" +oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest" src="key-hover.svg" export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" -optipng -o7 -strip all "../../../ozone/png/icons/$dest" +oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest" src="key.svg" export dest=$(echo $src | sed "s/.svg/.png/") mkdir -p ../../../ozone/png/icons inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest" -optipng -o7 -strip all "../../../ozone/png/icons/$dest" +oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest" # Export auxiliary sidebar icons SIDEBAR_SRC[0]="add.svg" # add.png @@ -162,7 +162,7 @@ do fi magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/sidebar/$dest" - optipng -o7 -strip all "../../../ozone/png/sidebar/$dest" + oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/sidebar/$dest" done @@ -174,7 +174,7 @@ dest="netplay.png" magick convert "$src" xc:"#ffffff" -channel RGB -clut "../../../ozone/png/sidebar/$dest" magick mogrify -resize 64x64 "../../../ozone/png/sidebar/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/sidebar/$dest" -optipng -o7 -strip all "../../../ozone/png/sidebar/$dest" +oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/sidebar/$dest" # Export main RetroArch icon src="menu_quickmenu.svg" @@ -186,4 +186,4 @@ border_size=11 inkscape -z -C -w $size -h $size -f "$src" -e "../../../ozone/png/$dest" magick mogrify -shave $border_size "../../../ozone/png/$dest" magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/$dest" -optipng -o7 -strip all "../../../ozone/png/$dest" +oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/$dest" From 5cd55a52b9eed7620a8a5f02ac149303f258b91f Mon Sep 17 00:00:00 2001 From: Martin Rys Date: Tue, 2 Apr 2024 01:01:59 +0200 Subject: [PATCH 4/4] xmb-convert.sh: Add oxipng step --- scripts/xmb-convert.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/xmb-convert.sh b/scripts/xmb-convert.sh index ac0d2d9bb..8db255b5b 100755 --- a/scripts/xmb-convert.sh +++ b/scripts/xmb-convert.sh @@ -25,11 +25,12 @@ checkCommand() { fi } checkCommand 'inkscape' +checkCommand 'oxipng' if [[ ${exitFlag} -eq 1 ]]; then exit 1 fi - cd -- "$(cd -- "$(dirname -- "$0")" && pwd -P)" inkscape -z -e "$1/png/$2.png" -w 256 -h 256 "../src/xmb/$1/$2.svg" +oxipng --quiet --zopfli --opt max --strip all "$1/png/$2.png"