Skip to content

Instantly share code, notes, and snippets.

@stefanpejcic
Created October 6, 2025 18:30
Show Gist options
  • Select an option

  • Save stefanpejcic/e3ce1b8b12603667da7e9e43fd610da6 to your computer and use it in GitHub Desktop.

Select an option

Save stefanpejcic/e3ce1b8b12603667da7e9e43fd610da6 to your computer and use it in GitHub Desktop.
Script for OpenPanel UI startup: sets dark mode by default and disables user/system theme switching - https://openpanel.com/
#!/bin/bash
: '
Example script that executes on openpanel UI container startup:
sets dark mode by default and disables user/system theme switching.
'
base="/templates/base.html"
switcher="/templates/partials/theme_switcher.html"
# 1. delete theme switcher from the sidebar
rm -rf ${switcher}
# 2. remove inline code from `head` that handles the switch on page load
sed -i '/THEME_SCRIPT_START/,/THEME_SCRIPT_END/ s/^/<!-- /; /THEME_SCRIPT_START/,/THEME_SCRIPT_END/ s/$/ -->/' ${base}
# 3. OPTIONAL: set dark as the default
sed -i 's|<html lang="en" class="h-full" style="color-scheme: "|<html lang="en" class="h-full" style="color-scheme: dark;|" ${base}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment