Simplify as we don't need to do any watching

Just rely on explicit applyTheme/reloadTheme
This commit is contained in:
David Heinemeier Hansson
2026-05-19 20:54:20 +02:00
parent 695d2c6e7c
commit bad94996ac
4 changed files with 10 additions and 64 deletions
+4 -24
View File
@@ -105,46 +105,26 @@ QtObject {
shellValues = parsed shellValues = parsed
} }
property bool themeReloadSuspended: false
function suspendThemeReloads() {
themeReloadSuspended = true
}
function resumeThemeReloads() {
themeReloadSuspended = false
}
function reloadTheme() { function reloadTheme() {
if (themeReloadSuspended) return
colorsFile.reload() colorsFile.reload()
shellFile.reload() shellFile.reload()
} }
// `omarchy-theme-set` recreates the theme/ directory via rm+mv, which kills // Startup load plus manual reloadTheme() support. Runtime theme switches
// the inotify watch on colors.toml. Use theme.name (overwritten in place) as // normally push the payload explicitly through shell IPC.
// a tripwire that forces a fresh reload after each swap.
property FileView colorsFile: FileView { property FileView colorsFile: FileView {
id: colorsFile id: colorsFile
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/colors.toml" path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/colors.toml"
watchChanges: true watchChanges: false
printErrors: false printErrors: false
onLoaded: root.loadColors(text()) onLoaded: root.loadColors(text())
onFileChanged: root.reloadTheme()
} }
property FileView shellFile: FileView { property FileView shellFile: FileView {
id: shellFile id: shellFile
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml" path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml"
watchChanges: true watchChanges: false
printErrors: false printErrors: false
onLoaded: root.loadShell(text()) onLoaded: root.loadShell(text())
onLoadFailed: root.loadShell("") onLoadFailed: root.loadShell("")
onFileChanged: root.reloadTheme()
}
property FileView themeNameFile: FileView {
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme.name"
watchChanges: true
printErrors: false
onFileChanged: root.reloadTheme()
} }
} }
+3 -28
View File
@@ -13,8 +13,8 @@ import Quickshell.Io
// their own rounding via theme/hyprland.lua; the user toggle via // their own rounding via theme/hyprland.lua; the user toggle via
// `omarchy style corners <round|sharp>` flips Hyprland's flag file // `omarchy style corners <round|sharp>` flips Hyprland's flag file
// and Hyprland's auto-reload pushes the new value out. The shell picks // and Hyprland's auto-reload pushes the new value out. The shell picks
// up the change here by re-running `hyprctl getoption` whenever either // up the change here by re-running `hyprctl getoption` when theme IPC
// of those input files changes. // manually reloads the theme and whenever user toggle files change.
// //
// Typography, spacing, and bar size come from `theme/shell.toml`. // Typography, spacing, and bar size come from `theme/shell.toml`.
// `[font] base-size` is the rem root; every `Style.font.<token>` derives // `[font] base-size` is the rem root; every `Style.font.<token>` derives
@@ -348,23 +348,11 @@ QtObject {
gapsOutProc.running = true gapsOutProc.running = true
} }
property bool themeReloadSuspended: false
function suspendThemeReloads() {
themeReloadSuspended = true
}
function resumeThemeReloads() {
themeReloadSuspended = false
}
function scheduleRefresh() { function scheduleRefresh() {
if (themeReloadSuspended) return
refreshTimer.restart() refreshTimer.restart()
} }
function reloadTheme() { function reloadTheme() {
if (themeReloadSuspended) return
shellTomlFile.reload() shellTomlFile.reload()
scheduleRefresh() scheduleRefresh()
} }
@@ -507,18 +495,6 @@ QtObject {
onTriggered: root.refresh() onTriggered: root.refresh()
} }
// The theme name flips whenever `omarchy-theme-set` swaps the theme/
// symlink; that's when theme/hyprland.lua's `rounding` value changes
// and the new theme/shell.toml drops into place. Force a reload of
// shell.toml here so we don't wait on the inotify watch — Color.qml
// uses the same tripwire for the same reason.
property FileView themeNameFile: FileView {
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme.name"
watchChanges: true
printErrors: false
onFileChanged: root.reloadTheme()
}
// `omarchy style corners <round|sharp>` and `omarchy toggle window-gaps` // `omarchy style corners <round|sharp>` and `omarchy toggle window-gaps`
// create/remove these flag files. Hyprland reloads its config when sourced // create/remove these flag files. Hyprland reloads its config when sourced
// files change, then hyprctl reflects the new effective values. // files change, then hyprctl reflects the new effective values.
@@ -543,11 +519,10 @@ QtObject {
property FileView shellTomlFile: FileView { property FileView shellTomlFile: FileView {
id: shellTomlFile id: shellTomlFile
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml" path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml"
watchChanges: true watchChanges: false
printErrors: false printErrors: false
onLoaded: root.loadShell(text()) onLoaded: root.loadShell(text())
onLoadFailed: root.loadShell("") onLoadFailed: root.loadShell("")
onFileChanged: root.reloadTheme()
} }
Component.onCompleted: { Component.onCompleted: {
+3 -4
View File
@@ -74,13 +74,12 @@ Item {
function applyPendingTheme() { function applyPendingTheme() {
if (pendingThemeVersion !== backgroundVersion) return if (pendingThemeVersion !== backgroundVersion) return
NoctaliaCommons.Color.resumeThemeReloads()
NoctaliaCommons.Color.loadColors(pendingColorsRaw) NoctaliaCommons.Color.loadColors(pendingColorsRaw)
NoctaliaCommons.Color.loadShell(pendingShellRaw) NoctaliaCommons.Color.loadShell(pendingShellRaw)
// Style watches the same shell.toml for [font] and [bar] sizing; push // Push style tokens synchronously so the type scale flips with the
// synchronously so the type scale flips with the background instead of // background reveal instead of waiting for a separate reload path.
// waiting on inotify debounce.
NoctaliaCommons.Style.loadShell(pendingShellRaw) NoctaliaCommons.Style.loadShell(pendingShellRaw)
NoctaliaCommons.Style.scheduleRefresh()
pendingThemeVersion = -1 pendingThemeVersion = -1
pendingColorsRaw = "" pendingColorsRaw = ""
pendingShellRaw = "" pendingShellRaw = ""
-8
View File
@@ -582,8 +582,6 @@ ShellRoot {
var shellRaw = "" var shellRaw = ""
try { colorsRaw = Qt.atob(String(colorsB64 || "")) } catch (e) { colorsRaw = "" } try { colorsRaw = Qt.atob(String(colorsB64 || "")) } catch (e) { colorsRaw = "" }
try { shellRaw = Qt.atob(String(shellB64 || "")) } catch (e2) { shellRaw = "" } try { shellRaw = Qt.atob(String(shellB64 || "")) } catch (e2) { shellRaw = "" }
NoctaliaCommons.Color.resumeThemeReloads()
NoctaliaCommons.Style.resumeThemeReloads()
NoctaliaCommons.Color.loadColors(colorsRaw) NoctaliaCommons.Color.loadColors(colorsRaw)
NoctaliaCommons.Color.loadShell(shellRaw) NoctaliaCommons.Color.loadShell(shellRaw)
NoctaliaCommons.Style.loadShell(shellRaw) NoctaliaCommons.Style.loadShell(shellRaw)
@@ -591,12 +589,6 @@ ShellRoot {
return "ok" return "ok"
} }
function suspendThemeReloads(): string {
NoctaliaCommons.Color.suspendThemeReloads()
NoctaliaCommons.Style.suspendThemeReloads()
return "ok"
}
function reloadTheme(): string { function reloadTheme(): string {
NoctaliaCommons.Color.reloadTheme() NoctaliaCommons.Color.reloadTheme()
NoctaliaCommons.Style.reloadTheme() NoctaliaCommons.Style.reloadTheme()