Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/cmd/dms/commands_matugen.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func init() {
cmd.Flags().String("state-dir", "", "State directory for cache files")
cmd.Flags().String("shell-dir", "", "DMS shell installation directory")
cmd.Flags().String("config-dir", "", "User config directory")
cmd.Flags().String("data-dir", "", "User data directory")
cmd.Flags().String("kind", "image", "Source type: image or hex")
cmd.Flags().String("value", "", "Wallpaper path or hex color")
cmd.Flags().String("mode", "dark", "Color mode: dark or light")
Expand All @@ -68,6 +69,7 @@ func buildMatugenOptions(cmd *cobra.Command) matugen.Options {
stateDir, _ := cmd.Flags().GetString("state-dir")
shellDir, _ := cmd.Flags().GetString("shell-dir")
configDir, _ := cmd.Flags().GetString("config-dir")
dataDir, _ := cmd.Flags().GetString("data-dir")
kind, _ := cmd.Flags().GetString("kind")
value, _ := cmd.Flags().GetString("value")
mode, _ := cmd.Flags().GetString("mode")
Expand All @@ -84,6 +86,7 @@ func buildMatugenOptions(cmd *cobra.Command) matugen.Options {
StateDir: stateDir,
ShellDir: shellDir,
ConfigDir: configDir,
DataDir: dataDir,
Kind: kind,
Value: value,
Mode: matugen.ColorMode(mode),
Expand Down Expand Up @@ -121,6 +124,7 @@ func runMatugenQueue(cmd *cobra.Command, args []string) {
"stateDir": opts.StateDir,
"shellDir": opts.ShellDir,
"configDir": opts.ConfigDir,
"dataDir": opts.DataDir,
"kind": opts.Kind,
"value": opts.Value,
"mode": opts.Mode,
Expand Down
1 change: 1 addition & 0 deletions core/internal/greeter/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ func syncGreeterDynamicOverrideColors(dmsPath, homeDir string, state greeterThem
StateDir: greeterOverrideColorsStateDir(homeDir),
ShellDir: dmsPath,
ConfigDir: filepath.Join(homeDir, ".config"),
DataDir: filepath.Join(homeDir, ".local/share"),
Kind: "image",
Value: state.ResolvedGreeterWallpaperPath,
Mode: mode,
Expand Down
37 changes: 11 additions & 26 deletions core/internal/matugen/matugen.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Options struct {
StateDir string
ShellDir string
ConfigDir string
DataDir string
Kind string
Value string
Mode ColorMode
Expand Down Expand Up @@ -143,6 +144,9 @@ func Run(opts Options) error {
if opts.ConfigDir == "" {
return fmt.Errorf("config-dir is required")
}
if opts.DataDir == "" {
return fmt.Errorf("data-dir is required")
}
if opts.Kind == "" {
return fmt.Errorf("kind is required")
}
Expand Down Expand Up @@ -283,16 +287,14 @@ func buildOnce(opts *Options) (bool, error) {
return true, nil
}

if isDMSGTKActive(opts.ConfigDir) {
switch opts.Mode {
case ColorModeLight:
syncAccentColor(primaryLight)
default:
syncAccentColor(primaryDark)
}
refreshGTK(opts.Mode)
refreshGTK4()
switch opts.Mode {
case ColorModeLight:
syncAccentColor(primaryLight)
default:
syncAccentColor(primaryDark)
}
refreshGTK(opts.Mode)
refreshGTK4()

if !opts.ShouldSkipTemplate("qt6ct") && appExists(opts.AppChecker, []string{"qt6ct"}, nil) {
refreshQt6ct()
Expand Down Expand Up @@ -776,23 +778,6 @@ func generateDank16Variants(primaryDark, primaryLight, surface string, mode Colo
return dank16.GenerateVariantJSON(variantColors)
}

func isDMSGTKActive(configDir string) bool {
gtkCSS := filepath.Join(configDir, "gtk-3.0", "gtk.css")

info, err := os.Lstat(gtkCSS)
if err != nil {
return false
}

if info.Mode()&os.ModeSymlink != 0 {
target, err := os.Readlink(gtkCSS)
return err == nil && strings.Contains(target, "dank-colors.css")
}

data, err := os.ReadFile(gtkCSS)
return err == nil && strings.Contains(string(data), "dank-colors.css")
}

func refreshGTK(mode ColorMode) {
if err := utils.GsettingsSet("org.gnome.desktop.interface", "gtk-theme", ""); err != nil {
log.Warnf("Failed to reset gtk-theme: %v", err)
Expand Down
1 change: 1 addition & 0 deletions core/internal/server/matugen_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func handleMatugenQueue(conn net.Conn, req models.Request) {
StateDir: models.GetOr(req, "stateDir", ""),
ShellDir: models.GetOr(req, "shellDir", ""),
ConfigDir: models.GetOr(req, "configDir", ""),
DataDir: models.GetOr(req, "dataDir", ""),
Kind: models.GetOr(req, "kind", ""),
Value: models.GetOr(req, "value", ""),
Mode: matugen.ColorMode(models.GetOr(req, "mode", "")),
Expand Down
5 changes: 3 additions & 2 deletions quickshell/Common/Theme.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Singleton {

readonly property string homeDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.HomeLocation))
readonly property string configDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation))
readonly property string dataDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.GenericDataLocation))
readonly property string shellDir: Paths.strip(Qt.resolvedUrl(".").toString()).replace("/Common/", "")
readonly property string wallpaperPath: {
if (typeof SessionData === "undefined")
Expand Down Expand Up @@ -1612,7 +1613,7 @@ Singleton {
log.debug("Starting matugen worker");
workerRunning = true;

const args = ["dms", "matugen", "queue", "--state-dir", stateDir, "--shell-dir", shellDir, "--config-dir", configDir, "--kind", desired.kind, "--value", desired.value, "--mode", desired.mode, "--icon-theme", desired.iconTheme, "--matugen-type", desired.matugenType,];
const args = ["dms", "matugen", "queue", "--state-dir", stateDir, "--shell-dir", shellDir, "--config-dir", configDir, "--data-dir", dataDir, "--kind", desired.kind, "--value", desired.value, "--mode", desired.mode, "--icon-theme", desired.iconTheme, "--matugen-type", desired.matugenType,];

if (!desired.runUserTemplates) {
args.push("--run-user-templates=false");
Expand Down Expand Up @@ -1865,7 +1866,7 @@ Singleton {
}

const isLight = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "true" : "false";
Proc.runCommand("gtkApplier", [shellDir + "/scripts/gtk.sh", configDir, isLight, shellDir], (output, exitCode) => {
Proc.runCommand("gtkApplier", [shellDir + "/scripts/gtk.sh", configDir, dataDir, isLight, shellDir], (output, exitCode) => {
if (exitCode === 0) {
if (typeof ToastService !== "undefined" && typeof NiriService !== "undefined" && !NiriService.matugenSuppression) {
ToastService.showInfo(I18n.tr("GTK colors applied successfully"));
Expand Down
6 changes: 5 additions & 1 deletion quickshell/matugen/configs/gtk3-dark.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[templates.dmsgtk3]
input_path = 'SHELL_DIR/matugen/templates/gtk-colors.css'
output_path = 'CONFIG_DIR/gtk-3.0/dank-colors.css'
output_path = 'DATA_DIR/themes/adw-gtk3-dark/gtk-3.0/dank-colors.css'
post_hook = '''
sed -i.backup '/\/\* BEGIN DMS OVERRIDE \*\//,/\/\* END DMS OVERRIDE \*\//d' 'DATA_DIR/themes/adw-gtk3-dark/gtk-3.0/gtk.css'
cat 'DATA_DIR/themes/adw-gtk3-dark/gtk-3.0/dank-colors.css' >> 'DATA_DIR/themes/adw-gtk3-dark/gtk-3.0/gtk.css'
'''

[templates.dmsgtk4]
input_path = 'SHELL_DIR/matugen/templates/gtk-colors.css'
Expand Down
6 changes: 5 additions & 1 deletion quickshell/matugen/configs/gtk3-light.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[templates.dmsgtk3]
input_path = 'SHELL_DIR/matugen/templates/gtk-light-colors.css'
output_path = 'CONFIG_DIR/gtk-3.0/dank-colors.css'
output_path = 'DATA_DIR/themes/adw-gtk3/gtk-3.0/dank-colors.css'
post_hook = '''
sed -i.backup '/\/\* BEGIN DMS OVERRIDE \*\//,/\/\* END DMS OVERRIDE \*\//d' 'DATA_DIR/themes/adw-gtk3/gtk-3.0/gtk.css';
cat 'DATA_DIR/themes/adw-gtk3/gtk-3.0/dank-colors.css' >> 'DATA_DIR/themes/adw-gtk3/gtk-3.0/gtk.css'
'''

[templates.dmsgtk4]
input_path = 'SHELL_DIR/matugen/templates/gtk-colors.css'
Expand Down
4 changes: 4 additions & 0 deletions quickshell/matugen/templates/gtk-colors.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* BEGIN DMS OVERRIDE */

/*
* GTK Colors
* Generated with Matugen
Expand Down Expand Up @@ -46,3 +48,5 @@ a color between surface and surface container so I think just giving this surfac
@define-color theme_unfocused_base_color @window_bg_color;
@define-color theme_unfocused_selected_bg_color @accent_bg_color;
@define-color theme_unfocused_selected_fg_color @accent_fg_color;

/* END DMS OVERRIDE */
Loading
Loading