Page 1 of 1

TWM ad hoc Minimal Graphical User Interface for Raspbian

Posted: Tue Apr 12, 2016 12:00 am
by MarkHaysHarris777
Greetings, the purpose of this post is to document a minimal graphical user interface for raspbian (twm tiny window manager) which is ad hoc, compatible with existing openbox, and has a very small footprint in ram.

There are many ways to accomplish this; this is one way, ad hoc, and manual-- although, it has been scripted (barely) to make the typing a little easier.

The first thing we want to do is to download the packages and fonts we will need:

Code: Select all

sudo apt-get install twm
sudo apt-get install x11-apps
sudo apt-get install xterm

sudo apt-get install xfonts-base
sudo apt-get install xfonts-100dpi
sudo apt-get install xfonts-75dpi
sudo apt-get install xfonts-terminus
Next we need to create two scripts in ~/bin/
The first is ~/bin/vt7-startx.sh

Code: Select all

#!/bin/sh
sudo /usr/bin/X -nolisten tcp :1 vt7 &
export DISPLAY=:1
sleep 2
exec ~/bin/mydesk-twm.sh
The second is ~/bin/mydesk-twm.sh

Code: Select all

xclock -display $DISPLAY -geometry 120x110+1764+30 &
xterm -display $DISPLAY -fn 9x15 -geometry 80x64+300+30 &
xcalc -display $DISPLAY -geometry +1400+694 &

exec twm -display $DISPLAY &
sleep 1
xsetroot -display $DISPLAY -solid darkcyan
You will need to make both of them executable with :

Code: Select all

chmod 0754 ~/bin/mydesk-twm.sh
chmod 0754 ~/bin/vt7-startx.sh
I boot my PI into the CLI black screen, and start my X environment if and when needed. You do not need to do that, of course, you can start vt7-startx.sh with openbox already running on display :0, vt1, because vt7-startx.sh uses display :1, vt7.

From the black screen on vt1 login as PI and run the startup script:

vt7-startx.sh

The screen will go black for about two seconds while the X server is initializing, and then the twm tiny window manager will start, give you a couple of cool apps, and set the background color to darkcyan; suit yourself and change any and all of this...

This simple setup assumes a display geometry of 1920x1080 (flat panel hdmi). If yours is different you may need to change the -geometry settings in the mydesk-twm.sh script to accommodate your own setup.

If openbox was already running you can toggle between the new desk and the old desk with:
ctrl-alt-F1 <> ctrl-alt-F7

You can have more than one of these desks running at a time; however, you will have to assign unique display numbers (greater than or equal to :2) and you will need to assign a unique virtual terminal vt8, etc.

Experiment; X is fun !

notes: if the cursor is missing from the new desk just left click to get it to appear. In an app it will look normal; on the open desktop it will be the now famous X cursor (this is normal for twm)

To get to the debian main menu left click on the open desktop and follow the yellow brick road... you can drill down many levels, and all of the raspbian apps are available (most all anyways).

edit: FYI twm was the only XFree86 window manager back in the early days of gnu+linux; so, this is a bit of an historical side-bar. twm has been around (obviously) for a very long time... it was good to see that its still in the repositories.


Enjoy

:ugeek:

Re: TWM ad hoc Minimal Graphical User Interface for Raspbian

Posted: Sun Nov 27, 2016 12:19 pm
by raspiab_1
Thanks for this. I wanted to auto-login the pi user and start up the TWM desktop and this helped. Here is the auto login part for inittab in case anyone else needs it. You will need to `apt-get install rungetty` first.

I changed this line in /etc/inittab:

Code: Select all

#1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/sbin/rungetty -u pi --autologin pi tty1
added this to /home/pi/.profile:

Code: Select all

isx=`ps -ef | grep bin/[X$]`
test -z "$isx" && /home/pi/bin/vt7-startx.sh
The inittab edit does an auto-login for the pi user. The pi user shell is set to /bin/bash so /home/pi/.profile is executed on login which contains a check to see if X is already running. If it is not running, it is started. The check is necessary so X is not started again every time a new shell is spawned. NOTE: this is not a good way for a multiuser system but works fine for pi where only 1 user is ever using the system.

PS: This will not work with SystemD type system as inittab is not used :/