awesome-yuki!

mew - a dynamic menu for Wayland

· yuki

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: "$@""

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() with drawbars(). So you will have to manually replace printstatus() with drawbars() 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:

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 use run0/doas/sudo/rootdo.

There are 8 different scripts available right now in the repo:

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

#linux #software #wayland

Reply to this post by email ↪