DankMaterialShell icon indicating copy to clipboard operation
DankMaterialShell copied to clipboard

VSCode/Code-OSS theming toggle never activates: nothing installs the danklinux.dms-theme extension

Open Conava opened this issue 4 months ago • 1 comments

Summary

The "VSCode" matugen template (matugenTemplateVscode in Settings → Theme & Colors) never does anything, on any editor, on a fresh install. dms matugen check reports vscode: detected: false forever, with no error anywhere telling you why. I traced it to core/internal/matugen/matugen.go: detection and config generation both require the danklinux.dms-theme-* extension folder to already exist under the editor's extensions dir, but nothing in the codebase ever creates that folder. It's a bootstrap gap, not a detection bug in the usual sense.

Environment

  • DMS v1.5.2 (dms version)
  • CachyOS (Arch-based)
  • Editor: code package (the FOSS/Code-OSS build). /usr/bin/code is a symlink to /usr/bin/code-oss; product.json reports nameShort: "Code - OSS", dataFolderName: ".vscode-oss"

Steps to reproduce

  1. Install Code-OSS (or VS Code, Cursor, Windsurf, VSCodium)
  2. Leave matugenTemplateVscode on (the default)
  3. Set a wallpaper, or run dms matugen generate
  4. Run dms matugen check

Expected

vscode shows detected: true, and a DankShell theme extension gets installed and kept in sync with the current palette, the same way GTK/Qt/kitty/etc. are handled.

Actual

vscode shows detected: false no matter what's installed. No log line, no Settings warning, no dms doctor flag. The toggle looks live but silently does nothing, indefinitely.

Root cause

Two functions in core/internal/matugen/matugen.go, both gated on the same precondition that's never satisfied:

checkVSCodeExtension (~line 1170) glob-matches danklinux.dms-theme-* inside each candidate extensions dir (~/.vscode/extensions, ~/.vscode-oss/extensions, ~/.config/Code - OSS/extensions, ~/.cursor/extensions, ~/.windsurf/extensions) and only returns true if a match already exists:

func checkVSCodeExtension(homeDir string) bool {
	extDirs := []string{
		filepath.Join(homeDir, ".vscode/extensions"),
		filepath.Join(homeDir, ".vscode-oss/extensions"),
		filepath.Join(homeDir, ".config/Code - OSS/extensions"),
		filepath.Join(homeDir, ".cursor/extensions"),
		filepath.Join(homeDir, ".windsurf/extensions"),
	}
	for _, extDir := range extDirs {
		pattern := filepath.Join(extDir, "danklinux.dms-theme-*")
		if matches, err := filepath.Glob(pattern); err == nil && len(matches) > 0 {
			return true
		}
	}
	return false
}

appendVSCodeConfig (~line 636), which wires matugen to actually write colors into the extension's theme JSON files, bails the same way:

func appendVSCodeConfig(cfgFile *os.File, name, extBaseDir, shellDir string) {
	pattern := filepath.Join(extBaseDir, "danklinux.dms-theme-*")
	matches, err := filepath.Glob(pattern)
	if err != nil || len(matches) == 0 {
		return
	}
	...

So both detection and config generation assume danklinux.dms-theme-* is already sitting in the extensions directory, and nothing installs it there. Every other template kind in this file detects the editor itself: binary on PATH, or its config dir existing. VSCode is the only one that checks for DMS's own artifact instead, which is circular. The artifact only gets written once detection passes, and detection only passes once the artifact exists.

The extension itself isn't missing or broken. matugen/vsix-build/ (shipped under the shell dir, e.g. /usr/share/quickshell/dms/matugen/vsix-build/ on Arch) is a complete, valid, unpacked VS Code extension: package.json declaring three themes, an icon, placeholder themes/dankshell-{default,dark,light}.json files. No build step needed. VS Code loads unpacked extensions straight from a <publisher>.<name>-<version> folder in the extensions dir. It just never gets copied anywhere.

Verified workaround

mkdir -p ~/.vscode-oss/extensions/danklinux.dms-theme-0.0.3
cp -r /usr/share/quickshell/dms/matugen/vsix-build/* ~/.vscode-oss/extensions/danklinux.dms-theme-0.0.3/

Immediately after, dms matugen check reports vscode: detected: true, and dms matugen generate logs Added codium theme config (extension found at ...) and writes real generated colors into the theme JSON (editor.background went from the placeholder #1a1a2e to a generated #181216 matching my current wallpaper palette). Set "workbench.colorTheme" in the editor's settings.json and it applies, then stays in sync from then on. The whole downstream pipeline works fine. The only missing piece is the initial install.

Secondary bug, same file

Around line 473-479, the block registering append targets per editor has this line:

appendVSCodeConfig(cfgFile, "codeoss", filepath.Join(homeDir, ".config/Code - OSS/extensions"), opts.ShellDir)

That path is wrong. Code-OSS's real extensions dir, per its own product.json (dataFolderName: ".vscode-oss"), is ~/.vscode-oss/extensions, already correctly targeted by the codium line right above it. ~/.config/Code - OSS/ is the user data directory (settings.json, keybindings, etc.), not where extensions live, so the codeoss entry can never match anything. Harmless today since codium already covers the real path, but it's dead code that'll mislead the next person debugging this.

Suggested fix

Simplest version: when the vscode toggle is on and an eligible editor is detected by its own presence (binary on PATH or its config dir existing, same as every other template), copy vsix-build/ into the matching extensions dir automatically. First run, dms doctor, or the first matugen generate after the toggle flips on would all work. That's literally the two-line workaround above, just run by DMS instead of by hand.

If that's more than you want to take on right now, even a stopgap message (Settings UI or dms doctor) saying "VSCode theme extension not installed, copy vsix-build/ to <path> to enable" would stop this from being a silent dead toggle.

Happy to send a PR for this if you're open to the approach above. Wanted to check your preferred direction first before writing code.

Conava avatar Jul 29 '26 22:07 Conava

Its intentional to not auto-install the extension since many dont want it, but it is available on marketplace https://danklinux.com/docs/dankmaterialshell/application-themes#vscode--codium--cursor--windsurf and I made the template have a description explaining that

bbedward avatar Jul 30 '26 19:07 bbedward