 Late in 2021, Xmonad released a new major version, 0.17, and 0.17 had a ton of new features built into Xmonad and the Xmonad-Contrib package. But Xmonad and Xmonad-Contrib didn't actually move to 0.17 inside Arch Linux until just a few weeks ago, so I'm still kind of new to discovering some of the cool modules that are available in the new version of Xmonad and Xmonad-Contrib. And one of the neat modules that's built into the latest version of Xmonad is the window swallowing feature. What is window swallowing? It is when you launch something from the terminal. The terminal goes away. It gets hidden. It gets swallowed by whatever new processes spawned until you kill that process and then your terminal comes back. Let me show you what I mean by window swallowing. So if I open a terminal and let me cd into a directory that's got some images and I'm going to launch an image inside fe, feh. This is an image viewer and if I open this image in this image viewer, you can see that the terminal is still open. I can't do anything in this terminal. It's a dead window because I launched this new process feh. I can't close the terminal. I can't do anything with the terminal. I can close the terminal, but if I close the terminal, feh gets killed as well because it's linked to the terminal. So what window swallowing will allow me to do is from now on when I launch something from the terminal, the terminal actually gets hidden and all I would see in this case would be the image viewer. I wouldn't have that dead terminal window taking up space on my screen. And adding this window swallowing feature to Xmonad is dead simple. I was actually reading the documentation for this and what you want to do is you want to import Xmonad.hooks.windows swallowing and then after you import this module, all you need to do is find your handle event hook and in that add this line right here. They give you the exact line to paste into your config and all it is is you add swallow event hook to your handle event hook and then inside parentheses, you're going to give it some class name. So these are what terminals do you want to be affected by the swallow event hook because it needs a proper class name. So if you use multiple terminals, you may have to do several of these class names here and then at the end inside parentheses, you want return true. So let me show you how this looks in my config. Let me get back to my desktop and let me open my Xmonad config and zoom in a little bit. So let me find the imports. So in the imports, all I need to do is I need to import Xmonad.hooks.windows swallowing and now let me go down toward the bottom of the document. So toward the end, I have the main block, this main do block here. And actually in my config, I actually didn't even use a handle event hook. I guess I was just using whatever the handle event hook is by default, like the default of settings for Xmonad because I actually didn't even have one in my config. But now I have added one. Let me turn off truncated lines here inside do me max because we couldn't see the entire line. But you can see handle event hook equals swallow event hook and then class name. So I have three terminals that I often use here on my system. So first one is class name equals alacrity with a capital A. And then this funny looking thing here is actually a less than sign, a pipe symbol, then another pipe symbol, then a greater than sign. But inside Emax, you have ligatures. So I get this fancy diagram, basically the representation of what this symbol actually is. It is actually this here if I'm looking at the browser. And this is just a separator for the next class name equals st-256 color for the st terminal, suckless is simple terminal. And then I also have this another separator and then class name X term and X term is capital X capital T term. And how did I get this? Well, let me run X term. So I'm going to launch X term. And there is a X utility called X prop for X window property. If I do X prop, my cursor turns into X. And the first window that I click on it will give me the properties for that window. So I'm going to click on this X term window. Let me make it full screen. And the text is all jumbled up. Let me try that again. It's up this time. Do it on a full screen window. There we go. And look for the line that starts with window manager class because that is what we need. We need the window class name. You've got two values here. I use the second value. You can see X T term, right? Capital X capital T term. So that is how I get the names for the terminals. So when I run X prop on a Lackardy, it's a Lackardy with a capital A. When I do X prop on the st terminal, it's st-256 color. So if you're struggling with getting the correct class name, just use the X prop command for that. And then once I add these two simple lines, let me do a colon W to write and let me tangle the file. And now let me restart Xmonad. And it restarts just fine. No error. So now let me go to a new workspace. I'm going to launch my Lackardy terminal here. And now let me zoom in just a little bit. I'm going to rerun what I did previously. So let's CD into this wallpapers directory where I have some images. And now when I run FEH on one of these images, so I'm going to view this in the FEH image viewer. Watch what happens to my terminal. It goes away, right? It's hidden. So all I have is the image viewer. And now if I hit Q and FEH to quit out of it, my terminal comes back. How cool is that? If I CD back into the home directory and then CD into videos, let me ls. I'm going to see if I can play one of my videos in MPV. So I'm going to CD into this directory here. And now I'm going to run MPV on one of these MP4 files. And MPV starts playing. Let me quit out of MPV. But you saw that the terminal went away. Now is the window swallowing inside Xmonad perfect? No. And they're upfront about this. If I actually go back to the browser at the top of the page about Xmonad hooks window swallowing, there is a note here. It reads, because the window swallowing needs to check the process hierarchy, it requires both the child and the parent to be distinct processes. And if they're not, I guess the window swallowing feature doesn't work. It mentions that many programs, the window swallowing probably won't work, especially some of the bigger complicated programs like web browsers. It actually is upfront about web browsers. And specifically, I have had people tell me that Firefox does not work with window swallowing. But oddly enough, when I go back to my desktop here, let me get back into the terminal here. If I launch Firefox from the terminal, yeah, I mean it swallows Firefox, just find the terminal goes away. Firefox is here. If I kill Firefox, the terminal comes back. So at least for web browsers, Firefox works. Now Brave does not work. You can see it actually does not swallow. And it takes me to the second workspace because I have that as a rule as well. A cute browser does work just fine with the swallowing effect. Let me quit out of cute browser. And let's check LibreWolf being based on Firefox. Since Firefox worked, I would expect LibreWolf to work. And it does. Let me kill LibreWolf. The terminal comes back just fine. I also have, I believe, Nyxt and Sold, the Nyxt browser. It swallows just fine. So all these browsers seem to work except for Brave with the swallowing. Most image viewers, your video player, MPV, all of that stuff seems to work. The one image viewer that does not work, which is unfortunate because it's the one I actually prefer is SXIV. If I launch the SXIV image viewer here on this particular image, you can see I get the image viewer, but it does not get swallowed by the terminal. And that is rather unfortunate. But overall, it works pretty well. I'm pretty happy with the Windows swallowing here inside Xmodad. I've already added it to my config, and I've pushed my latest config to my .files repository. I will eventually incorporate the Windows swallowing inside the Xmodad config for DTOS, although I haven't done that yet. But look for that coming in the next few days. Now, before I go, I need to thank a few special people. I need to thank the producers of this episode. Dustin Gabe James Matt, Maxim, Mehmet Michael Mitchell, Paul West, Wyatt Baldwin, Homie Allen, Armour Dragon, Chuck Commander, Rengarie Diokai, Dylan Gregg, Marsdrom, Erion, Alexander, Paul, Peace, Archon, Fedor, Polytech, Realities 4 Less, Red Prophet, Stephen Tools, Devler, and Willie. These guys, they're my highest-tiered patrons over on Patreon. Without these guys, this episode about Windows swallowing would not have been possible. The show is also brought to you by each and every one of these fine ladies and gentlemen. All these names you're seeing on the screen right now, and these are all my supporters over on Patreon because I don't have any corporate sponsors. I'm sponsored by you guys, the community. If you like my work, want to see more videos about Linux free and open source software such as Xmonead, subscribe to DistroTube over on Patreon. Peace, guys. Windows that don't swallow are bloat.