Skip to content

Commit

Permalink
Merge pull request #96 from nwg-piotr/theme
Browse files Browse the repository at this point in the history
Force GTK_THEME for libadwaita apps
  • Loading branch information
nwg-piotr authored Jul 27, 2023
2 parents 2903abd + ebfaba1 commit 94b8b8d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=<default-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\"")
Expand Down
13 changes: 13 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,15 @@ func savePinned() {
}

func launch(command string, terminal bool) {
themeToPrepend := ""
// add "GTK_THEME=<default_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, "%")
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 94b8b8d

Please sign in to comment.