feat(selector): add support for wofi (#24)

This commit is contained in:
Luis Pabon 2019-09-29 09:06:01 +01:00 committed by yory8
parent 913fb79ce8
commit 9641dc48e7

View file

@ -38,6 +38,8 @@ func selector(data []string, max int, tool string) (string, error) {
args = []string{"rofi", "-dmenu",
"-lines",
strconv.Itoa(max)}
case "wofi":
args = []string{"wofi", "--show", "dmenu", strconv.Itoa(max)}
default:
return "", fmt.Errorf("Unsupported tool: %s", tool)
}
@ -53,7 +55,13 @@ func selector(data []string, max int, tool string) (string, error) {
}
return "", err
}
selected := string(b[:len(b)-1]) // drop newline added by dmenu/rofi
// Wofi however does not error when no selection is done
if len(b) == 0 {
return "", nil
}
selected := string(b[:len(b)-1]) // drop newline added by dmenu/rofi/wofi
sel, ok := guide[selected]
if !ok {