[ Monoterm ] - Sat 18 April 2020

Do you have trouble with keeping too many terminals open?

Have you tried tmux, but can't keep attaching and detaching from sessions efficiently?

After struggling with these issues, I've written a script to be bound to a keymap in Openbox (or whatever window manager you prefer) that automatically finds the terminal with a managed tmux session and focus or unfocus/hide it.

If the script doesn't find a running session, it creates a new one with tmux windows corresponding to your virtual desktops. This is where the important stuff happens.

On my setup, I have 4 openbox desktops called zsh, web1, web2, and code. The script will get those names using wmctrl -l and create tmux windows with corresponding names.

A second script, called tmux_update_focus.sh will automatically update the focused tmux session as you switch desktops. Notice how tmux changes to the corresponding window as you switch virtual desktops.

So, ideally, you have this window open and on all desktops, and as you switch around your virtual desktops, tmux will update itself too.

The code can be found on Github. Make sure to include the relevant openbox lines to run tmux_update_focus.sh whenever a desktop switch happens.