Compiled image with a different default theme

Simple (basic) question.

When I compile and install OpenWRT to a Raspberry Pi board, the default LuCI theme is Bootstrap.
I have created a customized theme to use on LuCI and I would like to know if it's possible having this theme as the default theme right out of the box.
This is because when I need to perform a system reset, Bootstrap will return as the default theme.

Sure it is.
Just edit in the LuCI config file the lines that set the current template.

You can test by changing the template in LuCI and see how /etc/config/luci changes.

hint: "main" section, "mediaurlbase" item.
(additionally naturally also the "themes" section...)

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

1 Like

Just to let everyone know, when I include Material as a theme option using make menuconfig, this theme will be automatically set as the default, even if Bootstrap is being displayed as default.

Yeah, it may require some patching, as each theme has install script that tries to set it as default. Having multiple themes may lead to a race that which of them is installed last.

I include both bootstrap, openwrt2020 and material in my build, and marginally patch the install scripts first, so that material and openwrt2020 do no hijack the default that I set specifically.

--- a/modules/luci-base/root/etc/config/luci
+++ b/modules/luci-base/root/etc/config/luci
@@ -23,6 +23,7 @@ config internal ccache
 	option enable 1
 		
 config internal themes
+	option Bootstrap '/luci-static/bootstrap'
 
 config internal apply
 	option rollback 90
--- a/themes/luci-theme-material/root/etc/uci-defaults/30_luci-theme-material
+++ b/themes/luci-theme-material/root/etc/uci-defaults/30_luci-theme-material
@@ -4,7 +4,7 @@ if [ "$PKG_UPGRADE" != 1 ]; then
 	uci get luci.themes.Material >/dev/null 2>&1 || \
 	uci batch <<-EOF
 		set luci.themes.Material=/luci-static/material
-		set luci.main.mediaurlbase=/luci-static/material
+#		set luci.main.mediaurlbase=/luci-static/material
 		commit luci
 	EOF
 fi
--- a/themes/luci-theme-openwrt-2020/root/etc/uci-defaults/30_luci-theme-openwrt-2020
+++ b/themes/luci-theme-openwrt-2020/root/etc/uci-defaults/30_luci-theme-openwrt-2020
@@ -4,7 +4,7 @@ if [ "$PKG_UPGRADE" != 1 ]; then
 	uci get luci.themes.OpenWrt2020 >/dev/null 2>&1 || \
 	uci batch <<-EOF
 		set luci.themes.OpenWrt2020=/luci-static/openwrt2020
-		set luci.main.mediaurlbase=/luci-static/openwrt2020
+#		set luci.main.mediaurlbase=/luci-static/openwrt2020
 		commit luci
 	EOF
 fi

1 Like

Hi @hnyman and all,

A new firmware has been compiled with my theme included (set '*' on menuconfig under LuCI > Themes > Mytheme).
Inside bin/packages aarch64_cortex-a72/luci there's a IPK file for my theme.
When I flash this new compiled firmware to my Raspberry Pi, the default theme is bootstrap. So I go to /etc/config/luci to check the configuration and here's what I have:

config core 'main'
	option lang 'auto'
	option resourcebase '/luci-static/resources'
	option ubuspath '/ubus/'
	option mediaurlbase '/luci-static/material'

and

config internal 'themes'
	option Bootstrap '/luci-static/bootstrap'
	option BootstrapDark '/luci-static/bootstrap-dark'
	option BootstrapLight '/luci-static/bootstrap-light'
	option Material '/luci-static/material'

My theme isn't even showing on these lists.

If I try to upload this IPK file from my theme going System > Software > Language/Style. I get a message my theme is up to date.

Can anyone give me a hint what's going on?

First guess: you selected "keep settings" in sysupgrade?
So that your old settings from the previous build are there...

Note that the current build's defaults are stored in /rom/etc/config
If you have included the theme in the build, the luci config there likely shows it...

@hnyman I'm not upgrading my RPI board, I'm using rpiboot and that Raspberry Pi Imager to erase content from memory and flashing a new firmware to my raspberry pi board.