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
}
property bool themeReloadSuspended: false
function suspendThemeReloads() {
themeReloadSuspended = true
}
function resumeThemeReloads() {
themeReloadSuspended = false
}
function reloadTheme() {
if (themeReloadSuspended) return
colorsFile.reload()
shellFile.reload()
}
// `omarchy-theme-set` recreates the theme/ directory via rm+mv, which kills
// the inotify watch on colors.toml. Use theme.name (overwritten in place) as
// a tripwire that forces a fresh reload after each swap.
// Startup load plus manual reloadTheme() support. Runtime theme switches
// normally push the payload explicitly through shell IPC.
property FileView colorsFile: FileView {
id: colorsFile
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/colors.toml"
watchChanges: true
watchChanges: false
printErrors: false
onLoaded: root.loadColors(text())
onFileChanged: root.reloadTheme()
}
property FileView shellFile: FileView {
id: shellFile
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml"
watchChanges: true
watchChanges: false
printErrors: false
onLoaded: root.loadShell(text())
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
// `omarchy style corners <round|sharp>` flips Hyprland's flag file
// and Hyprland's auto-reload pushes the new value out. The shell picks
// up the change here by re-running `hyprctl getoption` whenever either
// of those input files changes.
// up the change here by re-running `hyprctl getoption` when theme IPC
// manually reloads the theme and whenever user toggle files change.
//
// Typography, spacing, and bar size come from `theme/shell.toml`.
// `[font] base-size` is the rem root; every `Style.font.<token>` derives
@@ -348,23 +348,11 @@ QtObject {
gapsOutProc.running = true
}
property bool themeReloadSuspended: false
function suspendThemeReloads() {
themeReloadSuspended = true
}
function resumeThemeReloads() {
themeReloadSuspended = false
}
function scheduleRefresh() {
if (themeReloadSuspended) return
refreshTimer.restart()
}
function reloadTheme() {
if (themeReloadSuspended) return
shellTomlFile.reload()
scheduleRefresh()
}
@@ -507,18 +495,6 @@ QtObject {
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`
// create/remove these flag files. Hyprland reloads its config when sourced
// files change, then hyprctl reflects the new effective values.
@@ -543,11 +519,10 @@ QtObject {
property FileView shellTomlFile: FileView {
id: shellTomlFile
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml"
watchChanges: true
watchChanges: false
printErrors: false
onLoaded: root.loadShell(text())
onLoadFailed: root.loadShell("")
onFileChanged: root.reloadTheme()
}
Component.onCompleted: {
+3 -4
View File
@@ -74,13 +74,12 @@ Item {
function applyPendingTheme() {
if (pendingThemeVersion !== backgroundVersion) return
NoctaliaCommons.Color.resumeThemeReloads()
NoctaliaCommons.Color.loadColors(pendingColorsRaw)
NoctaliaCommons.Color.loadShell(pendingShellRaw)
// Style watches the same shell.toml for [font] and [bar] sizing; push
// synchronously so the type scale flips with the background instead of
// waiting on inotify debounce.
// Push style tokens synchronously so the type scale flips with the
// background reveal instead of waiting for a separate reload path.
NoctaliaCommons.Style.loadShell(pendingShellRaw)
NoctaliaCommons.Style.scheduleRefresh()
pendingThemeVersion = -1
pendingColorsRaw = ""
pendingShellRaw = ""
-8
View File
@@ -582,8 +582,6 @@ ShellRoot {
var shellRaw = ""
try { colorsRaw = Qt.atob(String(colorsB64 || "")) } catch (e) { colorsRaw = "" }
try { shellRaw = Qt.atob(String(shellB64 || "")) } catch (e2) { shellRaw = "" }
NoctaliaCommons.Color.resumeThemeReloads()
NoctaliaCommons.Style.resumeThemeReloads()
NoctaliaCommons.Color.loadColors(colorsRaw)
NoctaliaCommons.Color.loadShell(shellRaw)
NoctaliaCommons.Style.loadShell(shellRaw)
@@ -591,12 +589,6 @@ ShellRoot {
return "ok"
}
function suspendThemeReloads(): string {
NoctaliaCommons.Color.suspendThemeReloads()
NoctaliaCommons.Style.suspendThemeReloads()
return "ok"
}
function reloadTheme(): string {
NoctaliaCommons.Color.reloadTheme()
NoctaliaCommons.Style.reloadTheme()