As if screen wasn’t cool enough to start with, here’s a little bonus to make your day a wee bit brighter: There’s an
-x flag for screen, which the man page and screen’s own
--help tips suggest you can use to attach to a screen session that’s not detached. “Multi-user mode,” is what is added in parenthesis.
It sounds trivial, but at the same time suggests an impending train wreck. The idea of more than one person using a screen session brings to mind words like “race condition” and “wheel war.” And besides, there’s only one keyboard on most computers, so who’s going to want to huddle up next to their friend, and play two sessions of Stone Soup at the same time?
Yes, in the conventional “one keyboard one user” sense, it doesn’t sound like fun. But try it this way: Get to machines networked, and allow one to access the other with something like ssh. This is the setup I usually have for a music system, which sits on the other side of the house next to the router, and connected to the stereo. See here.
Now start up screen on the host machine, and keep it running in an open terminal. Then connect remotely and attach to the same screen session with the
-x flag. Chances are if you’re in a position to watch both the original session and the remote session at the same time, you can do cool things and both screens will update together.
Which is fun for all of about six seconds. “Okay, K.Mandla,” you’re thinking. “Where’s the punch line?”
Well, you’re looking at it. Now you can run a remote session of screen from one computer and control it from afar, without needing an additional session. Think about that for a second or two, and the utility becomes obvious. One machine in the other room, playing music or seeding torrents, with screen running in tty1. Another machine accesses over a network and controls the same screen session at the same time, from another computer completely. One program, two interfaces.
Furthermore, screen is smart enough to allow its finer features — like screen blanking and window controls — to be used or take effect depending on the access point. So the screensaver for your remote session will kick in when its timeout is reached, and the host tty will start the blankerprg when its idle is complete.
And changing windows or drawing up split arrangements doesn’t mean both access points have to change together. Yes, you’ll see the cursor move independently if both are watching Midnight Commander, but one or both of them can move away from mc and screen will allow both to do their thing.
The only time this becomes a little frustrating is when one screen has different dimensions or has drawn up the window to fit a certain size. In that case, you might see dashed lines showing where screen’s output ends, depending on the size of the window. Which user sees the natural dimension and which one sees the dotted lines is a matter of first come, first served.
screen has a lot of little tweaks and gimmicks scattered here and there in its depths, and its worth breezing through the man pages once in a while to see if one of them can be held up to a different light, and made to do something new. In the mean time, try
:nethack on and keep an eye on screen’s message line. :mrgreen: