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", args = []string{"rofi", "-dmenu",
"-lines", "-lines",
strconv.Itoa(max)} strconv.Itoa(max)}
case "wofi":
args = []string{"wofi", "--show", "dmenu", strconv.Itoa(max)}
default: default:
return "", fmt.Errorf("Unsupported tool: %s", tool) return "", fmt.Errorf("Unsupported tool: %s", tool)
} }
@ -53,7 +55,13 @@ func selector(data []string, max int, tool string) (string, error) {
} }
return "", err 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] sel, ok := guide[selected]
if !ok { if !ok {