Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85320215be | |||
| f35903bfb7 | |||
| c8f8e27a65 | |||
|
|
4110554466 | ||
|
|
7d1242d6ce |
43
main.go
43
main.go
@@ -3,8 +3,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4-layer-shell/pkg/gtklayershell"
|
||||
"github.com/expr-lang/expr"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
@@ -14,6 +12,9 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/diamondburned/gotk4-layer-shell/pkg/gtklayershell"
|
||||
"github.com/expr-lang/expr"
|
||||
|
||||
"github.com/allan-simon/go-singleinstance"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
@@ -112,10 +113,10 @@ var desktopEntries []desktopEntry
|
||||
|
||||
// UI elements
|
||||
var (
|
||||
win *gtk.Window
|
||||
resultWindow *gtk.ScrolledWindow
|
||||
fileSearchResults []string
|
||||
searchEntry *gtk.SearchEntry
|
||||
win *gtk.Window
|
||||
resultWindow *gtk.ScrolledWindow
|
||||
fileSearchResults []string
|
||||
//searchEntry *gtk.SearchEntry
|
||||
phrase string
|
||||
fileSearchResultFlowBox *gtk.FlowBox
|
||||
userDirsMap map[string]string
|
||||
@@ -472,10 +473,11 @@ func main() {
|
||||
//key := &gdk.EventKey{Event: event}
|
||||
key := event.AsKey()
|
||||
if key.Keyval() == gdk.KEY_Escape {
|
||||
s := searchEntry.Text()
|
||||
//s := searchEntry.Text()
|
||||
s := ""
|
||||
if s != "" {
|
||||
searchEntry.GrabFocus()
|
||||
searchEntry.SetText("")
|
||||
//searchEntry.GrabFocus()
|
||||
//searchEntry.SetText("")
|
||||
} else {
|
||||
if !*resident {
|
||||
gtk.MainQuit()
|
||||
@@ -491,7 +493,8 @@ func main() {
|
||||
}
|
||||
|
||||
} else if key.Keyval() == gdk.KEY_Return {
|
||||
s := searchEntry.Text()
|
||||
//s := searchEntry.Text()
|
||||
s := ""
|
||||
if s != "" {
|
||||
// Check if the search box content is an arithmetic expression. If so, display the result
|
||||
// and copy to the clipboard with wl-copy.
|
||||
@@ -515,9 +518,9 @@ func main() {
|
||||
return false
|
||||
|
||||
default:
|
||||
if !searchEntry.IsFocus() {
|
||||
searchEntry.GrabFocusWithoutSelecting()
|
||||
}
|
||||
//if !searchEntry.IsFocus() {
|
||||
// searchEntry.GrabFocusWithoutSelecting()
|
||||
//}
|
||||
}
|
||||
return false
|
||||
})
|
||||
@@ -537,12 +540,12 @@ func main() {
|
||||
outerVBox := gtk.NewBox(gtk.OrientationVertical, 0)
|
||||
win.Add(outerVBox)
|
||||
|
||||
searchBoxWrapper := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
outerVBox.PackStart(searchBoxWrapper, false, false, 10)
|
||||
//searchBoxWrapper := gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
//outerVBox.PackStart(searchBoxWrapper, false, false, 10)
|
||||
|
||||
searchEntry = setUpSearchEntry()
|
||||
searchEntry.SetMaxWidthChars(30)
|
||||
searchBoxWrapper.PackStart(searchEntry, true, false, 0)
|
||||
//searchEntry = setUpSearchEntry()
|
||||
//searchEntry.SetMaxWidthChars(30)
|
||||
//searchBoxWrapper.PackStart(searchEntry, true, false, 0)
|
||||
|
||||
if !*noCats {
|
||||
categoriesWrapper = gtk.NewBox(gtk.OrientationHorizontal, 0)
|
||||
@@ -771,7 +774,7 @@ func restoreStateAndHide() {
|
||||
}
|
||||
|
||||
// clear search
|
||||
searchEntry.SetText("")
|
||||
//searchEntry.SetText("")
|
||||
|
||||
// One day or another we'll add SetFilterFunction here; it was impossible on the gotk3 library
|
||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
||||
@@ -786,5 +789,5 @@ func restoreStateAndHide() {
|
||||
}
|
||||
|
||||
t := time.Now()
|
||||
log.Debugf(fmt.Sprintf("UI hidden and restored in the backgroud in %v ms", t.Sub(timeStart1).Milliseconds()))
|
||||
log.Debugf(fmt.Sprintf("UI hidden and restored in the background in %v ms", t.Sub(timeStart1).Milliseconds()))
|
||||
}
|
||||
|
||||
11
run_forever.sh
Normal file
11
run_forever.sh
Normal 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."
|
||||
46
tools.go
46
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,36 @@ 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/"
|
||||
}
|
||||
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"}
|
||||
//xdgDataHome := os.Getenv("XDG_DATA_HOME")
|
||||
//xdgDataDirs := os.Getenv("XDG_DATA_DIRS")
|
||||
|
||||
for _, d := range flatpakDirs {
|
||||
if pathExists(d) && !isIn(dirs, d) {
|
||||
dirs = append(dirs, d)
|
||||
custom := os.Getenv("CUSTOM_DATA_DIRS")
|
||||
|
||||
if home != "" {
|
||||
if custom == "" {
|
||||
dirs = append(dirs, filepath.Join(home, "/my_applications"))
|
||||
} else {
|
||||
dirs = append(dirs, filepath.Join(home, custom))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 +627,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 +638,6 @@ func launch(command string, terminal bool, terminate bool) {
|
||||
if *resident {
|
||||
restoreStateAndHide()
|
||||
} else {
|
||||
gtk.MainQuit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/diamondburned/gotk4-layer-shell/pkg/gtklayershell"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/diamondburned/gotk4-layer-shell/pkg/gtklayershell"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/diamondburned/gotk4/pkg/gdk/v3"
|
||||
@@ -115,7 +116,7 @@ func setUpCategoriesButtonBox() *gtk.EventBox {
|
||||
button := gtk.NewButtonWithLabel("All")
|
||||
button.SetObjectProperty("name", "category-button")
|
||||
button.Connect("clicked", func(item *gtk.Button) {
|
||||
searchEntry.SetText("")
|
||||
//searchEntry.SetText("")
|
||||
appFlowBox = setUpAppsFlowBox(nil, "")
|
||||
for _, btn := range catButtons {
|
||||
btn.SetImagePosition(gtk.PosLeft)
|
||||
@@ -135,7 +136,7 @@ func setUpCategoriesButtonBox() *gtk.EventBox {
|
||||
name := cat.Name
|
||||
b := *button
|
||||
button.Connect("clicked", func(item *gtk.Button) {
|
||||
searchEntry.SetText("")
|
||||
//searchEntry.SetText("")
|
||||
// One day or another we'll add SetFilterFunction here; it was impossible on the gotk3 library
|
||||
appFlowBox = setUpAppsFlowBox(lists[name], "")
|
||||
for _, btn := range catButtons {
|
||||
|
||||
Reference in New Issue
Block a user