27th of July, 2022 · In Technical · Tagged with suckless, dmenu
Dmenu Images Patch
I recently posted about a minimal script I have been using to watch youtube videos without using a web browser. This involves several suckless utilities, but one of the most critical is dmenu. I found myself occasionally gravitating back to using the browser because I couldn’t render the video thumbnails inside of dmenu. To fix this problem I patched in some of the image rendering capabilities in suckless sent into dmenu in order to render the thumbnails into the video selection menu. It works pretty well!
I have the patch for vanilla dmenu 5.0 available. Let me explain a bit about how to use it. Typically with dmenu you pipe in a return separated list of items from standard input. The patched version is the same, but if in a given items input it sees a tag like `@image.png` it will look for `image.png` in the current working directory and if it finds it will render it to the screen in place of the placeholder prefixed by the @ symbol.
You can filter / select as usual and the line will be written to standard output.
In the suckless-yt script I use this by downloading all the thumbnails to a temporary directy and then rendering them into the menu. I then use `awk` to pull out just the id from the resulting selection and play the video.
In that script the menu looks like:
All in all this works pretty well. I will probably work on it / try to use it as the main youtube consumption interface for now for a while before submitting the patch to suckless.
If you give it a whirl buyer be warned that the error handling is not perfect yet, and it works better in `-l` column mode than in row mode.