Modify default-logo.svg

Started by GaardenZwerch, June 11, 2020, 02:08:18 PM

Previous topic - Next topic
Hi, I have been doing this for some time now (thanks Franco):
Quote
You could copy the theme, modify the svg and switch to the new theme in System: Settings: General

# cp -r /usr/local/opnsense/www/themes/{opnsense,custom}
Edit...
/usr/local/opnsense/www/themes/custom/build/images/default-logo.svg
And set "custom" theme from the GUI.

because I have a lot of OPNSense firewalls and I like to see which one I'm modifying. It doesn't seem to work anymore.
To be accurate I put a modified default-logo..png up there and deleted the default-logo.svg.
Or is there a better way of doing this? What I need is to display the hostname of the firewall instead of the opnsense logo.

Thanks for any tips,

Frank

You need to replicate the exact file name and .svg extension.


No,
the code seems to say that .svg has precedence over .png, so if I delete .svg, it should display the .png:

   
<?php if (file_exists("/usr/local/opnsense/www/themes/{$themename}/build/images/default-logo.svg")) : ?>

          <img src="<?= cache_safe("/ui/themes/{$themename}/build/images/default-logo.svg") ?>" height="30" alt="logo" />
   
<?php else : ?>

          <img src="<?= cache_safe("/ui/themes/{$themename}/build/images/default-logo.png") ?>" height="30" alt="logo" />
   
<?php endif ?>


Still the best way to do it. Usually the hostname in the upper right corner can help identify the box as well unless for some reason multiple boxes share the same host name.


Cheers,
Franco

Hi Franco,

is there some new cache-ing or something in place, because I can't seem to get it to work anymore...
The name at the right works, of course, but I really like to see the hostname in big friendly letters, as I always have several configs open at once.

Any other idea to achieve this would also be welcome, like having a script that overwrites default-logo.svg based on the hostname.

Thanks for any tipps,

Well, there is another way although it will be problematic for the health check as you are modifying existing package files, but here it goes...

https://docs.opnsense.org/development/backend/autorun.html

You can set up an "update" routine script that deletes the svg of the default theme and replaces the png file with the one you want.


Cheers,
Franco

Hi,

just a follow up, in case anyone else wants this:
I now create a custom theme, and replace the default-logo.svg with:

<svg xmlns="http://www.w3.org/2000/svg"
     width="150" height="30" viewBox="0 0 150 30">
  <text x="10" y="25"
        font-family="Arial"
         style="fill:orange"
        font-size="24">
    HOSTNAME
  </text>
</svg>


Thanks