Small Changes Big Improvement

Window Swallowing

I added a couple new features to my system that make development just a little nicer. First was a feature for dwm called swallowing windows. This one feels like the sort of thing you don’t know you want until you have it then you can’t think of living without. Dwm being a tiling window manager it manages the positions of windows automatically and when new ones are spawned it makes room for it on the screen. I use a lot of programs spawned from a terminal for example zathura for viewing pdfs and sxiv for viewing images. Both of these I don’t spawn with dmenu because I want to pass them the file(s) to open and with sxiv sometimes additional arguments. What happens without window swallowing is something like this:

cal

The window on the left is the one that spawns the program and waits for that other program to exit. It just sort of sits there taking up space, you can kill the program with Ctrl-c like you would any other terminal process. By adding window swallowing that terminal is basically hidden while the program it spawned is active. When that program is exited the terminal comes back. I can’t believe I never had this before, it just makes so much sense. I also think this would be useful if you use a floating window manager because even though the windows stack on top of each other and it may just get shuffled behind some other windows it’d be nice if it just got swallowed.

ST features

I’ve been using suckless' terminal emulator st for a while but I honestly only started using it because I was really liking dwm. Up till now I hadn’t really cared that much for it because I added 4 different patches just to get scrollback to work and it’s still a little weird having to hold shift to scroll. I got over it after getting that working, that’s probably the only ‘feature’ I use (although I don’t think this should count as an extra feature, it should be built in). I was browsing the st patches and stumbled on one called st-workingdir after reading it I decided to install it and give it a try. This goes with the window swallowing: I wouldn’t want to be without it. All it does is when you have an instance of st open say in ‘~/code/project’ if you open another instance of st the directory it is in is ‘~/code/project’. It seems like a really minor thing but it makes development so much easier when you use terminals for just about everything. This patch works because the window title for st is the directory: cal So it grabs the window title and finds the directory located in it and makes st start with that working directory. I had to modify my vim config a little to show the path of the current file, it used to only show “nvim” but with one line added to the vim config file (yes it’s neovim):

set titlestring=nvim\ %F
cal

This makes development awesome. If I’m working in vim on a bit of code I can spawn a new terminal in the right directory to commit with one keypress. Or maybe I’m working with a project that has a docker container I can spawn a new terminal and standup the container quicker. I don’t have to worry about spawning a terminal and keeping it around just so I don’t have to change the directory every time I need a terminal in the same spot as where I’m working.

Tags: tech

Posted on: 2021-06-18, last edited on: 2021-06-18, written by: Joshua Osenbaugh