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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user