Main > Linux

Linux GUI/Xorg without a window manager, and autologon

(1/3) > >>

elvis:
I keep seeing posts on here where people talk about using LXDE/Lubuntu or XFCE/Xubuntu to try and build a speedy MAME cab and keep memory down.  It's prompted me to share how I build my Linux MAME cabinets (6 cabs and counting, spread across Slackware, Debian and Ubuntu).  I'm a long time Linux user for home and work (getting on 17 years now), and it's great to see so many folks turning to Linux these days for specific tasks like cab building.

If all you're running on a MAME system is a frontend and emulators (like most cabinets do), you don't need a window manager at all.  Window managers are there simply to aid with graphical tools and allow you to position/resize windows easily, load themes and eye candy, etc.  For a full screen frontend, you're just throwing away system memory.  While probably not an issue for more powerful systems, I like the challenge of seeing what's the oldest hardware I can find to knock together yet another MAME cabinet, and that often means running configurations with just 256-512MB.

You don't need any particular window manager installed to run matching libraries and applications.  You can easily run GTK applications out of KDE, and vice versa Qt applications out of GNOME or Unity.  You can run anything you like even without a window manager, as long as the relevant libraries are installed. 

I use Xorg in all of my current cabinets (still the current graphical subsystem on most popular distros - the bit that sits "underneath" GNOME/KDE/Unity/LXDE/XFCE/etc), and most of this guide works on older XFree86 setups too.  I don't use direct frame buffer modes or Mir craziness, so that's all out of scope.

Here's how to do it:

1)
Disable any sort of graphical login manager from running at startup.  Ubuntu uses LightDM these days.  You might be using GDM with GNOME or other GTK setups, KDM for KDE, etc.  Either disable the service via your distro's preferred method, or simply uninstall the relevant package (avoid that if you want to log in to the GUI as a different user at some point).  I'll leave disabling of services as "homework". :)

2)
For the user you want to auto-login on boot (for me, it's always the user "mame"), go to that user's home directory.  In that home directory, edit/create a file called ".xinitrc".  Note the dot at the front of the filename - this convention means it's a configuration file.  In this case, it's the rc (Runtime Configuration) for XInit (the X Initialisation program).  In here, you put the full path to the file you want to run when X starts.

This can be a program directly.  For example, it could contain something like:

--- Code: ---/usr/local/bin/wahcade --full-screen --no-gstreamer --no-pygame
--- End code ---

Or it could point to a shell script you've written with a bit more complexity in it. 

What this does is execute that particular thing when X starts.  When it's all complete, X will die and send you back to the command line.  If you want to run several tasks, you can background them with the & character (say, background music, or some power management or screensaver application, etc).  For example:


--- Code: ---/path/to/music/player some_nice_music.mp3 &
/usr/local/bin/wahcade --full-screen --no-gstreamer --no-pygame

--- End code ---

You can test this at any time, by logging in to the command line as the user, and typing "startx".  You should see nothing but your chosen program launch, as if you'd launched it from within the GUI.

3)
Now to make it happen at startup.  There's a million ways to achieve this.  My method is pretty brute-force, but it works.

First, edit /etc/X11/Xwrapper.config (I believe this is Debian/Ubuntu specific), which by default contains the line:

--- Code: ---allowed_users=console
--- End code ---

This stops X being started by anyone other than a console user.  Change it to:

--- Code: ---allowed_users=anybody
--- End code ---

Then edit your /etc/rc.local to start X as the user in question:

--- Code: ---su - mame -c 'startx'
--- End code ---

"su" is the user switching tool, as the system starts by default as the root user.  The hyphen tells su to completely load the profile of the user you're switching to.  Then it's the user's name (again, I have a user called "mame"), then the -c flag informs su to run a particular command on switch, which in our case is 'startx'.  The Xwrapper.config allow s any user to start X, and the .xinitrc file tells X what to load when it starts.

There you have it.  Auto login, straight to a fullscreen frontend.  Use a tool like "htop" to compare your system RAM usage with a window manager and without.  You'll be amazed to see how much memory even lightweight window managers gobble up doing absolutely nothing.

General_Faliure:
Thanks for this tutorial.
I might try it on a next project.
I have just built in a newer mainboard in my cab, a core 2 duo 8400 @3.6 Ghz and 4 Gb of mem, so no lack of resources here.
I started out with an Athlon XP 2100 with 512 Mb which worked fine for most mame games, but came up short with the newer emulators.
I keep the window manager for ease of use, i asume you can still start the window manager for maintenance?

elvis:

--- Quote from: General_Faliure on January 03, 2014, 01:21:22 am ---i asume you can still start the window manager for maintenance?

--- End quote ---
You can, but why bother?  Change your .xinitrc to load "xterm".  From there you can run any commands you like to fire up programs (including GUI ones like Nautilus, Wahcade Setup, etc).

Ansa89:

--- Quote from: elvis on February 23, 2014, 02:10:44 am ---Change your .xinitrc to load "xterm".

--- End quote ---
Or just use ssh with x-forward.

MotorHedJr:
Elvis,

Great work. Can you please tell what Linux distro and version you're using? I've beaten my head all summer trying to get the AdvMAME (106)/SVGAlib Linux build to work on a multi-core newer processor.

I've verified my video card works per the AdvMAME procedures too on a way old version of Ubuntu (8.02 something I think)

I've had problems getting the right version of SVGAlib (that AdvMAME wants) to compile on a kernel that's still compatible w/ a current MOBO w/ a multi-core processor... Specifically, I can get everything to compile but when I goto launch AdvMAME my issue is the console seems to be 'corrupted'. (Bunch of text error messages) Thanks!

Regards,
John

Navigation

[0] Message Index

[#] Next page

Go to full version