From c8f8e27a6528daa6dc4487aa63040e38746dba9a Mon Sep 17 00:00:00 2001 From: Oliver Walter Date: Fri, 20 Dec 2024 04:17:36 +0100 Subject: [PATCH] only serach in custom director. hide&wait for the program to exit. --- run_forever.sh | 11 +++++++++++ tools.go | 38 ++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 run_forever.sh diff --git a/run_forever.sh b/run_forever.sh new file mode 100644 index 0000000..e1f233c --- /dev/null +++ b/run_forever.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Infinite loop to run the command +while true; do + echo "Starting nwg-drawer..." + bin/nwg-drawer -nocats -nofs -ovl -d +done & + + +# Return immediately after starting the loop +echo "The loop is running in the background." \ No newline at end of file diff --git a/tools.go b/tools.go index 14af67c..7fecda6 100644 --- a/tools.go +++ b/tools.go @@ -5,8 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/joshuarubin/go-sway" - log "github.com/sirupsen/logrus" "io" "io/fs" "net" @@ -20,6 +18,9 @@ import ( "syscall" "time" + "github.com/joshuarubin/go-sway" + log "github.com/sirupsen/logrus" + "github.com/diamondburned/gotk4/pkg/gdk/v3" "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2" "github.com/diamondburned/gotk4/pkg/gtk/v3" @@ -250,35 +251,26 @@ func dataDir() string { func getAppDirs() []string { var dirs []string + log.Info("App dirs::") home := os.Getenv("HOME") - xdgDataHome := os.Getenv("XDG_DATA_HOME") - xdgDataDirs := os.Getenv("XDG_DATA_DIRS") - if xdgDataDirs == "" { - xdgDataDirs = "/usr/local/share/:/usr/share/" + //xdgDataHome := os.Getenv("XDG_DATA_HOME") + //xdgDataDirs := os.Getenv("XDG_DATA_DIRS") + if home != "" { + dirs = append(dirs, filepath.Join(home, "/my_applications")) } - if xdgDataHome != "" { - dirs = append(dirs, filepath.Join(xdgDataHome, "applications")) - } else if home != "" { - dirs = append(dirs, filepath.Join(home, ".local/share/applications")) - } - for _, d := range strings.Split(xdgDataDirs, ":") { - dirs = append(dirs, filepath.Join(d, "applications")) - } - flatpakDirs := []string{filepath.Join(home, ".local/share/flatpak/exports/share/applications"), - "/var/lib/flatpak/exports/share/applications"} - for _, d := range flatpakDirs { - if pathExists(d) && !isIn(dirs, d) { - dirs = append(dirs, d) - } - } + log.Infof("App dirs: %v", dirs) + var confirmedDirs []string for _, d := range dirs { if pathExists(d) { confirmedDirs = append(confirmedDirs, d) } } + + log.Infof("App dirs: %v", dirs) + return confirmedDirs } @@ -625,7 +617,10 @@ func launch(command string, terminal bool, terminate bool) { // Collect the exit code of the child process to prevent zombies // if the drawer runs in resident mode go func() { + restoreStateAndHide() _ = cmd.Wait() + gtk.MainQuit() + }() } @@ -633,7 +628,6 @@ func launch(command string, terminal bool, terminate bool) { if *resident { restoreStateAndHide() } else { - gtk.MainQuit() } } }