[Etainment] 🎨 Color Your Mabox 3D Logo!

Edit: Non functional changes. Lookafeel…

:artist_palette: Color Your Mabox 3D Logo!

Only for entertainment purposes — just a playful way to experiment with recoloring the Mabox 3D logo.

@napcok is cooking up something more advanced and polished — but in the meantime, this little script was made just for fun. It offers a simple, visual way to tweak the colors of the SVG-based 3D Mabox logo using yad, ImageMagick.


:puzzle_piece: About the SVG

This is a static SVG file containing a 3D-style version of the Mabox logo. Since SVG files can have wildly different internal structures, the script is written specifically for this version — no guarantees it’ll work with others.

Make sure to save the SVG file as:
~/.icons/mb-logo-3d.svg

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="1350"
   height="1404.5"
   version="1.1"
   viewBox="0 0 1350 1404.5"
   id="svg154"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <defs
     id="defs154" />
  <style
     id="style1">.measure-arrow
{
}
.measure-label
{

}
.measure-line
{
}</style>
  <g
     transform="translate(7.4904,11.012)"
     id="g4">
    <path
       d="m 42.16,247.16 71.719,726.26 551.61,364.66 554.16,-367.41 65.029,-726.18 -616.27,-204.02 z"
       fill="#EEDADA"
       id="path3" />
    <path
       d="M 113.61,974.19 C 96.839,818.54 94.397,795.35 41.584,246.13 l 626.71,-206.28 623.29,202.78 -69.336,733.18 -557.89,368.76 z M 640.57,536.98 C 637.3278,534.2132 57.87,269.13 57.19,270.1 c 0,0 43.103,463.12 65.154,694.62 175.89,115.17 351.35,231.05 526.95,346.68 z m -174.46,613.76 c 0,0 -12.32,-302.85 -17.326,-453.86 l -39.155,-17.644 13.867,443.04 c -1.8417,-0.5414 -123.63,-79.894 -123.63,-79.894 l -28.113,-427.64 -31.494,-14.84 23.964,415.01 c 0.13363,2.314 -112.08,-69.499 -112.15,-70.137 l -58.895,-604.94 503.76,235.5 c 0,0 4.7585,663.97 4.0552,663.58 z m 742.27,-183.77 64.614,-691.09 c 0,-0.0294 -588.8,263.04 -588.8,263.04 0,0 -2.2797,771.42 0.44375,772.48 z M 732.03,575.54 1234.89,343.17 c 0,0 -33.266,401.95 -51.188,602.78 -39.452,21.937 -116.5,70.803 -116.5,70.803 l 24.7,-426.73 -33.281,17.21 c 0,0 -18.494,291.63 -28.557,437.36 l -125.27,76.008 14.896,-440.77 -38.658,20.077 -17.691,451.68 -140.31,87.831 c -1.6774,-139.65 9.0024,-663.87 9.0024,-663.87 z M 1252.59,243.62 667.56,51.89 86.47,240.92 659.92,501.22 Z m -828.32,124.89 29.515,-183.46 426.42,8.9635 18.257,174.98 z m 440.8,-163.92 -399.2,-7.1312 -22.951,159.87 438.91,0.55908 z m -249.67,140.79 4.2318,-99.35 -30.318,0.23782 -9.1938,99.296 -113.02,0.0377 19.851,-136.87 358.64,4.8382 13.082,132.39 -105.23,-0.0569 -3.7982,-99.655 -31.414,-0.43053 2.5359,99.586 z"
       fill="#162704"
       image-rendering="optimizeQuality"
       stroke-width="5.5469"
       id="path4" />
    <rect
       x="-7.4903998"
       y="-11.012"
       width="1350"
       height="1404.5"
       fill="none"
       id="rect4" />
  </g>
  <path
     class="path35 path-effect52 measure-helper-line measure-line"
     d="M 7.4904,11.012"
     display="none"
     marker-end="url(#ArrowDIN-end)"
     marker-start="url(#ArrowDIN-start)"
     stroke="#000000"
     stroke-width="0.94488"
     id="path5" />
  <path
     class="path35 path-effect52 measure-helper-line measure-line"
     d="M 7.4904,11.012"
     display="none"
     marker-end="url(#ArrowDIN-end)"
     marker-start="url(#ArrowDIN-start)"
     stroke="#000000"
     stroke-width="0.94488"
     id="path153" />
  <path
     class="path35 path-effect52 measure-DIM-line measure-line"
     d="M 7.4904,11.012"
     display="none"
     marker-end="url(#ArrowDIN-end)"
     marker-start="url(#ArrowDIN-start)"
     stroke="#000000"
     stroke-width="0.94488"
     id="path154" />
</svg>

Give name to script and save to ~/bin.

#!/bin/bash

# Set the path to yad, a graphical dialog library for GTK+
YAD_PATH=yad

# Check if yad is installed
if ! command -v "$YAD_PATH" &> /dev/null; then
    echo "Error: yad is not installed."
    exit 1
fi

# Set the SVG icon path
SVG_ICON=$HOME/.icons/mb-logo-3d.svg

