Essentially, I'm looking for a way to keep one terminal open running tmux, and open new windows inside of the session rather than spawning new terminals.
On pushing a key sequence, I'd like to open a new terminal if there isn't one open. But if there is one open already, I'd like to switch to its desktop if necessary and focus the window, then send the command.
I found the documentation for the
If action for windows and I was hoping there was a similar construct for global actions as well, but I'm not seeing it.
I ended up using a simplified version of jw013's script.
The original script was written for a quake terminal effect, but what I wanted was simpler: not to toggle a terminal, but simply to always open a window in a single tmux terminal session. The key component which I was missing was
wmctrl, which I hadn't heard of.
Using jw013's script as a base, I simplified to:
# the variable name for the window (used in openbox rc.xml for the rule as well) wmclass=tmux_terminal # if we successfully focus the window then open a new tmux window inside if wmctrl -a $wmclass -x; then tmux new-window # otherwise the window hasn't been opened. open it and attach to tmux. else urxvt -name $wmclass -e tmux attach & fi
I then bound this to
W-space in openbox, and set up an application for
name=tmux_terminal to open maximized on the 1st desktop. Now if the terminal is not opened,
W-space will open it and attach to tmux, else, it will simply switch to the existing tmux session window and open a new window inside of it.