by Rares Aioanei
IntroductionAs the title might suggest, this article will show you how to run X applications without using a window manager or desktop environment. You might ask yourself : why would I want to do that? Well, you might want to run a kiosk system where you only need to run the browser and/or the hardware resources are limited. Or you simply use only one/a few X applications and spend the rest of the time in a terminal so you don't need the overhead of a window manager. Or, last but not least, because it's an interesting experiment, akin to the one where you have to spend X days exclusively in a terminal. Also, it's fun! So let's get started.
Making sure we have all we needWhat you need is pretty simple : a minimal Linux distribution or a similar Unix-like OS with the desired X applications installed and Xorg. In RHEL-based distributions installing Xorg is accomplished by doing
$ sudo yum install xorg-x11*while in Debian-based operating systems this is done with
$ sudo apt-get install xorgPlease ensure that you also have your X-related applications installed before we get started and you're good to go. As a side note, I will use Firefox as an example because this is how my idea for this article came into being : I have a Pentium 4 machine running Debian and I needed Firefox on it so I wanted to see how to use as little CPU/RAM as possible.
Let's go!You will need a terminal (we don't have X, remember?) for every X application we want to run. This can be solved by running a terminal multiplexer, like tmux or dvtm. A good side effect of this is that, if your app is misbehaving you can see what the problem is by scrolling up in the terminal the app was started from. Now, let's get to it.
There are two ways you can do this, you can either run the X application in the same virtual terminal you're typing the command on without using elevated privileges, or if you want another VT, you will need sudo or su, because you will ask the operating system to open a new TTY, and that requires administrator privileges.
So, the same-terminal way looks like this :
$ xinit firefox $* -- :0 vt$XDG_VTNRThe part after :0 is exactly used to avoid /dev/tty0 permissions issues. The other way, which requires elevated privileges, looks like this:
$ sudo xinit firefox $* -- :1and will start X and Firefox inside it using /dev/tty1. For both commands we assume you're using /dev/tty0 AKA the first virtual console, accessible with Ctrl + Alt + F1.