More screen coolness: The -x flag

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:

About these ads

4 Responses to “More screen coolness: The -x flag”


  1. 1 Brett Dreher 2010/06/12 at 9:42 PM

    Always been a fan of the -x flag for holding a session and still working within it, it’s been rather shocking to me that *still* no graphical window manager can even come close to the flexibility of screen in terms of attachment/detachment and sharing. I’ve seen many attempts to hack at X for similar functionality but without the whole package it just seems niche.

  2. 2 x33a 2010/06/15 at 10:18 AM

    I use it all the time with xmonad on my arch machine.

    What i basically do is, start a screen session on one workspace and then if i have to open a terminal on another workspace i simply use screen -x. this way, all my running programs are available to me on any workspace i want.


  1. 1 GoblinX Project » GoblinX Newsletter, Issue 253 (06/13/2010) Trackback on 2010/06/13 at 10:28 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,963,830 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: