Using Mrxvt with Dtach

Roger  roger<at>eskimo.com
http://www.eskimo.com/~roger/programming/mrxvtanddtach.html
2006.09.16

This document will instruct how to setup Mrxvt using Dtach to manage each tabbed session.

Contents


Introduction

Dtach Install and Setup

Mrxvt Install and Setup


Running Mrxvt with Dtach

Troubleshooting

Screenshot

Introduction

What is Mrxvt and Dtach?  Mrxvt is a branch of code from the Rxvt Terminal project integrating the tabbed feature into the terminal as well as other features.  Dtach is similar to the "GNU Screen" project but tiny and easy!  With these two features, a user can have tabbed detached sessions.  (This is very similar to the feature Eterm is hard coded using GNU Screen!)

The pros of using Mrxvt with Dtach over Eterm's implementation of GNU Screen are:
If you don't know what GNU Screen or Dtach is, the big plus with using detached terminals, if you're compiling code and your terminal segfaults on you, whatever you were doing in your terminal, is still working in a background process separate of you terminal.  In theory, restarting your terminal and reattaching to the previous session should redisplay your current compile still performing or Irssi session without interruption!

Don't get me wrong.  I've used Eterm with GNU Screen for the past years and life would have been extremely difficult rebuilding my Gentoo boxes without it.  But there are allot of features of GNU Screen the basic shell user just isn't going to use.  For the time being, I'm giving Mrxvt & Dtach a whirl.

One issue with Dtach, Dtach does not redraw the screen as GNU Screen would.  This is one of the first things mentioned on the Dtach homepage.

Dtach Install and Setup

Dtach setup is quite easy.  Emerge or install Dtach according to your distribution's package install procedures.

Using Gentoo:

# emerge dtach

Mrxvt Install and Setup

Emerge or install Mrxvt according to your distribution's package install procedures.

Using Gentoo:

# emerge mrxvt

To setup a Mrxvt Terminal, the user either needs a
~/.mrxvtrc file or needs to specify all their configurations via command line switches.  To simplify this process, you can copy and modify my ~/.mrxvtrc file into your own $HOME folder.

Running Mrxvt with Dtach

$ mrxvt -name default &

The above command line starts a Mrxvt terminal with a default profile and is best placed within either your
~/.xprofile, ~/.e16/Init/sessions.sh or other window manager startup file.

The "-name default" starts a Mrxvt with a group of tabs specified by the default profile listed within the ~/.mrxvtrc file.  The "default" profile will also execute dtach within each tabbed shell - specifying a unique socket file to attach and reattach to as needed.  (Mrxvt's tabbed profiles was one of the more difficult features to configure.  Configuring eye-candy features was, at most, trivial.)

The idea is, if your window manager segfaults, on restart of X or  your window manager will result in your terminals being reattached.  (If you're compiling Openoffice or other package, your compile should still be performing independentaly in a detached process apart of your window manager or other graphical terminal interface and the compile should simply reappear in your terminal on restart using the above mrxvtrc and command line flags.)


*Be aware of Dtach trying to use old or stale socket files!  See Troubleshooting to ensure after a reboot, you're starting Mrxvt with clean Dtach sockets.

Troubleshooting

At times, you may find Dtach not cleaning-up it's old socket files or not able to create a new one for some reason.  This may happen if your Dtach session encounters an unexpected segfault or your computer reboots unexpectedly.  A way I work around this, before starting Mrxvt, I'll remove any old or stale Dtach socket files with the following:

$ rm -f /tmp/dtach.roger-* && DISPLAY=":0.0"  mrxvt -name default &

Again, the above goes into my window manager's start up file.  ie. ~/.e16/Init/session.sh

However, this defeats the purpose when X crashes.  From the dtach man file, "-A" should recognize a stale socket file and just create a new one.  I'm sure this is basically a bug bound to be fixed in future versions.

Screenshot

This screenshot isn't going show-off the features or benefits of Dtach as the features of Dtach are transparent and only seen on detach of a session or segfault.  This will, however, give you a good idea of the look & feel of the ~/.mrxvtrc file.  (For transparency, I have Xorg's Composite module performing all transparency operations for all applications using Xorg.)


Mrxvt using Dtach and Irssi