diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-11-07 11:04:52 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-11-07 11:06:33 +0100 |
commit | ed86f03a9f7c2f58a9111f925bb81303596b394b (patch) | |
tree | f4f3f9f08c36bb9ce1ec8e50ca371dbf58dcd20a /themes/luci-theme-bootstrap/root/etc | |
parent | cd6ad0a242a580fe006e7813c1904fe334299f9a (diff) |
luci-theme-bootstrap: add explicit dark/light mode selection
Register two further "virtual" themes called BootstrapDark and
BootstrapLight which force dark and light mode respectively.
The actual Bootstrap theme itself will continue to auto-select
dark mode preference based on OS/Browser preference settings.
Fixes: #5492
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'themes/luci-theme-bootstrap/root/etc')
-rwxr-xr-x | themes/luci-theme-bootstrap/root/etc/uci-defaults/30_luci-theme-bootstrap | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/themes/luci-theme-bootstrap/root/etc/uci-defaults/30_luci-theme-bootstrap b/themes/luci-theme-bootstrap/root/etc/uci-defaults/30_luci-theme-bootstrap index 4381a15c2e..b66e5b2be3 100755 --- a/themes/luci-theme-bootstrap/root/etc/uci-defaults/30_luci-theme-bootstrap +++ b/themes/luci-theme-bootstrap/root/etc/uci-defaults/30_luci-theme-bootstrap @@ -1,12 +1,28 @@ #!/bin/sh +changed=0 + +set_opt() { + local key=$1 + local val=$2 + + if ! uci -q get "luci.themes.$key" 2>/dev/null; then + uci set "luci.themes.$key=$val" + changed=1 + fi +} + +set_opt Bootstrap /luci-static/bootstrap +set_opt BootstrapDark /luci-static/bootstrap-dark +set_opt BootstrapLight /luci-static/bootstrap-light + if [ "$PKG_UPGRADE" != 1 ]; then - uci get luci.themes.Bootstrap >/dev/null 2>&1 || \ - uci batch <<-EOF - set luci.themes.Bootstrap=/luci-static/bootstrap - set luci.main.mediaurlbase=/luci-static/bootstrap - commit luci - EOF + uci set luci.main.mediaurlbase=/luci-static/bootstrap + changed=1 +fi + +if [ $changed = 1 ]; then + uci commit luci fi exit 0 |