diff --git a/main.go b/main.go index 426d138..0b9d795 100644 --- a/main.go +++ b/main.go @@ -127,6 +127,7 @@ var marginLeft = flag.Int("ml", 0, "Margin Left") var marginRight = flag.Int("mr", 0, "Margin Right") var marginBottom = flag.Int("mb", 0, "Margin Bottom") var fsColumns = flag.Uint("fscol", 2, "File Search result COLumns") +var forceTheme = flag.Bool("ft", false, "Force Theme for libadwaita apps, by adding GTK_THEME= env var") var columnsNumber = flag.Uint("c", 6, "number of Columns") var itemSpacing = flag.Uint("spacing", 20, "icon spacing") var lang = flag.String("lang", "", "force lang, e.g. \"en\", \"pl\"") diff --git a/tools.go b/tools.go index 98a171b..e573554 100644 --- a/tools.go +++ b/tools.go @@ -548,6 +548,15 @@ func savePinned() { } func launch(command string, terminal bool) { + themeToPrepend := "" + // add "GTK_THEME=" environment variable + if *forceTheme { + settings, _ := gtk.SettingsGetDefault() + th, err := settings.GetProperty("gtk-theme-name") + if err == nil { + themeToPrepend = th.(string) + } + } // trim % and everything afterwards if strings.Contains(command, "%") { cutAt := strings.Index(command, "%") @@ -577,6 +586,10 @@ func launch(command string, terminal bool) { cmdIdx = 0 } + if themeToPrepend != "" { + envVars = append(envVars, fmt.Sprintf("GTK_THEME=%s", themeToPrepend)) + } + cmd := exec.Command(elements[cmdIdx], elements[1+cmdIdx:]...) if terminal {