Merge branch 'main' from upstream into my main

This commit is contained in:
Anas Khalifa 2025-08-24 02:38:33 +03:00
commit 09bc3b3f01
No known key found for this signature in database
GPG key ID: 1B6C212010BABA2C

View file

@ -1,9 +1,9 @@
pragma Singleton
import QtQuick import QtQuick
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import qs.Commons import qs.Commons
import qs.Services import qs.Services
pragma Singleton
Singleton { Singleton {
id: root id: root
@ -12,11 +12,8 @@ Singleton {
// Default config directory: ~/.config/noctalia // Default config directory: ~/.config/noctalia
// Default cache directory: ~/.cache/noctalia // Default cache directory: ~/.cache/noctalia
property string shellName: "noctalia" property string shellName: "noctalia"
property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/"
|| Quickshell.env( property string cacheDir: Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env("HOME") + "/.cache") + "/" + shellName + "/"
"HOME") + "/.config") + "/" + shellName + "/"
property string cacheDir: Quickshell.env("NOCTALIA_CACHE_DIR") || (Quickshell.env("XDG_CACHE_HOME") || Quickshell.env(
"HOME") + "/.cache") + "/" + shellName + "/"
property string cacheDirImages: cacheDir + "images/" property string cacheDirImages: cacheDir + "images/"
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (configDir + "settings.json") property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE") || (configDir + "settings.json")
@ -32,41 +29,40 @@ Singleton {
// Function to validate monitor configurations // Function to validate monitor configurations
function validateMonitorConfigurations() { function validateMonitorConfigurations() {
var availableScreenNames = [] var availableScreenNames = [];
for (var i = 0; i < Quickshell.screens.length; i++) { for (var i = 0; i < Quickshell.screens.length; i++) {
availableScreenNames.push(Quickshell.screens[i].name) availableScreenNames.push(Quickshell.screens[i].name);
} }
Logger.log("Settings", "Available monitors: [" + availableScreenNames.join(", ") + "]") Logger.log("Settings", "Available monitors: [" + availableScreenNames.join(", ") + "]");
Logger.log("Settings", "Configured bar monitors: [" + adapter.bar.monitors.join(", ") + "]") Logger.log("Settings", "Configured bar monitors: [" + adapter.bar.monitors.join(", ") + "]");
// Check bar monitors // Check bar monitors
if (adapter.bar.monitors.length > 0) { if (adapter.bar.monitors.length > 0) {
var hasValidBarMonitor = false var hasValidBarMonitor = false;
for (var j = 0; j < adapter.bar.monitors.length; j++) { for (var j = 0; j < adapter.bar.monitors.length; j++) {
if (availableScreenNames.includes(adapter.bar.monitors[j])) { if (availableScreenNames.includes(adapter.bar.monitors[j])) {
hasValidBarMonitor = true hasValidBarMonitor = true;
break break;
} }
} }
if (!hasValidBarMonitor) { if (!hasValidBarMonitor) {
Logger.log("Settings", Logger.log("Settings", "No configured bar monitors found on system, clearing bar monitor list to show on all screens");
"No configured bar monitors found on system, clearing bar monitor list to show on all screens") adapter.bar.monitors = [];
adapter.bar.monitors = []
} else { } else {
Logger.log("Settings", "Found valid bar monitors, keeping configuration") Logger.log("Settings", "Found valid bar monitors, keeping configuration");
} }
} else { } else {
Logger.log("Settings", "Bar monitor list is empty, will show on all available screens") Logger.log("Settings", "Bar monitor list is empty, will show on all available screens");
} }
} }
Item { Item {
Component.onCompleted: { Component.onCompleted: {
// ensure settings dir exists // ensure settings dir exists
Quickshell.execDetached(["mkdir", "-p", configDir]) Quickshell.execDetached(["mkdir", "-p", configDir]);
Quickshell.execDetached(["mkdir", "-p", cacheDir]) Quickshell.execDetached(["mkdir", "-p", cacheDir]);
Quickshell.execDetached(["mkdir", "-p", cacheDirImages]) Quickshell.execDetached(["mkdir", "-p", cacheDirImages]);
} }
} }
@ -86,39 +82,37 @@ Singleton {
onFileChanged: reload() onFileChanged: reload()
onAdapterUpdated: saveTimer.start() onAdapterUpdated: saveTimer.start()
Component.onCompleted: function () { Component.onCompleted: function () {
reload() reload();
} }
onLoaded: function () { onLoaded: function () {
Qt.callLater(function () { Qt.callLater(function () {
if (isInitialLoad) { if (isInitialLoad) {
Logger.log("Settings", "OnLoaded") Logger.log("Settings", "OnLoaded");
// Only set wallpaper on initial load, not on reloads // Only set wallpaper on initial load, not on reloads
if (adapter.wallpaper.current !== "") { if (adapter.wallpaper.current !== "") {
Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current) Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current);
WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true) WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true);
} }
// Validate monitor configurations, only once // Validate monitor configurations, only once
// if none of the configured monitors exist, clear the lists // if none of the configured monitors exist, clear the lists
validateMonitorConfigurations() validateMonitorConfigurations();
} }
isInitialLoad = false isInitialLoad = false;
}) });
} }
onLoadFailed: function (error) { onLoadFailed: function (error) {
if (error.toString().includes("No such file") || error === 2) if (error.toString().includes("No such file") || error === 2)
// File doesn't exist, create it with default values // File doesn't exist, create it with default values
writeAdapter() writeAdapter();
} }
JsonAdapter { JsonAdapter {
id: adapter id: adapter
// bar // bar
property JsonObject bar property JsonObject bar: JsonObject {
bar: JsonObject {
property string position: "top" // Possible values: "top", "bottom" property string position: "top" // Possible values: "top", "bottom"
property bool showActiveWindowIcon: true property bool showActiveWindowIcon: true
property bool alwaysShowBatteryPercentage: false property bool alwaysShowBatteryPercentage: false
@ -135,9 +129,7 @@ Singleton {
} }
// general // general
property JsonObject general property JsonObject general: JsonObject {
general: JsonObject {
property string avatarImage: defaultAvatar property string avatarImage: defaultAvatar
property bool dimDesktop: false property bool dimDesktop: false
property bool showScreenCorners: false property bool showScreenCorners: false
@ -145,9 +137,7 @@ Singleton {
} }
// location // location
property JsonObject location property JsonObject location: JsonObject {
location: JsonObject {
property string name: "Tokyo" property string name: "Tokyo"
property bool useFahrenheit: false property bool useFahrenheit: false
property bool reverseDayMonth: false property bool reverseDayMonth: false
@ -156,9 +146,7 @@ Singleton {
} }
// screen recorder // screen recorder
property JsonObject screenRecorder property JsonObject screenRecorder: JsonObject {
screenRecorder: JsonObject {
property string directory: "~/Videos" property string directory: "~/Videos"
property int frameRate: 60 property int frameRate: 60
property string audioCodec: "opus" property string audioCodec: "opus"
@ -171,9 +159,7 @@ Singleton {
} }
// wallpaper // wallpaper
property JsonObject wallpaper property JsonObject wallpaper: JsonObject {
wallpaper: JsonObject {
property string directory: "/usr/share/wallpapers" property string directory: "/usr/share/wallpapers"
property string current: "" property string current: ""
property bool isRandom: false property bool isRandom: false
@ -194,9 +180,7 @@ Singleton {
} }
// applauncher // applauncher
property JsonObject appLauncher property JsonObject appLauncher: JsonObject {
appLauncher: JsonObject {
// When disabled, Launcher hides clipboard command and ignores cliphist // When disabled, Launcher hides clipboard command and ignores cliphist
property bool enableClipboardHistory: true property bool enableClipboardHistory: true
// Position: center, top_left, top_right, bottom_left, bottom_right // Position: center, top_left, top_right, bottom_left, bottom_right
@ -205,33 +189,25 @@ Singleton {
} }
// dock // dock
property JsonObject dock property JsonObject dock: JsonObject {
dock: JsonObject {
property bool autoHide: false property bool autoHide: false
property bool exclusive: false property bool exclusive: false
property list<string> monitors: [] property list<string> monitors: []
} }
// network // network
property JsonObject network property JsonObject network: JsonObject {
network: JsonObject {
property bool wifiEnabled: true property bool wifiEnabled: true
property bool bluetoothEnabled: true property bool bluetoothEnabled: true
} }
// notifications // notifications
property JsonObject notifications property JsonObject notifications: JsonObject {
notifications: JsonObject {
property list<string> monitors: [] property list<string> monitors: []
} }
// audio // audio
property JsonObject audio property JsonObject audio: JsonObject {
audio: JsonObject {
property bool showMiniplayerAlbumArt: false property bool showMiniplayerAlbumArt: false
property bool showMiniplayerCava: false property bool showMiniplayerCava: false
property string visualizerType: "linear" property string visualizerType: "linear"
@ -240,9 +216,7 @@ Singleton {
} }
// ui // ui
property JsonObject ui property JsonObject ui: JsonObject {
ui: JsonObject {
property string fontDefault: "Roboto" // Default font for all text property string fontDefault: "Roboto" // Default font for all text
property string fontFixed: "DejaVu Sans Mono" // Fixed width font for terminal property string fontFixed: "DejaVu Sans Mono" // Fixed width font for terminal
property string fontBillboard: "Inter" // Large bold font for clocks and prominent displays property string fontBillboard: "Inter" // Large bold font for clocks and prominent displays
@ -255,20 +229,14 @@ Singleton {
} }
// Scaling (not stored inside JsonObject, or it crashes) // Scaling (not stored inside JsonObject, or it crashes)
property var monitorsScaling: { property var monitorsScaling: {}
}
// brightness // brightness
property JsonObject brightness property JsonObject brightness: JsonObject {
brightness: JsonObject {
property int brightnessStep: 5 property int brightnessStep: 5
} }
property JsonObject colorSchemes property JsonObject colorSchemes: JsonObject {
colorSchemes: JsonObject {
property bool useWallpaperColors: false property bool useWallpaperColors: false
property string predefinedScheme: "" property string predefinedScheme: ""
property bool darkMode: true property bool darkMode: true