# Function to edit the SVG colors
edit_svg_colors() {
  while true
  do
    # Huidige waarden ophalen
    current_bg=$(grep -m1 'fill=' "$SVG_ICON" | grep -o 'fill="#[A-Fa-f0-9]\{6\}"' | cut -d'"' -f2)
    current_bg_opacity=$(grep -m1 'fill-opacity=' "$SVG_ICON" | grep -o 'fill-opacity="[^"]*"' | cut -d'"' -f2)
    current_fg=$(grep -m2 'fill=' "$SVG_ICON" | tail -n1 | grep -o 'fill="#[A-Fa-f0-9]\{6\}"' | cut -d'"' -f2)
    current_fg_opacity=$(grep -m2 'fill-opacity=' "$SVG_ICON" | tail -n1 | grep -o 'fill-opacity="[^"]*"' | cut -d'"' -f2)

    # YAD formulier tonen
    response=$(yad --form \
      --window-icon="$SVG_ICON" \
        --title="Edit Mabox 3D-Logo Colors" \
        --center \
        --width=400 \
        --field="Background color:CLR" "$current_bg" \
        --field="Opacity:CLR|TXT" "$current_bg_opacity" \
        --field="Foreground color:CLR" "$current_fg" \
        --field="Opacity:CLR|TXT" "$current_fg_opacity" \
        --separator="|")

    # Annuleren of sluiten
    if [ $? -ne 0 || -z "$response" ]; then
      break
    fi

    # Nieuwe waarden uit response halen
    IFS="|" read -r new_bg new_bg_opacity new_fg new_fg_opacity <<< "$response"

    # Backup (alleen eerste keer nodig, maar mag hier blijven)
    cp "$SVG_ICON" "${SVG_ICON}.bak"

    # Validate the new colors and opacity
    if [[ ! "$new_bg" =~ ^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$ ]]; then
      echo "Error: Invalid background color."
      break
    fi
    if [[ ! "$new_fg" =~ ^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$ ]]; then
      echo "Error: Invalid foreground color."
      break
    fi
    if [[ ! "$new_bg_opacity" =~ ^[0-9.]+(.[0-9]+)?$ ]] || (( $(echo "$new_bg_opacity < 0 || $new_bg_opacity > 1" | bc -l) )); then
      echo "Error: Invalid background opacity."
      break
    fi
    if [[ ! "$new_fg_opacity" =~ ^[0-9.]+(.[0-9]+)?$ ]] || (( $(echo "$new_fg_opacity < 0 || $new_fg_opacity > 1" | bc -l) )); then
      echo "Error: Invalid foreground opacity."
      break
    fi

    # Pas SVG aan met nieuwe waarden
    awk -v bg="$new_bg" -v bgo="$new_bg_opacity" \
        -v fg="$new_fg" -v fgo="$new_fg_opacity" \
        'BEGIN{bgdone=0;fgdone=0}
        /<path /{
            if (!bgdone) {
                sub(/fill="#[A-Fa-f0-9]+"/, "fill=\""bg"\"")
                sub(/fill-opacity="[0-9.]+"/, "fill-opacity=\""bgo"\"")
                bgdone=1
            } else if (!fgdone) {
                sub(/fill="#[A-Fa-f0-9]+"/, "fill=\""fg"\"")
                sub(/fill-opacity="[0-9.]+"/, "fill-opacity=\""fgo"\"")
                fgdone=1
            }
        }
        {print}' "$SVG_ICON" > "$SVG_ICON".tmp

    mv "$SVG_ICON".tmp "$SVG_ICON"

    # Bevestiging
    yad --info --text="SVG updated successfully!\n\nYou can now change more values or press Cancel to exit." \
        --timeout=3 --center
  done
}

# Call the function
edit_svg_colors

Have fun…

:bird: :dashing_away:

2 Likes

:bird:

1 Like

Update: Fixed Cancel process when using Yad colors.

SVG became uneditable.

:bird:

scrotinscrotinscrot… :camera_flash: :laptop:

:bird:

1 Like

I like the idea of replacing colors also in panel, menus and Conky :clap:
Currently, it does not work with default Mabox configs.
Noted with big letters in my TODO list :wink:

I modified 3D logo you send me some months ago. It currently can handle transparency for both colors. Try it with Conky. Green parts have a little transparency.

And you can see wallpaper through it…

1 Like

Cleaned logo SVG a little bit by editing in text editor. (Lite XL is handy while working with colors). Probably SVG can be cleaned more but I’m not expert in SVG :wink:

There are 4 attributes for replacement:

  • fill (hex color)
  • fill-opacity ( values from 0.0 to 1.0 )

Modified logo:

This is more readable than version before… :nerd_face:

Just installed lite-xl. to see how it works. :wink:

The nice thing of Geany = it shows the color when hoover over hex color.

What is the advantage above geany with lite-xl?

edit: The left panel is nice though of lite-xl. Quick acces to files.
:bird:

EDIT2: I see now you have colors shown at hex code. Need to look at lite-xl settings.

The only advantage for me is that Lite XL shows colors without hovering on it.
I don’t remember if this is enabled by default. Might need some configurations or plugin.

Together with our Color Menu W-A-c this makes work on themes super easy and fast.

1 Like

Logo optimized again - last time :slight_smile:
Size is 2,4KB only.
Optimized by online tool : https://optimize.svgomg.net/

1 Like

Both versions from AUR are not working with the plugins.

I downloaded the appimg to see how this goes.

First i ran it from download dir to test, but than it shows only download dir files.

So i put the appimg in home dir. Now i see all files (Ctrl-h for hidden files).

No edit of config needed for this appimg.

The github plugin version is old i guess.

:bird:

I use lite-xl from extra repo.
and lpm ( Lite XL plugin manager from AUR)
works fine.

I will probably never touch anything like snaps, flatpaks and so on :wink:

napcok@mabox ~/emu $ yay lite-xl
4 aur/lpm 1.4.0-1 (+0 0.00) (Installed)
    A lite-xl plugin manager.
3 aur/lpm-git 1.2.9.r47.gbf98e52-1 (+5 0.08) 
    A lite-xl plugin manager.
2 aur/lite-xl-git v2.1.3.r2313.2e8d59b8-1 (+3 0.00) 
    A lightweight text editor written in Lua (master branch)
1 extra/lite-xl 2.1.7-3 (345.2 KiB 1.1 MiB) (Installed)
    A lightweight text editor written in Lua

That’s how I started. Also using lpm.

  • Started over and installed with yay.

Now plugins are working :slight_smile:, without need of lpm.

:bird:

Update: Svg coloring script.

  • Added opacity. fg and bg.
  • Using latest svg structure.

Download and Save SVG as to location.

Change PATH.

SVG="$HOME/Documents/MABOX_STUFF/38c09de35ec0709c68700e1b361248437c2de3b2.svg"
#!/bin/bash

SVG="$HOME/Documents/MABOX_STUFF/38c09de35ec0709c68700e1b361248437c2de3b2.svg"
TMP_SVG="/tmp/modified_icon.svg"

while true; do
  # Huidige waarden ophalen
  current_bg=$(grep -m1 'fill=' "$SVG" | grep -o 'fill="#[A-Fa-f0-9]\{6\}"' | cut -d'"' -f2)
  current_bg_opacity=$(grep -m1 'fill-opacity=' "$SVG" | grep -o 'fill-opacity="[^"]*"' | cut -d'"' -f2)
  current_fg=$(grep -m2 'fill=' "$SVG" | tail -n1 | grep -o 'fill="#[A-Fa-f0-9]\{6\}"' | cut -d'"' -f2)
  current_fg_opacity=$(grep -m2 'fill-opacity=' "$SVG" | tail -n1 | grep -o 'fill-opacity="[^"]*"' | cut -d'"' -f2)

  # YAD formulier tonen
  response=$(yad --form \
    --title="Edit SVG Colors" \
    --window-icon=$SVG \
    --center \
    --width=400 \
    --field="Background color:CLR" "$current_bg" \
    --field="Background opacity:TXT" "$current_bg_opacity" \
    --field="Foreground color:CLR" "$current_fg" \
    --field="Foreground opacity:TXT" "$current_fg_opacity" \
    --separator="|")

  # Annuleren of sluiten
  [[ $? -ne 0 || -z "$response" ]] && break

  # Nieuwe waarden uit response halen
  IFS="|" read -r new_bg new_bg_opacity new_fg new_fg_opacity <<< "$response"

  # Backup (alleen eerste keer nodig, maar mag hier blijven)
  cp "$SVG" "${SVG}.bak"

  # Pas SVG aan met nieuwe waarden
  awk -v bg="$new_bg" -v bgo="$new_bg_opacity" \
      -v fg="$new_fg" -v fgo="$new_fg_opacity" \
      'BEGIN{bgdone=0;fgdone=0}
      /<path /{
          if (!bgdone) {
              sub(/fill="#[A-Fa-f0-9]+"/, "fill=\""bg"\"")
              sub(/fill-opacity="[0-9.]+"/, "fill-opacity=\""bgo"\"")
              bgdone=1
          } else if (!fgdone) {
              sub(/fill="#[A-Fa-f0-9]+"/, "fill=\""fg"\"")
              sub(/fill-opacity="[0-9.]+"/, "fill-opacity=\""fgo"\"")
              fgdone=1
          }
      }
      {print}' "$SVG" > "$TMP_SVG"

  mv "$TMP_SVG" "$SVG"

  # Bevestiging
  yad --info --text="SVG updated successfully!\n\nYou can now change more values or press Cancel to exit." \
      --timeout=3 --center
done

:bird:

1 Like

EDIT: added --window-icon=$SVG \

With updated version the SVG icon in main window is updated too.

Preview…

OMG awesome!! I’m only just seeing this now and I love it :grinning_face: I’ll let you know if I have any issues once I get a chance to test it out but it looks even better than I imagined. Good job :+1: this totally made my day!

Updated Script:

Yad menu layout.

:bird: