mew - a dynamic menu for Wayland
Mew is a dynamic menu for Wayland, which is also 99% compatible with dmenu. I will talk about how I use it in this blog post.
mew is a simple menu for Wayland, It manages large numbers of user-defined menu items efficiently. It runs as fast as the now-unmaintained tofi and is way smaller in terms of lines of code compared to the most popular dmenu “clone” (it’s not really a clone of dmenu), bemenu. In addition, it is nearly one-to-one compatible with any dmenu script with the exception of two options.
Installing and setting up mew
mew is configured much like suckless applications, where you have to edit a config.h
file and recompile the program to change something.
Installation
First of all, install the required dependencies listed in the repo’s README. Then, run these commands:
1git clone https://codeberg.org/sewn/mew.git
2make
Configuration
As mentioned earlier, you will have to edit config.h
and recompile in order to make changes. Here is my configuration:
1/* See LICENSE file for copyright and license details. */
2/* Default settings; can be overriden by command line. */
3
4static int top = 1; /* -b option; if 0, appear at bottom */
5static const char *fonts[] = { "monospace:size=10" }; /* -f option overrides fonts[0] */
6static const char *prompt = NULL; /* -p option; prompt to the left of input field */
7static uint32_t colors[][2] = {
8 /* fg bg */
9 [SchemeNorm] = { 0xcdd6f4ff, 0x1e1e2eff },
10 [SchemeSel] = { 0x1e1e2eff, 0x89b4faff },
11 [SchemeOut] = { 0x000000ff, 0x89b4faff },
12};
13
14/* -m option; if provided, use that output instead of default output */
15static const char *output_name = NULL;
16
17/* -l option; if nonzero, use vertical list with given number of lines */
18static unsigned int lines = 0;
19
20/*
21 * Characters not considered part of a word while deleting words
22 * for example: " /?\"&[]"
23 */
24static const char worddelimiters[] = " ";
As you can see from the colors array, I have riced mew to fit the catppuccin colorscheme, my favourite colorscheme! :3
In addition, if you wish to use mew for passwords, I recommend you install this patch to add a password mode and pinentry program. However, since I don’t use this, I can’t comment much about it at all.
Usage
Running desktop files (drun mode!)
I use j4-dmenu-desktop to find desktop files and pipe them into mew for execution. It’s quite fast and uncomplicated. I don’t use the mew-run
script included in the mew repo because I don’t like running binaries because of the inability to run flatpaks. I just have a small script to handle it:
1j4-dmenu-desktop --dmenu="mew -i -p drun: "$@""
menu patch for dwl
I use a patch for dwl called menu. This patch adds a menu command, which allows dwl to interface with dmenu-like programs such as mew! However, you will have to change it from wmenu (ew) to mew. (yay!)
1static const Menu menus[] = {
2 /* command feed function action function */
3 { "mew -i -l 5 -p Windows", menuwinfeed, menuwinaction },
4 { "mew -i -p Layouts", menulayoutfeed, menulayoutaction },
5};
If you want a guide on how to patch dwl, I have a blog post from a few months ago teaching you how to do so.
***WARNING!***If you use the bar patch, even if the menu patch applies perfectly (which it did for me), it will still error out when compiling. This is due to the bar patch changing
printstatus()
withdrawbars()
. So you will have to manually replaceprintstatus()
withdrawbars()
for compilation to work.
In order to use this patch, press alt+o
. This will open a mew window with all your toplevels (Wayland lingo for windows) and you can select and confirm your choice. This will switch focus to the selected window, even if it is in a different window. This is really useful when I’m working on stuff with a lot of windows in multiple tags, as I can easily just go to the windows I want without rotating through all of them manually.
Pressing alt+shift+o
will open up a mew window with all of your installed layouts. I don’t use this at all because I can tell which layout I am on pretty easily, as I only have the default 3 installed.
scripting
mew can be used in scripts, just like dmenu. Normally I would recommend just substituting dmenu with mew in all your existing scripts, but if you do this you will need to ensure that your script does not have the -m or -f options when calling mew, as mew does not have does options. -m is actually implemented as -o because X11 output names are different from Wayland and can’t be compatible.
Anyways, I have actually made a repository for a bunch of scripts that I use, called mew-scripts. This is forked from Distrotube’s dmscripts, and a lot of work has to be put in before a proper release can be done. You can check out the repo here: https://codeberg.org/yuki-was-taken/mew-scripts
Things that need to be done:
- Port all the scripts over to Wayland. (I don’t use a lot of them so I didn’t port them over when making the repo, so this needs to be done soon.)
- Rebrand from dmscripts to mew-scripts.
- Make new scripts. (I have an idea for a rss script.)
mew-scripts has a config file which needs to be located in ~/.config/dmscripts/config
(location will be changed later on to mew-scripts) and it’s pretty simple to understand. Change the options to the programs that you use, and you’ll be all set to use mew-scripts after installing it.
WARNING! mew-scripts will not work unless you run
make install
in the repo with whatever privilege escalation program you userun0/doas/sudo/rootdo
.
There are 8 different scripts available right now in the repo:
- dm-hub: A script which shows a list of all the available scripts and lets you select and run one of them. I have this bound on dwl to
alt+i
to launch all the other scripts. - dm-confedit: A script which shows all the files in your
~/.config/
directory, and when I say all, I mean all, even the git files. However, in the default config I have set it so dm-confedit ignores all files in .git folders to prevent clutter. When you select a file it will open said file in the foot terminal emulator and the neovim text editor by default. You can change this in the configuration file. - dm-logout: A menu to logout/poweroff/reboot/suspend. It only works on OpenRC for now, but I do plan on changing that. It also depends on wlock for screen locking and a notification daemon that uses
notify-send
. - dm-man: A script to search for a manpage or get a random one. It depends on the
less
pager for now, but I might change it so that it uses the program specified in the$PAGER
variable. It also depends onman-db
for some of the man page operations. - dm-radio: You can listen to the radio with this! It depends on yt-dlp and mpv, as well as a notification daemon that supports using
notify-send
. All of the station should work. If you want to add one or change one, send a pull request! - dm-setbg: Sets the background or chooses a random one. Once you select choose a wallpaper, imv will open up with an image. Just press P to accept it and change your wallpaper. ATTENTION: I plan to change this script soon, as I don’t really like the way it works as it hard-depends on wbg or xwallpaper, and imv for the image viewer.
- dm-weather: A simple script that just curls
wttr.in
for the weather info once you specify a location and pipes it into yad. You can set some preset locations in the config file, and choose them in mew. Depends on curl and yad. - dm-websearch: Search the internet! It will open the search query in the browser specified in the config file. You can also specify the search engines in the config file.
Conclusion
mew is a really cool program made by a very cool person!!! There are a lot of ways you can use it and I prefer it over most other menus that exist in the Wayland space. So, yeah! Go check out mew-scripts. I’m going to make a few changes to it in the coming few days. (It’s my school break right now.)
Thanks to sewn, the creator of mew for correcting the part about mew not having the -m option.
insert mewing brainrot meme :3