Shizcow / dmenu-rs

A pixel perfect port of dmenu, rewritten in Rust with extensive plugin support
GNU General Public License v3.0
202 stars 9 forks source link

Lookup plugin #36

Closed carrascomj closed 4 years ago

carrascomj commented 4 years ago

Closes #35

Description

Allow for a promptSearch like in xmonad. Adds the lookup FLAG:

-L, --lookup
            The input in the prompt will be used as the search term in the selected engine (duckduckgo as default). XDG-
            OPEN will be used for opening the  links.

With the engine OPTION:

--engine <engine>
            Engine to look up into. Possible values: ["github", "rust", "archwiki", "ddg", "english"]. More engines can
            be added at lookup/main.rs

The usage accepts any of the following:

Implementation

A HashMap with once_cell is used for the mappings from the input to the engine.

Shizcow commented 4 years ago

I'm impressed with how seamless this plugin is. Thanks for your contribution!

You mentioned lazy_static having some problems, which I'm not surprised about. I think phf::map could make things more optimal, but that increases dependency count by a lot. Then again this project already has ~300 dependencies when fully loaded anyway so I don't care either way.

I see you're still making some tweaks so I'll merge tomorrow morning. Minor changes I'd love (but can totally do myself):

carrascomj commented 4 years ago

Cool! I implemented your suggestions and it is ready from my side. Feel free to change whatever you want (maybe you prefer other names for the engines, I just picked whatever was easy to read).

Shizcow commented 4 years ago

Thanks for the edits. Looking forward to putting echo -e "crates\ngithub\nrust\nddg\nenglish\ndocs\narchwiki" | dmenu | dmenu --lookup somewhere is my dotfiles :+1:

Shizcow commented 4 years ago

After a week of frequent use, I've addressed minor areas of improvement. Everything's documented in make plugins and dmenu --help, but here's an overview:

This now simplifies the lookup command in my previous comment to:

dmenu --lookup --list-engines | dmenu | dmenu --lookup
carrascomj commented 4 years ago

That's very convenient, I like it :+1: