forked from Shinonome/alt-illogical-impulse
ac6d3adeb9
BREAKING CHANGE: Remove external dots-hyprland dependency - Imported all essential configs from dots-hyprland/installer-replication - Added complete configs/ directory with: - hypr/ - Hyprland configuration - quickshell/ - Quickshell widgets and config - applications/ - Application configurations - scripts/ - Utility scripts - matugen/ - Material You theming - Updated flake.nix to use local ./configs instead of external repo - Simplified update-flake script (removed external repo management) - Updated README to reflect self-contained architecture - All builds pass with local configurations Benefits: - No external repository dependencies - Faster builds (no network dependencies) - Version controlled configs in single repo - Easier maintenance and development - Complete installer replication in one place
59 lines
1.5 KiB
QML
59 lines
1.5 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import qs.modules.common
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
/**
|
|
* Automatically reloads generated material colors.
|
|
* It is necessary to run reapplyTheme() on startup because Singletons are lazily loaded.
|
|
*/
|
|
Singleton {
|
|
id: root
|
|
property string filePath: Directories.generatedMaterialThemePath
|
|
|
|
function reapplyTheme() {
|
|
themeFileView.reload()
|
|
}
|
|
|
|
function applyColors(fileContent) {
|
|
const json = JSON.parse(fileContent)
|
|
for (const key in json) {
|
|
if (json.hasOwnProperty(key)) {
|
|
// Convert snake_case to CamelCase
|
|
const camelCaseKey = key.replace(/_([a-z])/g, (g) => g[1].toUpperCase())
|
|
const m3Key = `m3${camelCaseKey}`
|
|
Appearance.m3colors[m3Key] = json[key]
|
|
}
|
|
}
|
|
|
|
Appearance.m3colors.darkmode = (Appearance.m3colors.m3background.hslLightness < 0.5)
|
|
}
|
|
|
|
Timer {
|
|
id: delayedFileRead
|
|
interval: Config.options?.hacks?.arbitraryRaceConditionDelay ?? 100
|
|
repeat: false
|
|
running: false
|
|
onTriggered: {
|
|
root.applyColors(themeFileView.text())
|
|
}
|
|
}
|
|
|
|
FileView {
|
|
id: themeFileView
|
|
path: Qt.resolvedUrl(root.filePath)
|
|
watchChanges: true
|
|
onFileChanged: {
|
|
this.reload()
|
|
delayedFileRead.start()
|
|
}
|
|
onLoadedChanged: {
|
|
const fileContent = themeFileView.text()
|
|
root.applyColors(fileContent)
|
|
}
|
|
}
|
|
}
|