Skip to content

Commit

Permalink
scripts: Code cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
nana-4 committed Jan 31, 2019
1 parent 61e252f commit f66d436
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions install.sh
Expand Up @@ -15,7 +15,7 @@ GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30')
LATEST_GS_VERSION="${GS_VERSIONS[-1]}"

# Set a proper gnome-shell theme version
if command -v gnome-shell >/dev/null ; then
if command -v gnome-shell >/dev/null; then
CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"
for version in "${GS_VERSIONS[@]}"; do
if (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then
Expand Down Expand Up @@ -126,7 +126,7 @@ install_gdm() {
local GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
local UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/ubuntu.css"

if [[ -f "$GS_THEME_FILE" ]] && command -v glib-compile-resources >/dev/null ; then
if [[ -f "$GS_THEME_FILE" ]] && command -v glib-compile-resources >/dev/null; then
echo "Installing '$GS_THEME_FILE'..."
cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak"
glib-compile-resources \
Expand Down
4 changes: 2 additions & 2 deletions render-assets.sh
Expand Up @@ -7,11 +7,11 @@ if [[ ! "$(command -v inkscape || command -v rendersvg)" ]]; then
fi

if [[ ! "$(command -v optipng)" ]]; then
echo "'optipng' needs to be installed to optimize the resulting PNG!"
echo "'optipng' needs to be installed to optimize the resulting PNG."
fi

chrome() (
cd ./src/chrome
cd src/chrome
./render-assets.sh
)

Expand Down
6 changes: 3 additions & 3 deletions src/chrome/render-asset.sh
Expand Up @@ -8,12 +8,12 @@ OPTIPNG="$(command -v optipng)" || true
i="$1"

echo "Rendering '$i.png'"
if [[ -n "${RENDER_SVG}" ]] ; then
if [[ -n "${RENDER_SVG}" ]]; then
"$RENDER_SVG" --dpi 96 "$i.svg" "$i.png"
else
"$INKSCAPE" --export-dpi=96 --export-png="$i.png" "$i.svg" >/dev/null
fi

if [[ -n "${OPTIPNG}" ]] ; then
"$OPTIPNG" -o7 --quiet "$i.png"
if [[ -n "${OPTIPNG}" ]]; then
"$OPTIPNG" -o7 --quiet "$i.png"
fi
2 changes: 1 addition & 1 deletion src/chrome/render-assets.sh
Expand Up @@ -3,7 +3,7 @@ set -ueo pipefail

# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if command -v parallel >/dev/null ; then
if command -v parallel >/dev/null; then
cmd=(parallel)
else
cmd=(xargs -n1)
Expand Down
22 changes: 11 additions & 11 deletions src/gtk-2.0/render-asset.sh
Expand Up @@ -17,7 +17,7 @@ i="$2"

# @TODO: remove $ZOOM when it will be fixed/implemented in resvg
GTK2_HIDPI="$(echo "${GTK2_HIDPI-False}" | tr '[:upper:]' '[:lower:]')"
if [[ "${GTK2_HIDPI}" == "true" ]] ; then
if [[ "${GTK2_HIDPI}" == "true" ]]; then
DPI=192
ZOOM=2
else
Expand All @@ -26,19 +26,19 @@ else
fi

echo "Rendering '$ASSETS_DIR/$i.png'"
if [[ -n "${RENDER_SVG}" ]] ; then
# @TODO: remove --zoom when it will be fixed/implemented in resvg
if [[ -n "${RENDER_SVG}" ]]; then
# @TODO: remove --zoom when it will be fixed/implemented in resvg
"$RENDER_SVG" --export-id "$i" \
--dpi ${DPI} \
--zoom ${ZOOM} \
"$SRC_FILE" "$ASSETS_DIR/$i.png"
--dpi ${DPI} \
--zoom ${ZOOM} \
"$SRC_FILE" "$ASSETS_DIR/$i.png"
else
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-dpi=${DPI} \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null
--export-id-only \
--export-dpi=${DPI} \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null
fi

if [[ -n "${OPTIPNG}" ]] ; then
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
if [[ -n "${OPTIPNG}" ]]; then
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
fi
2 changes: 1 addition & 1 deletion src/gtk-2.0/render-assets.sh
Expand Up @@ -3,7 +3,7 @@ set -ueo pipefail

# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if command -v parallel >/dev/null ; then
if command -v parallel >/dev/null; then
cmd=(parallel)
else
cmd=(xargs -n1)
Expand Down
32 changes: 16 additions & 16 deletions src/gtk/render-asset.sh
Expand Up @@ -11,31 +11,31 @@ ASSETS_DIR="assets"
i="$1"

echo "Rendering '$ASSETS_DIR/$i.png'"
if [[ -n "${RENDER_SVG}" ]] ; then
if [[ -n "${RENDER_SVG}" ]]; then
"$RENDER_SVG" --export-id "$i" \
"$SRC_FILE" "$ASSETS_DIR/$i.png"
"$SRC_FILE" "$ASSETS_DIR/$i.png"
else
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null
--export-id-only \
--export-png="$ASSETS_DIR/$i.png" "$SRC_FILE" >/dev/null
fi
if [[ -n "${OPTIPNG}" ]] ; then
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
if [[ -n "${OPTIPNG}" ]]; then
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i.png"
fi

echo "Rendering '$ASSETS_DIR/$i@2.png'"
if [[ -n "${RENDER_SVG}" ]] ; then
# @TODO: remove --zoom when it will be fixed/implemented in resvg
if [[ -n "${RENDER_SVG}" ]]; then
# @TODO: remove --zoom when it will be fixed/implemented in resvg
"$RENDER_SVG" --export-id "$i" \
--dpi 192 \
--zoom 2 \
"$SRC_FILE" "$ASSETS_DIR/$i@2.png"
--dpi 192 \
--zoom 2 \
"$SRC_FILE" "$ASSETS_DIR/$i@2.png"
else
"$INKSCAPE" --export-id="$i" \
--export-id-only \
--export-dpi=192 \
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null
--export-id-only \
--export-dpi=192 \
--export-png="$ASSETS_DIR/$i@2.png" "$SRC_FILE" >/dev/null
fi
if [[ -n "${OPTIPNG}" ]] ; then
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
if [[ -n "${OPTIPNG}" ]]; then
"$OPTIPNG" -o7 --quiet "$ASSETS_DIR/$i@2.png"
fi
2 changes: 1 addition & 1 deletion src/gtk/render-assets.sh
Expand Up @@ -3,7 +3,7 @@ set -ueo pipefail

# Make sure that parallel is GNU parallel and not moreutils.
# Otherwise, it fails silently. There's no smooth way to detect this.
if command -v parallel >/dev/null ; then
if command -v parallel >/dev/null; then
cmd=(parallel)
else
cmd=(xargs -n1)
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Expand Up @@ -25,7 +25,7 @@ GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30')
LATEST_GS_VERSION="${GS_VERSIONS[-1]}"

# Set a proper gnome-shell theme version
if command -v gnome-shell >/dev/null ; then
if command -v gnome-shell >/dev/null; then
CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"
for version in "${GS_VERSIONS[@]}"; do
if (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then
Expand Down

0 comments on commit f66d436

Please sign in to comment.