2023-08-21 23:02:58 +00:00
|
|
|
X-Date: 2023-08-21T23:30:00Z
|
|
|
|
X-Note-Id: 19a3f09f-467c-4ba5-ba58-fd954cd931ea
|
|
|
|
Subject: A fuzzy launcher I use for the last 2 years
|
|
|
|
X-Slug: a_fuzzy_launcher_i_use
|
|
|
|
|
2024-09-11 23:12:15 +00:00
|
|
|
About 2 years ago, I decided to write [my own launcher](https://git.knazarov.com/knazarov/q.sh).
|
2023-08-21 23:02:58 +00:00
|
|
|
It's been originally for [Yabai](https://github.com/koekeishiya/yabai)
|
|
|
|
WM, which is a tiling WM for the mac. I wrote it because at the time there were no satisfactory replacements to dmenu/rofi
|
|
|
|
that suited my personal needs. Right now I use it with Linux, because it's fully portable.
|
|
|
|
|
|
|
|
Since I was short on time, I decided to not write my own GUI. Instead, I was starting a terminal in the middle of the screen
|
|
|
|
without window decorations, which started my launcher instead of bash.
|
|
|
|
|
|
|
|
For the launcher, I decided to pick fzf, which already has great fuzzy search-and-complete. It turned out eventually that
|
|
|
|
fzf can not only filter stdin and run a command, but can also run a script that would interactively receive an updated
|
|
|
|
line that the user is typing.
|
|
|
|
|
|
|
|
Using `change:reload-sync:`, you can make fzf run any external program that can essentially produce auto-completions for
|
|
|
|
the line the user is typing. So, using it you can implement prefix commands. In my case, if I type an equal sign and then
|
|
|
|
press space, the shell script underneath will switch into an expression evaluation mode (pipe the rest of the command to
|
|
|
|
"bc" and print the result). As the user edits the expression, the output will be updated as well.
|
|
|
|
|
|
|
|
And as a final addition, depending on the prefix command the action taken when the user presses "enter" will be different.
|
|
|
|
For passwords, I use the "pass" tool and the action would be to copy the password to the clipboard. For bookmarks, the
|
|
|
|
action would be to open them in the browser.
|
|
|
|
|
|
|
|
To be fair, some other people have come to roughly the same idea.
|
|
|
|
See [sway-launcher-desktop](https://github.com/Biont/sway-launcher-desktop) for example. I just don't think that other people
|
|
|
|
went as far as to add prefix commands and extensibility.
|
|
|
|
|
2024-09-11 23:12:15 +00:00
|
|
|
If you want to read through the code, you can find it [here](https://git.knazarov.com/knazarov/q.sh).
|