only serach in custom director.

hide&wait for the program to exit.
This commit is contained in:
2024-12-20 04:17:36 +01:00
parent 4110554466
commit c8f8e27a65
2 changed files with 27 additions and 22 deletions

11
run_forever.sh Normal file
View File

@@ -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."

View File

@@ -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()
}
}
}