mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 00:12:50 -05:00
matugen: make check codition an array
This commit is contained in:
@@ -234,61 +234,61 @@ output_path = '%s'
|
|||||||
if !opts.ShouldSkipTemplate("gtk") {
|
if !opts.ShouldSkipTemplate("gtk") {
|
||||||
switch opts.Mode {
|
switch opts.Mode {
|
||||||
case "light":
|
case "light":
|
||||||
appendConfig(opts, cfgFile, "skip", "gtk3-light.toml")
|
appendConfig(opts, cfgFile, nil, "gtk3-light.toml")
|
||||||
default:
|
default:
|
||||||
appendConfig(opts, cfgFile, "skip", "gtk3-dark.toml")
|
appendConfig(opts, cfgFile, nil, "gtk3-dark.toml")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.ShouldSkipTemplate("niri") {
|
if !opts.ShouldSkipTemplate("niri") {
|
||||||
appendConfig(opts, cfgFile, "niri", "niri.toml")
|
appendConfig(opts, cfgFile, []string{"niri"}, "niri.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("qt5ct") {
|
if !opts.ShouldSkipTemplate("qt5ct") {
|
||||||
appendConfig(opts, cfgFile, "qt5ct", "qt5ct.toml")
|
appendConfig(opts, cfgFile, []string{"qt5ct"}, "qt5ct.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("qt6ct") {
|
if !opts.ShouldSkipTemplate("qt6ct") {
|
||||||
appendConfig(opts, cfgFile, "qt6ct", "qt6ct.toml")
|
appendConfig(opts, cfgFile, []string{"qt6ct"}, "qt6ct.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("firefox") {
|
if !opts.ShouldSkipTemplate("firefox") {
|
||||||
appendConfig(opts, cfgFile, "firefox", "firefox.toml")
|
appendConfig(opts, cfgFile, []string{"firefox"}, "firefox.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("pywalfox") {
|
if !opts.ShouldSkipTemplate("pywalfox") {
|
||||||
appendConfig(opts, cfgFile, "pywalfox", "pywalfox.toml")
|
appendConfig(opts, cfgFile, []string{"pywalfox"}, "pywalfox.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("zenbrowser") {
|
if !opts.ShouldSkipTemplate("zenbrowser") {
|
||||||
appendConfig(opts, cfgFile, "zen", "zenbrowser.toml")
|
appendConfig(opts, cfgFile, []string{"zen", "zen-browser"}, "zenbrowser.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("vesktop") {
|
if !opts.ShouldSkipTemplate("vesktop") {
|
||||||
appendConfig(opts, cfgFile, "vesktop", "vesktop.toml")
|
appendConfig(opts, cfgFile, []string{"vesktop"}, "vesktop.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("equibop") {
|
if !opts.ShouldSkipTemplate("equibop") {
|
||||||
appendConfig(opts, cfgFile, "equibop", "equibop.toml")
|
appendConfig(opts, cfgFile, []string{"equibop"}, "equibop.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("ghostty") {
|
if !opts.ShouldSkipTemplate("ghostty") {
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, "ghostty", "ghostty.toml")
|
appendTerminalConfig(opts, cfgFile, tmpDir, []string{"ghostty"}, "ghostty.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("kitty") {
|
if !opts.ShouldSkipTemplate("kitty") {
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, "kitty", "kitty.toml")
|
appendTerminalConfig(opts, cfgFile, tmpDir, []string{"kitty"}, "kitty.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("foot") {
|
if !opts.ShouldSkipTemplate("foot") {
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, "foot", "foot.toml")
|
appendTerminalConfig(opts, cfgFile, tmpDir, []string{"foot"}, "foot.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("alacritty") {
|
if !opts.ShouldSkipTemplate("alacritty") {
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, "alacritty", "alacritty.toml")
|
appendTerminalConfig(opts, cfgFile, tmpDir, []string{"alacritty"}, "alacritty.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("wezterm") {
|
if !opts.ShouldSkipTemplate("wezterm") {
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, "wezterm", "wezterm.toml")
|
appendTerminalConfig(opts, cfgFile, tmpDir, []string{"wezterm"}, "wezterm.toml")
|
||||||
}
|
}
|
||||||
if !opts.ShouldSkipTemplate("nvim") {
|
if !opts.ShouldSkipTemplate("nvim") {
|
||||||
appendTerminalConfig(opts, cfgFile, tmpDir, "nvim", "neovim.toml")
|
appendTerminalConfig(opts, cfgFile, tmpDir, []string{"nvim"}, "neovim.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.ShouldSkipTemplate("dgop") {
|
if !opts.ShouldSkipTemplate("dgop") {
|
||||||
appendConfig(opts, cfgFile, "dgop", "dgop.toml")
|
appendConfig(opts, cfgFile, []string{"dgop"}, "dgop.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.ShouldSkipTemplate("kcolorscheme") {
|
if !opts.ShouldSkipTemplate("kcolorscheme") {
|
||||||
appendConfig(opts, cfgFile, "skip", "kcolorscheme.toml")
|
appendConfig(opts, cfgFile, nil, "kcolorscheme.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.ShouldSkipTemplate("vscode") {
|
if !opts.ShouldSkipTemplate("vscode") {
|
||||||
@@ -326,12 +326,12 @@ output_path = '%s'
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendConfig(opts *Options, cfgFile *os.File, checkCmd, fileName string) {
|
func appendConfig(opts *Options, cfgFile *os.File, checkCmd []string, fileName string) {
|
||||||
configPath := filepath.Join(opts.ShellDir, "matugen", "configs", fileName)
|
configPath := filepath.Join(opts.ShellDir, "matugen", "configs", fileName)
|
||||||
if _, err := os.Stat(configPath); err != nil {
|
if _, err := os.Stat(configPath); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if checkCmd != "skip" && !utils.CommandExists(checkCmd) {
|
if !utils.AnyCommandExists(checkCmd...) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := os.ReadFile(configPath)
|
data, err := os.ReadFile(configPath)
|
||||||
@@ -342,12 +342,12 @@ func appendConfig(opts *Options, cfgFile *os.File, checkCmd, fileName string) {
|
|||||||
cfgFile.WriteString("\n")
|
cfgFile.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendTerminalConfig(opts *Options, cfgFile *os.File, tmpDir, checkCmd, fileName string) {
|
func appendTerminalConfig(opts *Options, cfgFile *os.File, tmpDir string, checkCmd []string, fileName string) {
|
||||||
configPath := filepath.Join(opts.ShellDir, "matugen", "configs", fileName)
|
configPath := filepath.Join(opts.ShellDir, "matugen", "configs", fileName)
|
||||||
if _, err := os.Stat(configPath); err != nil {
|
if _, err := os.Stat(configPath); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if checkCmd != "skip" && !utils.CommandExists(checkCmd) {
|
if !utils.AnyCommandExists(checkCmd...) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, err := os.ReadFile(configPath)
|
data, err := os.ReadFile(configPath)
|
||||||
|
|||||||
@@ -6,3 +6,12 @@ func CommandExists(cmd string) bool {
|
|||||||
_, err := exec.LookPath(cmd)
|
_, err := exec.LookPath(cmd)
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AnyCommandExists(cmds ...string) bool {
|
||||||
|
for _, cmd := range cmds {
|
||||||
|
if CommandExists(cmd) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ Singleton {
|
|||||||
|
|
||||||
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
||||||
property bool hasTriedDefaultSession: false
|
property bool hasTriedDefaultSession: false
|
||||||
|
property bool _parseError: false
|
||||||
readonly property string _stateUrl: StandardPaths.writableLocation(StandardPaths.GenericStateLocation)
|
readonly property string _stateUrl: StandardPaths.writableLocation(StandardPaths.GenericStateLocation)
|
||||||
readonly property string _stateDir: Paths.strip(_stateUrl)
|
readonly property string _stateDir: Paths.strip(_stateUrl)
|
||||||
|
|
||||||
@@ -108,96 +109,98 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseSettings(content) {
|
function parseSettings(content) {
|
||||||
|
_parseError = false;
|
||||||
try {
|
try {
|
||||||
if (content && content.trim()) {
|
if (!content || !content.trim())
|
||||||
var settings = JSON.parse(content);
|
return;
|
||||||
isLightMode = settings.isLightMode !== undefined ? settings.isLightMode : false;
|
var settings = JSON.parse(content);
|
||||||
|
isLightMode = settings.isLightMode !== undefined ? settings.isLightMode : false;
|
||||||
|
|
||||||
if (settings.wallpaperPath && settings.wallpaperPath.startsWith("we:")) {
|
if (settings.wallpaperPath && settings.wallpaperPath.startsWith("we:")) {
|
||||||
console.warn("WallpaperEngine wallpaper detected, resetting wallpaper");
|
console.warn("WallpaperEngine wallpaper detected, resetting wallpaper");
|
||||||
wallpaperPath = "";
|
wallpaperPath = "";
|
||||||
Quickshell.execDetached(["notify-send", "-u", "critical", "-a", "DMS", "-i", "dialog-warning", "WallpaperEngine Support Moved", "WallpaperEngine support has been moved to a plugin. Please enable the Linux Wallpaper Engine plugin in Settings → Plugins to continue using WallpaperEngine."]);
|
Quickshell.execDetached(["notify-send", "-u", "critical", "-a", "DMS", "-i", "dialog-warning", "WallpaperEngine Support Moved", "WallpaperEngine support has been moved to a plugin. Please enable the Linux Wallpaper Engine plugin in Settings → Plugins to continue using WallpaperEngine."]);
|
||||||
} else {
|
} else {
|
||||||
wallpaperPath = settings.wallpaperPath !== undefined ? settings.wallpaperPath : "";
|
wallpaperPath = settings.wallpaperPath !== undefined ? settings.wallpaperPath : "";
|
||||||
}
|
|
||||||
perMonitorWallpaper = settings.perMonitorWallpaper !== undefined ? settings.perMonitorWallpaper : false;
|
|
||||||
monitorWallpapers = settings.monitorWallpapers !== undefined ? settings.monitorWallpapers : {};
|
|
||||||
perModeWallpaper = settings.perModeWallpaper !== undefined ? settings.perModeWallpaper : false;
|
|
||||||
wallpaperPathLight = settings.wallpaperPathLight !== undefined ? settings.wallpaperPathLight : "";
|
|
||||||
wallpaperPathDark = settings.wallpaperPathDark !== undefined ? settings.wallpaperPathDark : "";
|
|
||||||
monitorWallpapersLight = settings.monitorWallpapersLight !== undefined ? settings.monitorWallpapersLight : {};
|
|
||||||
monitorWallpapersDark = settings.monitorWallpapersDark !== undefined ? settings.monitorWallpapersDark : {};
|
|
||||||
brightnessExponentialDevices = settings.brightnessExponentialDevices !== undefined ? settings.brightnessExponentialDevices : (settings.brightnessLogarithmicDevices || {});
|
|
||||||
brightnessUserSetValues = settings.brightnessUserSetValues !== undefined ? settings.brightnessUserSetValues : {};
|
|
||||||
brightnessExponentValues = settings.brightnessExponentValues !== undefined ? settings.brightnessExponentValues : {};
|
|
||||||
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false;
|
|
||||||
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false;
|
|
||||||
nightModeTemperature = settings.nightModeTemperature !== undefined ? settings.nightModeTemperature : 4500;
|
|
||||||
nightModeHighTemperature = settings.nightModeHighTemperature !== undefined ? settings.nightModeHighTemperature : 6500;
|
|
||||||
nightModeAutoEnabled = settings.nightModeAutoEnabled !== undefined ? settings.nightModeAutoEnabled : false;
|
|
||||||
nightModeAutoMode = settings.nightModeAutoMode !== undefined ? settings.nightModeAutoMode : "time";
|
|
||||||
if (settings.nightModeStartTime !== undefined) {
|
|
||||||
const parts = settings.nightModeStartTime.split(":");
|
|
||||||
nightModeStartHour = parseInt(parts[0]) || 18;
|
|
||||||
nightModeStartMinute = parseInt(parts[1]) || 0;
|
|
||||||
} else {
|
|
||||||
nightModeStartHour = settings.nightModeStartHour !== undefined ? settings.nightModeStartHour : 18;
|
|
||||||
nightModeStartMinute = settings.nightModeStartMinute !== undefined ? settings.nightModeStartMinute : 0;
|
|
||||||
}
|
|
||||||
if (settings.nightModeEndTime !== undefined) {
|
|
||||||
const parts = settings.nightModeEndTime.split(":");
|
|
||||||
nightModeEndHour = parseInt(parts[0]) || 6;
|
|
||||||
nightModeEndMinute = parseInt(parts[1]) || 0;
|
|
||||||
} else {
|
|
||||||
nightModeEndHour = settings.nightModeEndHour !== undefined ? settings.nightModeEndHour : 6;
|
|
||||||
nightModeEndMinute = settings.nightModeEndMinute !== undefined ? settings.nightModeEndMinute : 0;
|
|
||||||
}
|
|
||||||
latitude = settings.latitude !== undefined ? settings.latitude : 0.0;
|
|
||||||
longitude = settings.longitude !== undefined ? settings.longitude : 0.0;
|
|
||||||
nightModeUseIPLocation = settings.nightModeUseIPLocation !== undefined ? settings.nightModeUseIPLocation : false;
|
|
||||||
nightModeLocationProvider = settings.nightModeLocationProvider !== undefined ? settings.nightModeLocationProvider : "";
|
|
||||||
pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : [];
|
|
||||||
hiddenTrayIds = settings.hiddenTrayIds !== undefined ? settings.hiddenTrayIds : [];
|
|
||||||
selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0;
|
|
||||||
nvidiaGpuTempEnabled = settings.nvidiaGpuTempEnabled !== undefined ? settings.nvidiaGpuTempEnabled : false;
|
|
||||||
nonNvidiaGpuTempEnabled = settings.nonNvidiaGpuTempEnabled !== undefined ? settings.nonNvidiaGpuTempEnabled : false;
|
|
||||||
enabledGpuPciIds = settings.enabledGpuPciIds !== undefined ? settings.enabledGpuPciIds : [];
|
|
||||||
wifiDeviceOverride = settings.wifiDeviceOverride !== undefined ? settings.wifiDeviceOverride : "";
|
|
||||||
weatherHourlyDetailed = settings.weatherHourlyDetailed !== undefined ? settings.weatherHourlyDetailed : true;
|
|
||||||
wallpaperCyclingEnabled = settings.wallpaperCyclingEnabled !== undefined ? settings.wallpaperCyclingEnabled : false;
|
|
||||||
wallpaperCyclingMode = settings.wallpaperCyclingMode !== undefined ? settings.wallpaperCyclingMode : "interval";
|
|
||||||
wallpaperCyclingInterval = settings.wallpaperCyclingInterval !== undefined ? settings.wallpaperCyclingInterval : 300;
|
|
||||||
wallpaperCyclingTime = settings.wallpaperCyclingTime !== undefined ? settings.wallpaperCyclingTime : "06:00";
|
|
||||||
monitorCyclingSettings = settings.monitorCyclingSettings !== undefined ? settings.monitorCyclingSettings : {};
|
|
||||||
lastBrightnessDevice = settings.lastBrightnessDevice !== undefined ? settings.lastBrightnessDevice : "";
|
|
||||||
launchPrefix = settings.launchPrefix !== undefined ? settings.launchPrefix : "";
|
|
||||||
wallpaperTransition = settings.wallpaperTransition !== undefined ? settings.wallpaperTransition : "fade";
|
|
||||||
includedTransitions = settings.includedTransitions !== undefined ? settings.includedTransitions : availableWallpaperTransitions.filter(t => t !== "none");
|
|
||||||
recentColors = settings.recentColors !== undefined ? settings.recentColors : [];
|
|
||||||
showThirdPartyPlugins = settings.showThirdPartyPlugins !== undefined ? settings.showThirdPartyPlugins : false;
|
|
||||||
|
|
||||||
if (settings.configVersion === undefined) {
|
|
||||||
migrateFromUndefinedToV1(settings);
|
|
||||||
saveSettings();
|
|
||||||
} else if (settings.configVersion === sessionConfigVersion) {
|
|
||||||
cleanupUnusedKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isGreeterMode) {
|
|
||||||
if (typeof Theme !== "undefined") {
|
|
||||||
Theme.generateSystemThemesFromCurrentTheme();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof WallpaperCyclingService !== "undefined") {
|
|
||||||
WallpaperCyclingService.updateCyclingState();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
perMonitorWallpaper = settings.perMonitorWallpaper !== undefined ? settings.perMonitorWallpaper : false;
|
||||||
|
monitorWallpapers = settings.monitorWallpapers !== undefined ? settings.monitorWallpapers : {};
|
||||||
|
perModeWallpaper = settings.perModeWallpaper !== undefined ? settings.perModeWallpaper : false;
|
||||||
|
wallpaperPathLight = settings.wallpaperPathLight !== undefined ? settings.wallpaperPathLight : "";
|
||||||
|
wallpaperPathDark = settings.wallpaperPathDark !== undefined ? settings.wallpaperPathDark : "";
|
||||||
|
monitorWallpapersLight = settings.monitorWallpapersLight !== undefined ? settings.monitorWallpapersLight : {};
|
||||||
|
monitorWallpapersDark = settings.monitorWallpapersDark !== undefined ? settings.monitorWallpapersDark : {};
|
||||||
|
brightnessExponentialDevices = settings.brightnessExponentialDevices !== undefined ? settings.brightnessExponentialDevices : (settings.brightnessLogarithmicDevices || {});
|
||||||
|
brightnessUserSetValues = settings.brightnessUserSetValues !== undefined ? settings.brightnessUserSetValues : {};
|
||||||
|
brightnessExponentValues = settings.brightnessExponentValues !== undefined ? settings.brightnessExponentValues : {};
|
||||||
|
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false;
|
||||||
|
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false;
|
||||||
|
nightModeTemperature = settings.nightModeTemperature !== undefined ? settings.nightModeTemperature : 4500;
|
||||||
|
nightModeHighTemperature = settings.nightModeHighTemperature !== undefined ? settings.nightModeHighTemperature : 6500;
|
||||||
|
nightModeAutoEnabled = settings.nightModeAutoEnabled !== undefined ? settings.nightModeAutoEnabled : false;
|
||||||
|
nightModeAutoMode = settings.nightModeAutoMode !== undefined ? settings.nightModeAutoMode : "time";
|
||||||
|
if (settings.nightModeStartTime !== undefined) {
|
||||||
|
const parts = settings.nightModeStartTime.split(":");
|
||||||
|
nightModeStartHour = parseInt(parts[0]) || 18;
|
||||||
|
nightModeStartMinute = parseInt(parts[1]) || 0;
|
||||||
|
} else {
|
||||||
|
nightModeStartHour = settings.nightModeStartHour !== undefined ? settings.nightModeStartHour : 18;
|
||||||
|
nightModeStartMinute = settings.nightModeStartMinute !== undefined ? settings.nightModeStartMinute : 0;
|
||||||
|
}
|
||||||
|
if (settings.nightModeEndTime !== undefined) {
|
||||||
|
const parts = settings.nightModeEndTime.split(":");
|
||||||
|
nightModeEndHour = parseInt(parts[0]) || 6;
|
||||||
|
nightModeEndMinute = parseInt(parts[1]) || 0;
|
||||||
|
} else {
|
||||||
|
nightModeEndHour = settings.nightModeEndHour !== undefined ? settings.nightModeEndHour : 6;
|
||||||
|
nightModeEndMinute = settings.nightModeEndMinute !== undefined ? settings.nightModeEndMinute : 0;
|
||||||
|
}
|
||||||
|
latitude = settings.latitude !== undefined ? settings.latitude : 0.0;
|
||||||
|
longitude = settings.longitude !== undefined ? settings.longitude : 0.0;
|
||||||
|
nightModeUseIPLocation = settings.nightModeUseIPLocation !== undefined ? settings.nightModeUseIPLocation : false;
|
||||||
|
nightModeLocationProvider = settings.nightModeLocationProvider !== undefined ? settings.nightModeLocationProvider : "";
|
||||||
|
pinnedApps = settings.pinnedApps !== undefined ? settings.pinnedApps : [];
|
||||||
|
hiddenTrayIds = settings.hiddenTrayIds !== undefined ? settings.hiddenTrayIds : [];
|
||||||
|
selectedGpuIndex = settings.selectedGpuIndex !== undefined ? settings.selectedGpuIndex : 0;
|
||||||
|
nvidiaGpuTempEnabled = settings.nvidiaGpuTempEnabled !== undefined ? settings.nvidiaGpuTempEnabled : false;
|
||||||
|
nonNvidiaGpuTempEnabled = settings.nonNvidiaGpuTempEnabled !== undefined ? settings.nonNvidiaGpuTempEnabled : false;
|
||||||
|
enabledGpuPciIds = settings.enabledGpuPciIds !== undefined ? settings.enabledGpuPciIds : [];
|
||||||
|
wifiDeviceOverride = settings.wifiDeviceOverride !== undefined ? settings.wifiDeviceOverride : "";
|
||||||
|
weatherHourlyDetailed = settings.weatherHourlyDetailed !== undefined ? settings.weatherHourlyDetailed : true;
|
||||||
|
wallpaperCyclingEnabled = settings.wallpaperCyclingEnabled !== undefined ? settings.wallpaperCyclingEnabled : false;
|
||||||
|
wallpaperCyclingMode = settings.wallpaperCyclingMode !== undefined ? settings.wallpaperCyclingMode : "interval";
|
||||||
|
wallpaperCyclingInterval = settings.wallpaperCyclingInterval !== undefined ? settings.wallpaperCyclingInterval : 300;
|
||||||
|
wallpaperCyclingTime = settings.wallpaperCyclingTime !== undefined ? settings.wallpaperCyclingTime : "06:00";
|
||||||
|
monitorCyclingSettings = settings.monitorCyclingSettings !== undefined ? settings.monitorCyclingSettings : {};
|
||||||
|
lastBrightnessDevice = settings.lastBrightnessDevice !== undefined ? settings.lastBrightnessDevice : "";
|
||||||
|
launchPrefix = settings.launchPrefix !== undefined ? settings.launchPrefix : "";
|
||||||
|
wallpaperTransition = settings.wallpaperTransition !== undefined ? settings.wallpaperTransition : "fade";
|
||||||
|
includedTransitions = settings.includedTransitions !== undefined ? settings.includedTransitions : availableWallpaperTransitions.filter(t => t !== "none");
|
||||||
|
recentColors = settings.recentColors !== undefined ? settings.recentColors : [];
|
||||||
|
showThirdPartyPlugins = settings.showThirdPartyPlugins !== undefined ? settings.showThirdPartyPlugins : false;
|
||||||
|
|
||||||
|
if (settings.configVersion === undefined) {
|
||||||
|
migrateFromUndefinedToV1(settings);
|
||||||
|
saveSettings();
|
||||||
|
} else if (settings.configVersion === sessionConfigVersion) {
|
||||||
|
cleanupUnusedKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isGreeterMode && typeof Theme !== "undefined") {
|
||||||
|
Theme.generateSystemThemesFromCurrentTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof WallpaperCyclingService !== "undefined") {
|
||||||
|
WallpaperCyclingService.updateCyclingState();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
_parseError = true;
|
||||||
|
console.error("SessionData: Failed to parse session.json - file will not be overwritten. Error:", e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
if (isGreeterMode)
|
if (isGreeterMode || _parseError)
|
||||||
return;
|
return;
|
||||||
settingsFile.setText(JSON.stringify({
|
settingsFile.setText(JSON.stringify({
|
||||||
"isLightMode": isLightMode,
|
"isLightMode": isLightMode,
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ Singleton {
|
|||||||
|
|
||||||
property bool _loading: false
|
property bool _loading: false
|
||||||
property bool _pluginSettingsLoading: false
|
property bool _pluginSettingsLoading: false
|
||||||
|
property bool _parseError: false
|
||||||
|
property bool _pluginParseError: false
|
||||||
property bool hasTriedDefaultSettings: false
|
property bool hasTriedDefaultSettings: false
|
||||||
property var pluginSettings: ({})
|
property var pluginSettings: ({})
|
||||||
|
|
||||||
@@ -772,6 +774,7 @@ Singleton {
|
|||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
_loading = true;
|
_loading = true;
|
||||||
|
_parseError = false;
|
||||||
try {
|
try {
|
||||||
const txt = settingsFile.text();
|
const txt = settingsFile.text();
|
||||||
let obj = (txt && txt.trim()) ? JSON.parse(txt) : null;
|
let obj = (txt && txt.trim()) ? JSON.parse(txt) : null;
|
||||||
@@ -790,7 +793,8 @@ Singleton {
|
|||||||
applyStoredIconTheme();
|
applyStoredIconTheme();
|
||||||
Processes.detectQtTools();
|
Processes.detectQtTools();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("SettingsData: Failed to load settings:", e.message);
|
_parseError = true;
|
||||||
|
console.error("SettingsData: Failed to parse settings.json - file will not be overwritten. Error:", e.message);
|
||||||
applyStoredTheme();
|
applyStoredTheme();
|
||||||
applyStoredIconTheme();
|
applyStoredIconTheme();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -807,6 +811,7 @@ Singleton {
|
|||||||
|
|
||||||
function parsePluginSettings(content) {
|
function parsePluginSettings(content) {
|
||||||
_pluginSettingsLoading = true;
|
_pluginSettingsLoading = true;
|
||||||
|
_pluginParseError = false;
|
||||||
try {
|
try {
|
||||||
if (content && content.trim()) {
|
if (content && content.trim()) {
|
||||||
pluginSettings = JSON.parse(content);
|
pluginSettings = JSON.parse(content);
|
||||||
@@ -814,7 +819,8 @@ Singleton {
|
|||||||
pluginSettings = {};
|
pluginSettings = {};
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn("SettingsData: Failed to parse plugin settings:", e.message);
|
_pluginParseError = true;
|
||||||
|
console.error("SettingsData: Failed to parse plugin_settings.json - file will not be overwritten. Error:", e.message);
|
||||||
pluginSettings = {};
|
pluginSettings = {};
|
||||||
} finally {
|
} finally {
|
||||||
_pluginSettingsLoading = false;
|
_pluginSettingsLoading = false;
|
||||||
@@ -822,13 +828,13 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
if (_loading)
|
if (_loading || _parseError)
|
||||||
return;
|
return;
|
||||||
settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2));
|
settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function savePluginSettings() {
|
function savePluginSettings() {
|
||||||
if (_pluginSettingsLoading)
|
if (_pluginSettingsLoading || _pluginParseError)
|
||||||
return;
|
return;
|
||||||
pluginSettingsFile.setText(JSON.stringify(pluginSettings, null, 2));
|
pluginSettingsFile.setText(JSON.stringify(pluginSettings, null, 2));
|
||||||
}
|
}
|
||||||
@@ -1785,18 +1791,23 @@ Singleton {
|
|||||||
atomicWrites: true
|
atomicWrites: true
|
||||||
watchChanges: !isGreeterMode
|
watchChanges: !isGreeterMode
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
if (!isGreeterMode) {
|
if (isGreeterMode)
|
||||||
try {
|
return;
|
||||||
const txt = settingsFile.text();
|
_loading = true;
|
||||||
const obj = (txt && txt.trim()) ? JSON.parse(txt) : null;
|
try {
|
||||||
Store.parse(root, obj);
|
const txt = settingsFile.text();
|
||||||
applyStoredTheme();
|
const obj = (txt && txt.trim()) ? JSON.parse(txt) : null;
|
||||||
applyStoredIconTheme();
|
_parseError = false;
|
||||||
} catch (e) {
|
Store.parse(root, obj);
|
||||||
console.warn("SettingsData: Failed to reload settings:", e.message);
|
applyStoredTheme();
|
||||||
}
|
applyStoredIconTheme();
|
||||||
hasTriedDefaultSettings = false;
|
} catch (e) {
|
||||||
|
_parseError = true;
|
||||||
|
console.error("SettingsData: Failed to reload settings.json - file will not be overwritten. Error:", e.message);
|
||||||
|
} finally {
|
||||||
|
_loading = false;
|
||||||
}
|
}
|
||||||
|
hasTriedDefaultSettings = false;
|
||||||
}
|
}
|
||||||
onLoadFailed: error => {
|
onLoadFailed: error => {
|
||||||
if (!isGreeterMode && !hasTriedDefaultSettings) {
|
if (!isGreeterMode && !hasTriedDefaultSettings) {
|
||||||
|
|||||||
Reference in New Issue
Block a user