diff --git a/quickshell/Common/SessionData.qml b/quickshell/Common/SessionData.qml index 577c2f4b..f6bd4864 100644 --- a/quickshell/Common/SessionData.qml +++ b/quickshell/Common/SessionData.qml @@ -13,7 +13,7 @@ import "settings/SessionStore.js" as Store Singleton { id: root - readonly property int sessionConfigVersion: 2 + readonly property int sessionConfigVersion: 3 readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true" property bool _parseError: false @@ -109,6 +109,8 @@ Singleton { property var appOverrides: ({}) property bool searchAppActions: true + property string vpnLastConnected: "" + Component.onCompleted: { if (!isGreeterMode) { loadSettings(); @@ -1003,6 +1005,11 @@ Singleton { saveSettings(); } + function setVpnLastConnected(uuid) { + vpnLastConnected = uuid || ""; + saveSettings(); + } + function syncWallpaperForCurrentMode() { if (!perModeWallpaper) return; diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index 676aae45..56e45a90 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -292,13 +292,13 @@ Singleton { property string _legacyWeatherLocation: "New York, NY" property string _legacyWeatherCoordinates: "40.7128,-74.0060" + property string _legacyVpnLastConnected: "" readonly property string weatherLocation: SessionData.weatherLocation readonly property string weatherCoordinates: SessionData.weatherCoordinates property bool useAutoLocation: false property bool weatherEnabled: true property string networkPreference: "auto" - property string vpnLastConnected: "" property string iconTheme: "System Default" property var availableIconThemes: ["System Default"] @@ -1078,6 +1078,11 @@ Singleton { _legacyWeatherLocation = obj.weatherLocation; if (obj?.weatherCoordinates !== undefined) _legacyWeatherCoordinates = obj.weatherCoordinates; + if (obj?.vpnLastConnected !== undefined && obj.vpnLastConnected !== "") { + _legacyVpnLastConnected = obj.vpnLastConnected; + SessionData.vpnLastConnected = _legacyVpnLastConnected; + SessionData.saveSettings(); + } _loadedSettingsSnapshot = JSON.stringify(Store.toJson(root)); _hasLoaded = true; @@ -2311,6 +2316,11 @@ Singleton { _legacyWeatherLocation = obj.weatherLocation; if (obj.weatherCoordinates !== undefined) _legacyWeatherCoordinates = obj.weatherCoordinates; + if (obj.vpnLastConnected !== undefined && obj.vpnLastConnected !== "") { + _legacyVpnLastConnected = obj.vpnLastConnected; + SessionData.vpnLastConnected = _legacyVpnLastConnected; + SessionData.saveSettings(); + } _loadedSettingsSnapshot = JSON.stringify(Store.toJson(root)); _hasLoaded = true; diff --git a/quickshell/Common/settings/SessionSpec.js b/quickshell/Common/settings/SessionSpec.js index 4acb24f1..4b83a290 100644 --- a/quickshell/Common/settings/SessionSpec.js +++ b/quickshell/Common/settings/SessionSpec.js @@ -61,7 +61,9 @@ var SPEC = { hiddenApps: { def: [] }, appOverrides: { def: {} }, - searchAppActions: { def: true } + searchAppActions: { def: true }, + + vpnLastConnected: { def: "" } }; function getValidKeys() { diff --git a/quickshell/Common/settings/SessionStore.js b/quickshell/Common/settings/SessionStore.js index 53ebea2a..c1e21906 100644 --- a/quickshell/Common/settings/SessionStore.js +++ b/quickshell/Common/settings/SessionStore.js @@ -1,6 +1,6 @@ .pragma library -.import "./SessionSpec.js" as SpecModule + .import "./SessionSpec.js" as SpecModule function parse(root, jsonObj) { var SPEC = SpecModule.SPEC; @@ -68,6 +68,11 @@ function migrateToVersion(obj, targetVersion, settingsData) { session.configVersion = 2; } + if (currentVersion < 3) { + console.info("SessionData: Migrating session to version 3"); + session.configVersion = 3; + } + return session; } diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index d720b89e..ac5fbc27 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -79,16 +79,18 @@ var SPEC = { privacyShowCameraIcon: { def: false }, privacyShowScreenShareIcon: { def: false }, - controlCenterWidgets: { def: [ - { id: "volumeSlider", enabled: true, width: 50 }, - { id: "brightnessSlider", enabled: true, width: 50 }, - { id: "wifi", enabled: true, width: 50 }, - { id: "bluetooth", enabled: true, width: 50 }, - { id: "audioOutput", enabled: true, width: 50 }, - { id: "audioInput", enabled: true, width: 50 }, - { id: "nightMode", enabled: true, width: 50 }, - { id: "darkMode", enabled: true, width: 50 } - ]}, + controlCenterWidgets: { + def: [ + { id: "volumeSlider", enabled: true, width: 50 }, + { id: "brightnessSlider", enabled: true, width: 50 }, + { id: "wifi", enabled: true, width: 50 }, + { id: "bluetooth", enabled: true, width: 50 }, + { id: "audioOutput", enabled: true, width: 50 }, + { id: "audioInput", enabled: true, width: 50 }, + { id: "nightMode", enabled: true, width: 50 }, + { id: "darkMode", enabled: true, width: 50 } + ] + }, showWorkspaceIndex: { def: false }, showWorkspaceName: { def: false }, @@ -119,13 +121,15 @@ var SPEC = { keyboardLayoutNameCompactMode: { def: false }, runningAppsCurrentWorkspace: { def: false }, runningAppsGroupByApp: { def: false }, - appIdSubstitutions: { def: [ - { pattern: "Spotify", replacement: "spotify", type: "exact" }, - { pattern: "beepertexts", replacement: "beeper", type: "exact" }, - { pattern: "home assistant desktop", replacement: "homeassistant-desktop", type: "exact" }, - { pattern: "com.transmissionbt.transmission", replacement: "transmission-gtk", type: "contains" }, - { pattern: "^steam_app_(\\d+)$", replacement: "steam_icon_$1", type: "regex" } - ]}, + appIdSubstitutions: { + def: [ + { pattern: "Spotify", replacement: "spotify", type: "exact" }, + { pattern: "beepertexts", replacement: "beeper", type: "exact" }, + { pattern: "home assistant desktop", replacement: "homeassistant-desktop", type: "exact" }, + { pattern: "com.transmissionbt.transmission", replacement: "transmission-gtk", type: "contains" }, + { pattern: "^steam_app_(\\d+)$", replacement: "steam_icon_$1", type: "regex" } + ] + }, centeringMode: { def: "index" }, clockDateFormat: { def: "" }, lockDateFormat: { def: "" }, @@ -153,7 +157,6 @@ var SPEC = { weatherEnabled: { def: true }, networkPreference: { def: "auto" }, - vpnLastConnected: { def: "" }, iconTheme: { def: "System Default", onChange: "applyStoredIconTheme" }, availableIconThemes: { def: ["System Default"], persist: false }, @@ -306,7 +309,7 @@ var SPEC = { osdAlwaysShowValue: { def: false }, osdPosition: { def: 5 }, osdVolumeEnabled: { def: true }, - osdMediaVolumeEnabled : { def: true }, + osdMediaVolumeEnabled: { def: true }, osdBrightnessEnabled: { def: true }, osdIdleInhibitorEnabled: { def: true }, osdMicMuteEnabled: { def: true }, @@ -337,52 +340,54 @@ var SPEC = { niriOutputSettings: { def: {} }, hyprlandOutputSettings: { def: {} }, - barConfigs: { def: [{ - id: "default", - name: "Main Bar", - enabled: true, - position: 0, - screenPreferences: ["all"], - showOnLastDisplay: true, - leftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"], - centerWidgets: ["music", "clock", "weather"], - rightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"], - spacing: 4, - innerPadding: 4, - bottomGap: 0, - transparency: 1.0, - widgetTransparency: 1.0, - squareCorners: false, - noBackground: false, - gothCornersEnabled: false, - gothCornerRadiusOverride: false, - gothCornerRadiusValue: 12, - borderEnabled: false, - borderColor: "surfaceText", - borderOpacity: 1.0, - borderThickness: 1, - widgetOutlineEnabled: false, - widgetOutlineColor: "primary", - widgetOutlineOpacity: 1.0, - widgetOutlineThickness: 1, - fontScale: 1.0, - autoHide: false, - autoHideDelay: 250, - showOnWindowsOpen: false, - openOnOverview: false, - visible: true, - popupGapsAuto: true, - popupGapsManual: 4, - maximizeDetection: true, - scrollEnabled: true, - scrollXBehavior: "column", - scrollYBehavior: "workspace", - shadowIntensity: 0, - shadowOpacity: 60, - shadowColorMode: "text", - shadowCustomColor: "#000000", - clickThrough: false - }], onChange: "updateBarConfigs" }, + barConfigs: { + def: [{ + id: "default", + name: "Main Bar", + enabled: true, + position: 0, + screenPreferences: ["all"], + showOnLastDisplay: true, + leftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"], + centerWidgets: ["music", "clock", "weather"], + rightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"], + spacing: 4, + innerPadding: 4, + bottomGap: 0, + transparency: 1.0, + widgetTransparency: 1.0, + squareCorners: false, + noBackground: false, + gothCornersEnabled: false, + gothCornerRadiusOverride: false, + gothCornerRadiusValue: 12, + borderEnabled: false, + borderColor: "surfaceText", + borderOpacity: 1.0, + borderThickness: 1, + widgetOutlineEnabled: false, + widgetOutlineColor: "primary", + widgetOutlineOpacity: 1.0, + widgetOutlineThickness: 1, + fontScale: 1.0, + autoHide: false, + autoHideDelay: 250, + showOnWindowsOpen: false, + openOnOverview: false, + visible: true, + popupGapsAuto: true, + popupGapsManual: 4, + maximizeDetection: true, + scrollEnabled: true, + scrollXBehavior: "column", + scrollYBehavior: "workspace", + shadowIntensity: 0, + shadowOpacity: 60, + shadowColorMode: "text", + shadowCustomColor: "#000000", + clickThrough: false + }], onChange: "updateBarConfigs" + }, desktopClockEnabled: { def: false }, desktopClockStyle: { def: "analog" }, @@ -437,7 +442,7 @@ var SPEC = { }; function getValidKeys() { - return Object.keys(SPEC).filter(function(k) { return SPEC[k].persist !== false; }).concat(["configVersion"]); + return Object.keys(SPEC).filter(function (k) { return SPEC[k].persist !== false; }).concat(["configVersion"]); } function set(root, key, value, saveFn, hooks) { diff --git a/quickshell/Common/settings/SettingsStore.js b/quickshell/Common/settings/SettingsStore.js index 103ae0e1..fb491033 100644 --- a/quickshell/Common/settings/SettingsStore.js +++ b/quickshell/Common/settings/SettingsStore.js @@ -1,6 +1,6 @@ .pragma library -.import "./SettingsSpec.js" as SpecModule + .import "./SettingsSpec.js" as SpecModule function parse(root, jsonObj) { var SPEC = SpecModule.SPEC; diff --git a/quickshell/Services/DMSNetworkService.qml b/quickshell/Services/DMSNetworkService.qml index 8a18623e..e234cf47 100644 --- a/quickshell/Services/DMSNetworkService.qml +++ b/quickshell/Services/DMSNetworkService.qml @@ -130,7 +130,7 @@ Singleton { Component.onCompleted: { root.userPreference = SettingsData.networkPreference; - lastConnectedVpnUuid = SettingsData.vpnLastConnected || ""; + lastConnectedVpnUuid = SessionData.vpnLastConnected || ""; if (socketPath && socketPath.length > 0) { checkDMSCapabilities(); } @@ -293,7 +293,7 @@ Singleton { if (vpnConnected && activeUuid) { lastConnectedVpnUuid = activeUuid; - SettingsData.set("vpnLastConnected", activeUuid); + SessionData.setVpnLastConnected(activeUuid); } if (vpnIsBusy) {