From e341759b9e70f4414de720df7be18b6dd5232ed9 Mon Sep 17 00:00:00 2001 From: wtl Date: Thu, 23 Sep 2021 16:05:17 +0300 Subject: [PATCH] Add support for absolute paths In reference to https://github.com/nwg-piotr/nwg-bar/issues/1 --- Makefile | 4 ++-- main.go | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 48198c5..9144a52 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ get: go get "github.com/sirupsen/logrus" build: - go build -o bin/nwg-drawer *.go + go build -o bin/nwg-drawer . install: mkdir -p /usr/share/nwg-drawer @@ -21,5 +21,5 @@ uninstall: rm /usr/bin/nwg-drawer run: - go build -o bin/nwg-drawer *.go + go build -o bin/nwg-drawer . bin/nwg-drawer diff --git a/main.go b/main.go index c0e5dde..f2c3990 100644 --- a/main.go +++ b/main.go @@ -190,7 +190,9 @@ func main() { } log.Info(fmt.Sprintf("Found %v pinned items", len(pinned))) - cssFile := filepath.Join(configDirectory, *cssFileName) + if !strings.HasPrefix(*cssFileName, "/") { + *cssFileName = filepath.Join(configDirectory, *cssFileName) + } appDirs = getAppDirs() @@ -216,12 +218,12 @@ func main() { cssProvider, _ := gtk.CssProviderNew() - err = cssProvider.LoadFromPath(cssFile) + err = cssProvider.LoadFromPath(*cssFileName) if err != nil { - log.Errorf("ERROR: %s css file not found or erroneous. Using GTK styling.", cssFile) + log.Errorf("ERROR: %s css file not found or erroneous. Using GTK styling.", *cssFileName) log.Errorf("%s", err) } else { - log.Info(fmt.Sprintf("Using style from %s", cssFile)) + log.Info(fmt.Sprintf("Using style from %s", *cssFileName)) screen, _ := gdk.ScreenGetDefault() gtk.AddProviderForScreen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) }