Run multiple consoles at once with this open source window environment

Simulate the old-school DESQview experience with twin in the fourteenth in our series on 20 ways to be more productive with open source in 2020.
103 readers like this.
Digital creative of a browser on the internet

Last year, I brought you 19 days of new (to you) productivity tools for 2019. This year, I'm taking a different approach: building an environment that will allow you to be more productive in the new year, using tools you may or may not already be using.

Overcome "one screen, one app" limits with twin

Who remembers DESQview? It allowed for things in DOS we take for granted now in Windows, Linux, and MacOS—namely the ability to run and have multiple programs running onscreen at once. In my early days running a dial-up BBS, DESQview was a necessity—it enabled me to have the BBS running in the background while doing other things in the foreground. For example, I could be working on new features or setting up new external programs while someone was dialed in without impacting their experience. Later, in my early days in support, I could have my work email (DaVinci email on MHS), the support ticket system, and other DOS programs running all at once. It was amazing!

twin

Running multiple console applications has come a long way since then. But applications like tmux and Screen still follow the "one screen, one app" kind of display. OK, yes, tmux has screen splitting and panes, but not like DESQview, with the ability to "float" windows over others, and I, for one, miss that.

Enter twin, the text-mode window environment. This relatively young project is, in my opinion, a spiritual successor to DESQview. It supports console and graphical environments, as well as the ability to detach from and reattach to sessions. It's not as easy to set up as some things, but it will run on most modern operating systems.

Twin is installed from source (for now). But first, you need to install the required development libraries. The library names will vary by operating system. The following example shows it for my Ubuntu 19.10 installation. Once the libraries are installed, check out the twin source from Git and run ./configure and make, which should auto-detect everything and build twin:

sudo apt install libx11-dev libxpm-dev libncurses-dev zlib1g-dev libgpm-dev
git clone git@github.com:cosmos72/twin.git
cd twin
./configure
make
sudo make install

Note: If you are compiling this on MacOS or BSD, you will need to comment out #define socklen_t int in the files include/Tw/autoconf.h and include/twautoconf.h before running make. This should be addressed by twin issue number 57.

twin text mode

Invoking twin for the first time can be a bit of a challenge. You need to tell it what kind of display it is using with the --hw parameter. For example, to launch a text-mode version of twin, you would enter twin --hw=tty,TERM=linux. The TERM variable specifies an override to the current terminal variable in your shell. To launch a graphical version, run twin --hw=X@$DISPLAY. On Linux, twin mostly "just works," and on MacOS, it mostly only works in terminals.

The real fun comes with the ability to attach to running sessions with the twattach and twdisplay commands. They allow you to attach to a running twin session somewhere else. For example, on my Mac, I can run the following command to connect to the twin session running on my demo box:

twdisplay --twin@20days2020.local:0 --hw=tty,TERM=linux

remote twin session

With some extra work, you can also use it as a login shell in place of getty on consoles. This requires the gdm mouse daemon, the twdm application (included), and a little extra configuration. On systems that use systemd, start by installing and enabling gdm (if it isn't already installed). Then use systemctl to create an override for a console (I used tty6). The commands must be run as the root user; on Ubuntu, they look something like this:

apt install gdm
systemctl enable gdm
systemctl start gdm
systemctl edit getty@tty6

The systemctl edit getty@tty6 command will open an empty file named override.conf. This defines systemd service settings to override the default for console 6. Update the contents to:

[service]
ExecStart=
ExecStart=-/usr/local/sbin/twdm --hw=tty@/dev/tty6,TERM=linux
StandardInput=tty
StandardOutput=tty

Now, reload systemd and restart tty6 to get a twin login prompt:

systemctl daemon-reload
systemctl restart getty@tty6

twin

This will launch a twin session for the user who logs in. I do not recommend this for a multi-user system, but it is pretty cool for a personal desktop. And, by using twattach and twdisplay, you can access that session from the local GUI or remote desktops.

I think twin is pretty darn cool. It has some rough edges, but the basic functionality is there, and it has some pretty good documentation. Also, it scratches the itch I have for a DESQview-like experience on modern operating systems. I look forward to improvements over time, and I hope you like it as much as I do.

What to read next
Tags
User profile image.
Kevin Sonney is a technology professional, media producer, and podcaster. A Linux Sysadmin and Open Source advocate, Kevin has over 25 years in the IT industry, with over 15 years in Open Source. He currently works as an SRE at elastic.

5 Comments

Wow! This is great. Your articles have been amazing. Everyday you’ve got me looking at something new.

Thanks for your article! I'm looking into moving my desktop environment to CLI, to be able to control my machine remotely with the same level of comfort a full DE offers.

I'm already comfortable in tmux, I've switched to mpd and nncmpp for music, lazygit... I don't even need to connect via VNC anymore. ^_^

Is there any advantage to using twin over say... Screen/tmux in a floating / tiling window manager such as i3 or bspwm ?

This is quite awesome, but for some reason, arrow keys doesn't seem to work. I will figure it out, but using nvlc is a real pain without arrow keys

I found a way, by using the Execute on the menu and running the app with the tick "run in a terminal"

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.