fix(theme): sync manual theme switches to darkman portal
This commit is contained in:
1 parent
83216e7b64
commit
0063fde73b
1 file changed
+21
-6
@@ -2,20 +2,35 @@
|
|||||||
|
|
||||||
def apply-theme [selected: string] {
|
def apply-theme [selected: string] {
|
||||||
let choice = if $selected == "auto" {
|
let choice = if $selected == "auto" {
|
||||||
let color_scheme = (bash -lc "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null || true" | str trim)
|
let mode = (try { darkman get | str trim } catch { "" })
|
||||||
|
if $mode == "dark" {
|
||||||
if ($color_scheme | str contains "prefer-dark") {
|
|
||||||
"mocha"
|
"mocha"
|
||||||
} else if ($color_scheme | str contains "prefer-light") {
|
} else if $mode == "light" {
|
||||||
"latte"
|
"latte"
|
||||||
} else {
|
} else {
|
||||||
let hour = (date now | format date "%H" | into int)
|
let color_scheme = (bash -lc "gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null || true" | str trim)
|
||||||
if ($hour >= 19 or $hour < 7) { "mocha" } else { "latte" }
|
|
||||||
|
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 {
|
} else {
|
||||||
$selected
|
$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 home = $env.HOME
|
||||||
let base = $"($home)/.config/themes/catppuccin/($choice)"
|
let base = $"($home)/.config/themes/catppuccin/($choice)"
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user