swaysw: don't return error when no window is selected in wofi

This commit is contained in:
Asmir A 2023-10-27 12:15:26 +02:00
parent de732b8317
commit 1e49032fbf

View File

@ -44,7 +44,7 @@ func selectWithWofi(windows string) string {
cmd.Stdin = strings.NewReader(windows) cmd.Stdin = strings.NewReader(windows)
stdout, err := cmd.Output() stdout, err := cmd.Output()
if err != nil { if err != nil {
log.Fatal(err) return ""
} }
return strings.TrimSpace(string(stdout)) return strings.TrimSpace(string(stdout))
} }
@ -82,7 +82,8 @@ func main() {
var windows []window var windows []window
flatten(swaymsg_output, &windows) flatten(swaymsg_output, &windows)
selected := selectWithWofi(getWindowNames(windows)) if selected := selectWithWofi(getWindowNames(windows)); selected != "" {
windowId := findWindowId(selected, windows) windowId := findWindowId(selected, windows)
switchToWindow(windowId) switchToWindow(windowId)
} }
}