From 4afa9f1aa3b2e087952b05ba6d7253c6b7485ce0 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 Sep 2024 13:26:18 +0200 Subject: [PATCH 1/6] add `riverctl spawn` --- main.go | 2 +- tools.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 10beb7a..e4285e3 100644 --- a/main.go +++ b/main.go @@ -171,7 +171,7 @@ var itemSpacing = flag.Uint("spacing", 20, "icon spacing") var lang = flag.String("lang", "", "force lang, e.g. \"en\", \"pl\"") var fileManager = flag.String("fm", "thunar", "File Manager") var term = flag.String("term", defaultTermIfBlank(os.Getenv("TERM"), "foot"), "Terminal emulator") -var wm = flag.String("wm", "", "use swaymsg exec (with 'sway' argument) or hyprctl dispatch exec (with 'hyprland') to launch programs") +var wm = flag.String("wm", "", "use swaymsg exec (with 'sway' argument) or hyprctl dispatch exec (with 'hyprland') or riverctl spawn (with 'river') to launch programs") var nameLimit = flag.Int("fslen", 80, "File Search name LENgth Limit") var noCats = flag.Bool("nocats", false, "Disable filtering by category") var noFS = flag.Bool("nofs", false, "Disable file search") diff --git a/tools.go b/tools.go index a16c20b..0ac96bc 100644 --- a/tools.go +++ b/tools.go @@ -611,6 +611,8 @@ func launch(command string, terminal bool) { cmd = exec.Command("swaymsg", "exec", strings.Join(elements, " ")) } else if *wm == "hyprland" || *wm == "Hyprland" { cmd = exec.Command("hyprctl", "dispatch", "exec", strings.Join(elements, " ")) + } else if *wm == "river" { + cmd = exec.Command("riverctl", "spawn", strings.Join(elements, " ")) } msg := fmt.Sprintf("command: %q; args: %q\n", cmd.Args[0], cmd.Args[1:]) From 86c92328cd25838e079d5f4ca6c8e79d2a1f6787 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 Sep 2024 13:29:07 +0200 Subject: [PATCH 2/6] update dependencies --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index d2086bb..27e82b6 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,6 @@ require ( require ( github.com/joshuarubin/lifecycle v1.1.4 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect ) diff --git a/go.sum b/go.sum index 9acb641..3586d10 100644 --- a/go.sum +++ b/go.sum @@ -30,9 +30,13 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 1015f4c48f83b4ecd244a29146aa5cb8954fb163 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 Sep 2024 13:44:02 +0200 Subject: [PATCH 3/6] fix hyprclt & mapping output->monitor --- tools.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tools.go b/tools.go index 0ac96bc..1aed16d 100644 --- a/tools.go +++ b/tools.go @@ -689,13 +689,8 @@ func mapOutputs() (map[string]*gdk.Monitor, error) { num := display.GetNMonitors() for i := 0; i < num; i++ { mon, _ := display.GetMonitor(i) - geometry := mon.GetGeometry() - // assign output to monitor on the basis of the same x, y coordinates - for _, output := range hyprlandMonitors { - if int(output.X) == geometry.GetX() && int(output.Y) == geometry.GetY() { - result[output.Name] = mon - } - } + output := hyprlandMonitors[i] + result[output.Name] = mon } } else { return nil, err @@ -723,13 +718,8 @@ func mapOutputs() (map[string]*gdk.Monitor, error) { num := display.GetNMonitors() for i := 0; i < num; i++ { mon, _ := display.GetMonitor(i) - geometry := mon.GetGeometry() - // assign output to monitor on the basis of the same x, y coordinates - for _, output := range outputs { - if int(output.Rect.X) == geometry.GetX() && int(output.Rect.Y) == geometry.GetY() { - result[output.Name] = mon - } - } + output := outputs[i] + result[output.Name] = mon } } else { return nil, errors.New("output assignment only supported on sway and Hyprland") @@ -756,7 +746,15 @@ func substring(s string, start int, end int) string { func hyprctl(cmd string) ([]byte, error) { his := os.Getenv("HYPRLAND_INSTANCE_SIGNATURE") - socketFile := fmt.Sprintf("/tmp/hypr/%s/.socket.sock", his) + xdgRuntimeDir := os.Getenv("XDG_RUNTIME_DIR") + hyprDir := "" + if xdgRuntimeDir != "" { + hyprDir = fmt.Sprintf("%s/hypr", xdgRuntimeDir) + } else { + hyprDir = "/tmp/hypr" + } + + socketFile := fmt.Sprintf("%s/%s/.socket.sock", hyprDir, his) conn, err := net.Dial("unix", socketFile) if err != nil { return nil, err From e3cb0af2bdd0128a814c417c804c9a16d8caafcd Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 Sep 2024 13:51:46 +0200 Subject: [PATCH 4/6] println -> log.Debug --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index e4285e3..bb5825f 100644 --- a/main.go +++ b/main.go @@ -438,7 +438,7 @@ func main() { if *targetOutput != "" { // We want to assign layershell to a monitor, but we only know the output name! output2mon, err = mapOutputs() - fmt.Println(">>>", output2mon) + log.Debugf("output2mon: %s", output2mon) if err == nil { monitor := output2mon[*targetOutput] layershell.SetMonitor(win, monitor) From e77d189f4a57640f413418ccd46536f5efc3d011 Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 Sep 2024 13:54:32 +0200 Subject: [PATCH 5/6] println -> log.Debug --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index bb5825f..6e17f7c 100644 --- a/main.go +++ b/main.go @@ -419,7 +419,6 @@ func main() { err = cssProvider.LoadFromPath(*cssFileName) if err != nil { 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", *cssFileName)) screen, _ := gdk.ScreenGetDefault() From c4a268332a6a96f7e5fa89806c782ac365dd631b Mon Sep 17 00:00:00 2001 From: piotr Date: Sun, 22 Sep 2024 13:57:01 +0200 Subject: [PATCH 6/6] bump to 0.5.0 --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 6e17f7c..1aaa261 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ import ( "github.com/gotk3/gotk3/gtk" ) -const version = "0.4.9" +const version = "0.5.0" var ( appDirs []string