DarkModeToggle: new bar widget
This commit is contained in:
parent
b908dc0ed2
commit
508c1407be
7 changed files with 89 additions and 36 deletions
|
|
@ -16,6 +16,7 @@ Singleton {
|
|||
"Bluetooth": bluetoothComponent,
|
||||
"Brightness": brightnessComponent,
|
||||
"Clock": clockComponent,
|
||||
"DarkModeToggle": darkModeToggle,
|
||||
"KeyboardLayout": keyboardLayoutComponent,
|
||||
"MediaMini": mediaMiniComponent,
|
||||
"Microphone": microphoneComponent,
|
||||
|
|
@ -51,6 +52,9 @@ Singleton {
|
|||
property Component clockComponent: Component {
|
||||
Clock {}
|
||||
}
|
||||
property Component darkModeToggle: Component {
|
||||
DarkModeToggle {}
|
||||
}
|
||||
property Component keyboardLayoutComponent: Component {
|
||||
KeyboardLayout {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,16 +10,30 @@ import qs.Services
|
|||
Singleton {
|
||||
id: root
|
||||
|
||||
Component.onCompleted: {
|
||||
Logger.log("ColorScheme", "Service started")
|
||||
loadColorSchemes()
|
||||
}
|
||||
|
||||
property var schemes: []
|
||||
property bool scanning: false
|
||||
property string schemesDirectory: Quickshell.shellDir + "/Assets/ColorScheme"
|
||||
property string colorsJsonFilePath: Settings.configDir + "colors.json"
|
||||
|
||||
Connections {
|
||||
target: Settings.data.colorSchemes
|
||||
function onDarkModeChanged() {
|
||||
Logger.log("ColorScheme", "Detected dark mode change")
|
||||
if (!Settings.data.colorSchemes.useWallpaperColors && Settings.data.colorSchemes.predefinedScheme) {
|
||||
// Re-apply current scheme to pick the right variant
|
||||
applyScheme(Settings.data.colorSchemes.predefinedScheme)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
function init() {
|
||||
// does nothing but ensure the singleton is created
|
||||
// do not remove
|
||||
Logger.log("ColorScheme", "Service started")
|
||||
loadColorSchemes()
|
||||
}
|
||||
|
||||
function loadColorSchemes() {
|
||||
Logger.log("ColorScheme", "Load ColorScheme")
|
||||
scanning = true
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import qs.Services
|
|||
Singleton {
|
||||
id: root
|
||||
|
||||
property string dynamicConfigPath: Settings.cacheDir + "matugen.dynamic.toml"
|
||||
property string dynamicConfigPath: Settings.isLoaded ? Settings.cacheDir + "matugen.dynamic.toml" : ""
|
||||
|
||||
// External state management
|
||||
Connections {
|
||||
|
|
@ -23,6 +23,23 @@ Singleton {
|
|||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Settings.data.colorSchemes
|
||||
function onDarkModeChanged() {
|
||||
Logger.log("Matugen", "Detected dark mode change")
|
||||
if (Settings.data.colorSchemes.useWallpaperColors) {
|
||||
MatugenService.generateFromWallpaper()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
function init() {
|
||||
// does nothing but ensure the singleton is created
|
||||
// do not remove
|
||||
Logger.log("Matugen", "Service started")
|
||||
}
|
||||
|
||||
// Build TOML content based on settings
|
||||
function buildConfigToml() {
|
||||
return Matugen.buildConfigToml()
|
||||
|
|
@ -30,11 +47,12 @@ Singleton {
|
|||
|
||||
// Generate colors using current wallpaper and settings
|
||||
function generateFromWallpaper() {
|
||||
// Ensure cache dir exists
|
||||
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir])
|
||||
|
||||
Logger.log("Matugen", "Generating from wallpaper on screen:", Screen.name)
|
||||
var wp = WallpaperService.getWallpaper(Screen.name).replace(/'/g, "'\\''")
|
||||
if (wp === "") {
|
||||
Logger.error("Matugen", "No wallpaper was found")
|
||||
return
|
||||
}
|
||||
|
||||
var content = buildConfigToml()
|
||||
var mode = Settings.data.colorSchemes.darkMode ? "dark" : "light"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue