diff --git a/config/nushell/scripts/theme-switch.nu b/config/nushell/scripts/theme-switch.nu index 67da04e..9f3c452 100755 --- a/config/nushell/scripts/theme-switch.nu +++ b/config/nushell/scripts/theme-switch.nu @@ -2,20 +2,35 @@ def apply-theme [selected: string] { let choice = if $selected == "auto" { - let color_scheme = (bash -lc "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null || true" | str trim) - - if ($color_scheme | str contains "prefer-dark") { + let mode = (try { darkman get | str trim } catch { "" }) + if $mode == "dark" { "mocha" - } else if ($color_scheme | str contains "prefer-light") { + } else if $mode == "light" { "latte" } else { - let hour = (date now | format date "%H" | into int) - if ($hour >= 19 or $hour < 7) { "mocha" } else { "latte" } + let color_scheme = (bash -lc "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null || true" | str trim) + + if ($color_scheme | str contains "prefer-dark") { + "mocha" + } else if ($color_scheme | str contains "prefer-light") { + "latte" + } else { + let hour = (date now | format date "%H" | into int) + if ($hour >= 19 or $hour < 7) { "mocha" } else { "latte" } + } } } else { $selected } + let wanted_darkman = if $choice == "mocha" { "dark" } else { "light" } + let current_darkman = (try { darkman get | str trim } catch { "" }) + if $current_darkman != "" and $current_darkman != $wanted_darkman { + try { + bash -c $"darkman set ($wanted_darkman) &" + } catch {} + } + let home = $env.HOME let base = $"($home)/.config/themes/catppuccin/($choice)"