1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-15 18:22:08 -04:00

matugen: fix app checking

- double nil for flatpak + bin required to skip
This commit is contained in:
bbedward
2026-01-04 17:53:47 -05:00
parent 29d27ebd6d
commit 7ac5191e8d
5 changed files with 322 additions and 14 deletions

View File

@@ -51,6 +51,7 @@ type Options struct {
SyncModeWithPortal bool
TerminalsAlwaysDark bool
SkipTemplates string
AppChecker utils.AppChecker
}
type ColorsOutput struct {
@@ -101,6 +102,9 @@ func Run(opts Options) error {
if opts.IconTheme == "" {
opts.IconTheme = "System Default"
}
if opts.AppChecker == nil {
opts.AppChecker = utils.DefaultAppChecker{}
}
if err := os.MkdirAll(opts.StateDir, 0755); err != nil {
return fmt.Errorf("failed to create state dir: %w", err)
@@ -353,10 +357,7 @@ func appendConfig(
if _, err := os.Stat(configPath); err != nil {
return
}
cmdExists := checkCmd == nil || utils.AnyCommandExists(checkCmd...)
flatpakExists := checkFlatpaks == nil || utils.AnyFlatpakExists(checkFlatpaks...)
if !cmdExists && !flatpakExists {
if !appExists(opts.AppChecker, checkCmd, checkFlatpaks) {
return
}
data, err := os.ReadFile(configPath)
@@ -372,10 +373,7 @@ func appendTerminalConfig(opts *Options, cfgFile *os.File, tmpDir string, checkC
if _, err := os.Stat(configPath); err != nil {
return
}
cmdExists := checkCmd == nil || utils.AnyCommandExists(checkCmd...)
flatpakExists := checkFlatpaks == nil || utils.AnyFlatpakExists(checkFlatpaks...)
if !cmdExists && !flatpakExists {
if !appExists(opts.AppChecker, checkCmd, checkFlatpaks) {
return
}
data, err := os.ReadFile(configPath)
@@ -428,6 +426,20 @@ func appendTerminalConfig(opts *Options, cfgFile *os.File, tmpDir string, checkC
cfgFile.WriteString("\n")
}
func appExists(checker utils.AppChecker, checkCmd []string, checkFlatpaks []string) bool {
// Both nil is treated as "skip check" / unconditionally run
if checkCmd == nil && checkFlatpaks == nil {
return true
}
if checkCmd != nil && checker.AnyCommandExists(checkCmd...) {
return true
}
if checkFlatpaks != nil && checker.AnyFlatpakExists(checkFlatpaks...) {
return true
}
return false
}
func appendVSCodeConfig(cfgFile *os.File, name, extBaseDir, shellDir string) {
pattern := filepath.Join(extBaseDir, "danklinux.dms-theme-*")
matches, err := filepath.Glob(pattern)