mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
meta: integrate wallpaper, FileBrowser, StateLayer
- A lot of this is implements patterns implemented by soramannew's caelestia-shell
This commit is contained in:
65
Common/Appearance.qml
Normal file
65
Common/Appearance.qml
Normal file
@@ -0,0 +1,65 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property Rounding rounding: Rounding {}
|
||||
readonly property Spacing spacing: Spacing {}
|
||||
readonly property FontSize fontSize: FontSize {}
|
||||
readonly property Anim anim: Anim {}
|
||||
|
||||
component Rounding: QtObject {
|
||||
readonly property int small: 8
|
||||
readonly property int normal: 12
|
||||
readonly property int large: 16
|
||||
readonly property int extraLarge: 24
|
||||
readonly property int full: 1000
|
||||
}
|
||||
|
||||
component Spacing: QtObject {
|
||||
readonly property int small: 4
|
||||
readonly property int normal: 8
|
||||
readonly property int large: 12
|
||||
readonly property int extraLarge: 16
|
||||
readonly property int huge: 24
|
||||
}
|
||||
|
||||
component FontSize: QtObject {
|
||||
readonly property int small: 12
|
||||
readonly property int normal: 14
|
||||
readonly property int large: 16
|
||||
readonly property int extraLarge: 20
|
||||
readonly property int huge: 24
|
||||
}
|
||||
|
||||
component AnimCurves: QtObject {
|
||||
readonly property list<real> standard: [0.2, 0, 0, 1, 1, 1]
|
||||
readonly property list<real> standardAccel: [0.3, 0, 1, 1, 1, 1]
|
||||
readonly property list<real> standardDecel: [0, 0, 0, 1, 1, 1]
|
||||
readonly property list<real> emphasized: [0.05, 0, 2 / 15, 0.06, 1 / 6, 0.4, 5 / 24, 0.82, 0.25, 1, 1, 1]
|
||||
readonly property list<real> emphasizedAccel: [0.3, 0, 0.8, 0.15, 1, 1]
|
||||
readonly property list<real> emphasizedDecel: [0.05, 0.7, 0.1, 1, 1, 1]
|
||||
readonly property list<real> expressiveFastSpatial: [0.42, 1.67, 0.21, 0.9, 1, 1]
|
||||
readonly property list<real> expressiveDefaultSpatial: [0.38, 1.21, 0.22, 1, 1, 1]
|
||||
readonly property list<real> expressiveEffects: [0.34, 0.8, 0.34, 1, 1, 1]
|
||||
}
|
||||
|
||||
component AnimDurations: QtObject {
|
||||
readonly property int quick: 150
|
||||
readonly property int normal: 300
|
||||
readonly property int slow: 500
|
||||
readonly property int extraSlow: 1000
|
||||
readonly property int expressiveFastSpatial: 350
|
||||
readonly property int expressiveDefaultSpatial: 500
|
||||
readonly property int expressiveEffects: 200
|
||||
}
|
||||
|
||||
component Anim: QtObject {
|
||||
readonly property AnimCurves curves: AnimCurves {}
|
||||
readonly property AnimDurations durations: AnimDurations {}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Services
|
||||
import qs.Common
|
||||
|
||||
Singleton {
|
||||
|
||||
@@ -13,7 +14,7 @@ Singleton {
|
||||
|
||||
readonly property string _homeUrl: StandardPaths.writableLocation(StandardPaths.HomeLocation)
|
||||
readonly property string homeDir: _homeUrl.startsWith("file://") ? _homeUrl.substring(7) : _homeUrl
|
||||
readonly property string wallpaperPath: homeDir + "/quickshell/current_wallpaper"
|
||||
readonly property string wallpaperPath: Prefs.wallpaperPath || homeDir + "/quickshell/current_wallpaper"
|
||||
readonly property string notifyPath: homeDir + "/quickshell/wallpaper_changed"
|
||||
property bool matugenAvailable: false
|
||||
property string matugenJson: ""
|
||||
@@ -141,6 +142,7 @@ Singleton {
|
||||
root.matugenJson = out;
|
||||
root.matugenColors = JSON.parse(out);
|
||||
root.colorsUpdated();
|
||||
generateAppConfigs();
|
||||
ToastService.clearWallpaperError();
|
||||
} catch (e) {
|
||||
console.error("JSON parse failed:", e);
|
||||
@@ -156,4 +158,113 @@ Singleton {
|
||||
|
||||
}
|
||||
|
||||
function generateAppConfigs() {
|
||||
if (!matugenColors || !matugenColors.colors) {
|
||||
console.warn("No matugen colors available for app config generation");
|
||||
return;
|
||||
}
|
||||
|
||||
generateNiriConfig();
|
||||
generateGhosttyConfig();
|
||||
}
|
||||
|
||||
function generateNiriConfig() {
|
||||
var dark = matugenColors.colors.dark;
|
||||
if (!dark) return;
|
||||
|
||||
var bg = dark.background || "#1a1c1e";
|
||||
var primary = dark.primary || "#42a5f5";
|
||||
var secondary = dark.secondary || "#8ab4f8";
|
||||
var inverse = dark.inverse_primary || "#6200ea";
|
||||
|
||||
var content = `// AUTO-GENERATED on ${new Date().toISOString()}
|
||||
layout {
|
||||
border {
|
||||
active-color "${primary}"
|
||||
inactive-color "${secondary}"
|
||||
}
|
||||
focus-ring {
|
||||
active-color "${inverse}"
|
||||
}
|
||||
background-color "${bg}"
|
||||
}`;
|
||||
|
||||
niriConfigWriter.command = ["bash", "-c", `echo '${content}' > niri-colors.generated.kdl`];
|
||||
niriConfigWriter.running = true;
|
||||
}
|
||||
|
||||
function generateGhosttyConfig() {
|
||||
var dark = matugenColors.colors.dark;
|
||||
var light = matugenColors.colors.light;
|
||||
if (!dark || !light) return;
|
||||
|
||||
var bg = dark.background || "#1a1c1e";
|
||||
var fg = dark.on_background || "#e3e8ef";
|
||||
var primary = dark.primary || "#42a5f5";
|
||||
var secondary = dark.secondary || "#8ab4f8";
|
||||
var tertiary = dark.tertiary || "#bb86fc";
|
||||
var tertiary_ctr = dark.tertiary_container || "#3700b3";
|
||||
var error = dark.error || "#cf6679";
|
||||
var inverse = dark.inverse_primary || "#6200ea";
|
||||
|
||||
var bg_b = light.background || "#fef7ff";
|
||||
var fg_b = light.on_background || "#1d1b20";
|
||||
var primary_b = light.primary || "#1976d2";
|
||||
var secondary_b = light.secondary || "#1565c0";
|
||||
var tertiary_b = light.tertiary || "#7b1fa2";
|
||||
var tertiary_ctr_b = light.tertiary_container || "#e1bee7";
|
||||
var error_b = light.error || "#b00020";
|
||||
var inverse_b = light.inverse_primary || "#bb86fc";
|
||||
|
||||
var content = `# AUTO-GENERATED on ${new Date().toISOString()}
|
||||
background = ${bg}
|
||||
foreground = ${fg}
|
||||
cursor-color = ${inverse}
|
||||
selection-background = ${secondary}
|
||||
selection-foreground = #ffffff
|
||||
palette = 0=${bg}
|
||||
palette = 1=${error}
|
||||
palette = 2=${tertiary}
|
||||
palette = 3=${secondary}
|
||||
palette = 4=${primary}
|
||||
palette = 5=${tertiary_ctr}
|
||||
palette = 6=${inverse}
|
||||
palette = 7=${fg}
|
||||
palette = 8=${bg_b}
|
||||
palette = 9=${error_b}
|
||||
palette = 10=${tertiary_b}
|
||||
palette = 11=${secondary_b}
|
||||
palette = 12=${primary_b}
|
||||
palette = 13=${tertiary_ctr_b}
|
||||
palette = 14=${inverse_b}
|
||||
palette = 15=${fg_b}`;
|
||||
|
||||
ghosttyConfigWriter.command = ["bash", "-c", `echo '${content}' > ghostty-colors.generated.conf`];
|
||||
ghosttyConfigWriter.running = true;
|
||||
}
|
||||
|
||||
Process {
|
||||
id: niriConfigWriter
|
||||
running: false
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
console.log("Generated niri-colors.generated.kdl");
|
||||
} else {
|
||||
console.warn("Failed to generate niri config, exit code:", exitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: ghosttyConfigWriter
|
||||
running: false
|
||||
onExited: (exitCode) => {
|
||||
if (exitCode === 0) {
|
||||
console.log("Generated ghostty-colors.generated.conf");
|
||||
} else {
|
||||
console.warn("Failed to generate ghostty config, exit code:", exitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ Singleton {
|
||||
property string osLogoColorOverride: ""
|
||||
property real osLogoBrightness: 0.5
|
||||
property real osLogoContrast: 1.0
|
||||
property string wallpaperPath: ""
|
||||
property string wallpaperDirectory: StandardPaths.writableLocation(StandardPaths.PicturesLocation) + "/Wallpapers"
|
||||
property bool wallpaperDynamicTheming: true
|
||||
property string wallpaperLastPath: ""
|
||||
property string profileLastPath: ""
|
||||
|
||||
function loadSettings() {
|
||||
parseSettings(settingsFile.text());
|
||||
@@ -77,6 +82,11 @@ Singleton {
|
||||
osLogoColorOverride = settings.osLogoColorOverride !== undefined ? settings.osLogoColorOverride : "";
|
||||
osLogoBrightness = settings.osLogoBrightness !== undefined ? settings.osLogoBrightness : 0.5;
|
||||
osLogoContrast = settings.osLogoContrast !== undefined ? settings.osLogoContrast : 1.0;
|
||||
wallpaperPath = settings.wallpaperPath !== undefined ? settings.wallpaperPath : "";
|
||||
wallpaperDirectory = settings.wallpaperDirectory !== undefined ? settings.wallpaperDirectory : StandardPaths.writableLocation(StandardPaths.PicturesLocation) + "/Wallpapers";
|
||||
wallpaperDynamicTheming = settings.wallpaperDynamicTheming !== undefined ? settings.wallpaperDynamicTheming : true;
|
||||
wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : "";
|
||||
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : "";
|
||||
applyStoredTheme();
|
||||
detectAvailableIconThemes();
|
||||
updateGtkIconTheme(iconTheme);
|
||||
@@ -118,7 +128,12 @@ Singleton {
|
||||
"useOSLogo": useOSLogo,
|
||||
"osLogoColorOverride": osLogoColorOverride,
|
||||
"osLogoBrightness": osLogoBrightness,
|
||||
"osLogoContrast": osLogoContrast
|
||||
"osLogoContrast": osLogoContrast,
|
||||
"wallpaperPath": wallpaperPath,
|
||||
"wallpaperDirectory": wallpaperDirectory,
|
||||
"wallpaperDynamicTheming": wallpaperDynamicTheming,
|
||||
"wallpaperLastPath": wallpaperLastPath,
|
||||
"profileLastPath": profileLastPath
|
||||
}, null, 2));
|
||||
}
|
||||
|
||||
@@ -418,6 +433,43 @@ gtk-application-prefer-dark-theme=true`;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function setWallpaperPath(path) {
|
||||
wallpaperPath = path;
|
||||
saveSettings();
|
||||
|
||||
// Trigger dynamic theming if enabled
|
||||
if (wallpaperDynamicTheming && path && typeof Theme !== "undefined") {
|
||||
console.log("Wallpaper changed, triggering dynamic theme extraction");
|
||||
Theme.switchTheme(themeIndex, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
function setWallpaperDirectory(directory) {
|
||||
wallpaperDirectory = directory;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
function setWallpaperDynamicTheming(enabled) {
|
||||
wallpaperDynamicTheming = enabled;
|
||||
saveSettings();
|
||||
|
||||
// If enabled and we have a wallpaper, trigger dynamic theming
|
||||
if (enabled && wallpaperPath && typeof Theme !== "undefined") {
|
||||
console.log("Dynamic theming enabled, triggering theme extraction");
|
||||
Theme.switchTheme(themeIndex, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
function setWallpaper(imagePath) {
|
||||
wallpaperPath = imagePath;
|
||||
saveSettings();
|
||||
|
||||
// Trigger color extraction if dynamic theming is enabled
|
||||
if (wallpaperDynamicTheming && typeof Colors !== "undefined") {
|
||||
Colors.extractColors();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: loadSettings()
|
||||
onShowSystemResourcesChanged: {
|
||||
if (typeof SystemMonitorService !== 'undefined')
|
||||
@@ -535,4 +587,5 @@ gtk-application-prefer-dark-theme=true`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -602,19 +602,5 @@ Singleton {
|
||||
console.log("Theme initialized, waiting for Prefs to load settings and apply theme");
|
||||
}
|
||||
|
||||
// Wallpaper IPC handler
|
||||
IpcHandler {
|
||||
function refresh() {
|
||||
console.log("Wallpaper IPC: refresh() called");
|
||||
// Trigger color extraction if using dynamic theme
|
||||
if (typeof Theme !== "undefined" && Theme.isDynamicTheme) {
|
||||
console.log("Triggering color extraction due to wallpaper IPC");
|
||||
Colors.extractColors();
|
||||
}
|
||||
return "WALLPAPER_REFRESH_SUCCESS";
|
||||
}
|
||||
|
||||
target: "wallpaper"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user