summaryrefslogtreecommitdiff
path: root/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml
diff options
context:
space:
mode:
authornippy <you@example.com>2026-04-18 13:49:56 +0200
committernippy <you@example.com>2026-04-18 13:49:56 +0200
commit5d94c0a7d44a2255b81815a52a7056a94a39842d (patch)
tree759bdea9645c6a62f9e1e4c001f7d81cccd120d2 /raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml
parente79cdf210b267f21a186255ce1a4d50029439d54 (diff)
downloadRaveOS-PKGBUILD-5d94c0a7d44a2255b81815a52a7056a94a39842d.tar.gz
RaveOS-PKGBUILD-5d94c0a7d44a2255b81815a52a7056a94a39842d.zip
update Raveos themes
Diffstat (limited to 'raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml')
-rw-r--r--raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml128
1 files changed, 128 insertions, 0 deletions
diff --git a/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml b/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml
new file mode 100644
index 0000000..da949d3
--- /dev/null
+++ b/raveos-theme/hyprland/theme-data/DankMaterialShell/quickshell/Modules/Greetd/GreetdMemory.qml
@@ -0,0 +1,128 @@
+pragma Singleton
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import Quickshell
+import Quickshell.Io
+import "GreetdEnv.js" as GreetdEnv
+
+Singleton {
+ id: root
+
+ readonly property string greetCfgDir: Quickshell.env("DMS_GREET_CFG_DIR") || "/var/cache/dms-greeter"
+ readonly property string sessionConfigPath: greetCfgDir + "/session.json"
+ readonly property string memoryFile: greetCfgDir + "/.local/state/memory.json"
+ readonly property bool rememberLastSession: GreetdEnv.readBoolOverride(Quickshell.env, ["DMS_GREET_REMEMBER_LAST_SESSION", "DMS_SAVE_SESSION"], true)
+ readonly property bool rememberLastUser: GreetdEnv.readBoolOverride(Quickshell.env, ["DMS_GREET_REMEMBER_LAST_USER", "DMS_SAVE_USERNAME"], true)
+
+ property string lastSessionId: ""
+ property string lastSuccessfulUser: ""
+ property bool memoryReady: false
+ property bool isLightMode: false
+ property bool nightModeEnabled: false
+
+ Component.onCompleted: {
+ loadMemory();
+ loadSessionConfig();
+ }
+
+ function loadMemory() {
+ parseMemory(memoryFileView.text());
+ }
+
+ function loadSessionConfig() {
+ parseSessionConfig(sessionConfigFileView.text());
+ }
+
+ function parseSessionConfig(content) {
+ try {
+ if (content && content.trim()) {
+ const config = JSON.parse(content);
+ isLightMode = config.isLightMode !== undefined ? config.isLightMode : false;
+ nightModeEnabled = config.nightModeEnabled !== undefined ? config.nightModeEnabled : false;
+ }
+ } catch (e) {
+ console.warn("Failed to parse greeter session config:", e);
+ }
+ }
+
+ function parseMemory(content) {
+ try {
+ if (!content || !content.trim())
+ return;
+ const memory = JSON.parse(content);
+ lastSessionId = rememberLastSession ? (memory.lastSessionId || "") : "";
+ lastSuccessfulUser = rememberLastUser ? (memory.lastSuccessfulUser || "") : "";
+ if (!rememberLastSession || !rememberLastUser)
+ saveMemory();
+ } catch (e) {
+ console.warn("Failed to parse greetd memory:", e);
+ }
+ }
+
+ function saveMemory() {
+ let memory = {};
+ if (rememberLastSession && lastSessionId)
+ memory.lastSessionId = lastSessionId;
+ if (rememberLastUser && lastSuccessfulUser)
+ memory.lastSuccessfulUser = lastSuccessfulUser;
+ memoryFileView.setText(JSON.stringify(memory, null, 2));
+ }
+
+ function setLastSessionId(id) {
+ if (!rememberLastSession) {
+ if (lastSessionId !== "") {
+ lastSessionId = "";
+ saveMemory();
+ }
+ return;
+ }
+ lastSessionId = id || "";
+ saveMemory();
+ }
+
+ function setLastSuccessfulUser(username) {
+ if (!rememberLastUser) {
+ if (lastSuccessfulUser !== "") {
+ lastSuccessfulUser = "";
+ saveMemory();
+ }
+ return;
+ }
+ lastSuccessfulUser = username || "";
+ saveMemory();
+ }
+
+ FileView {
+ id: memoryFileView
+ path: root.memoryFile
+ blockLoading: false
+ blockWrites: false
+ atomicWrites: true
+ watchChanges: false
+ printErrors: false
+ onLoaded: {
+ parseMemory(memoryFileView.text());
+ root.memoryReady = true;
+ }
+ onLoadFailed: {
+ root.memoryReady = true;
+ }
+ }
+
+ FileView {
+ id: sessionConfigFileView
+ path: root.sessionConfigPath
+ blockLoading: false
+ blockWrites: true
+ atomicWrites: false
+ watchChanges: false
+ printErrors: true
+ onLoaded: {
+ parseSessionConfig(sessionConfigFileView.text());
+ }
+ onLoadFailed: error => {
+ console.warn("Could not load greeter session config from", root.sessionConfigPath, "error:", error);
+ }
+ }
+}