13. Installing X Windows

13.1. An X on OpenPsion Screenshot!

X windows can be installed on the 5MX. This involves three basic steps: (1) install the relevant *.deb files (*.ipk files are as yet untested), (2) get the Xipaq X server that has been specially configured for the 5MX, and (3) configure a window manager. X windows is a fairly large overgrown package, but the number of applications designed to run under X windows is staggering. Note: The 5MX Xipaq server seems to be available only as a binary; the original patches to the X source code for the 5MX seem to have been lost. If you have information as to the wherabouts of that patch, please post to the OpenPsion mail list.

13.2. Prerequisites

You will need to have a compactflash with something like 80 MB of free space available for the linux distribution with X windows. After installation, a great deal of disk space can be freed up by the deletion of extraneous fonts, binaries, and other meta data. Without doing any of this clean up, my 96MB linux partition was left with 12MB of free space.

Until the ipkg system gets sorted out, you will also need a distribution based on dpkg.

13.3. Packages to Install

The following packages and binaries, or their more modern versions, need to be installed: (The *.deb packages can be obtained from the distribution packages site at debian.org. Be sure to arm binaries, not i386 binaries.)

cpp_2.95.4-9_arm.deb
libncurses5_5.2.20020112a-5_arm.deb
libdps1_4.1.0-14_arm.deb
libfreetype6_2.0.9-1_arm.deb
libglib1.2_1.2.10-4_arm.deb
libutahglx1_0.0-cvs-20010702-3_arm.deb
libxaw7_4.1.0-14_arm.deb
xfree86-common_4.1.0-14_all.deb
xbase-clients_4.1.0-14_arm.deb
xlibs_4.1.0-14_arm.deb
zlib1g_1.1.4-1_arm.deb
xfs_4.1.0-14_arm.deb  (optional)
xserver-common_4.1.0-14_arm.deb (optional)
The X fonts are slightly optional:
xutils_4.1.0-14_arm.deb
xfonts-base_4.1.0-14_all.deb
xfonts-scalable_4.1.0-14_all.deb
xfonts-75dpi_4.1.0-14_all.deb
Bearing in mind the severe memory constraints, X terminal emulators to consider are:
xvt_2.1-14_arm.deb
rxvt_2.6.4-3_arm.deb
xterm_4.1.0-14_arm.deb (a memory hog)
Of these xvt is preferred, because it uses much less memory.

In addition, you will need to download the Xipaq X server from the "Sourceforge downloads" download site from OpenPsion. This tarball contains:

Xipaq
Xmodmap

There are several approaches to using the mouse functions. See the section below on Mouse Issues.

You will also need a Window manager for X. Here we will discuss the Blackbox window manager, blackbox_0.62.1-1_arm.deb. The Windowmaker manager might be a little better (see screenshot below), and there are other managers as well.

Install the above *.deb packages, and copy the Xipaq server to /usr/X11R6/bin/X.

Before starting X, first make sure you are in 4bpp by fbset -a 4bpp, and be sure the touch panel device "/dev/tpanel" exists (mknod /dev/tpanel c 10 11). Then execute startx! If you are not in 4bpp, you will get a segmentation fault. You can start X more simply by just exec xinit which will save a little memory (startx is a script, so it keeps a shell open while X is running.)

You can start X up with the screen rotated. Start the xserver with:

Xipaq -screen 640x240@$ROTATION
where for values of $ROTATION:
($ROTATION <45)||( $ROTATION>=315) screenrotation = 0°
($ROTATION <135)&&( $ROTATION>=45) screenrotation = 90°
($ROTATION <=225)&&( $ROTATION>=135) screenrotation = 180°
($ROTATION <=315)&&( $ROTATION>=225) screenrotation = 270°
A rotation of 90° can improve the useability of some applications as long the required width is less than 240 pixels. [No, setting the resolution to something bigger (like 640x480 or 1280x1024) doesn't do virtual resolution (nor does it increases your screensize)]. You can set up a small script called /usr/bin/X11/Xrot containing the lines:
  #!/bin/sh
  /usr/bin/X11/Xipaq -screen 640x240@90
(and chmod 755 Xrot). Then, the rotated X can be started with xinit -- /usr/bin/X11/Xrot.

13.4. Configuring the Blackbox Window Manager

There are three main configuration files that need to be set up to run the Blackbox Window Manager: (1) .xinitrc, (2) .blackboxrc, and (3) ~/.blackbox/menu. These are discussed in turn.

~/.xinitrc

/msdos/x11/XRmouse & 
xrdb ~/.Xdefaults 
#rclock -geometry 60x60-1-1 & 
xvt -sb -geometry 60x12+5+20 -sl 200 & 
/usr/bin/blackbox -rc /root/.blackboxrc
startx, in the end, looks to this file to start up the X applications. The above file ends with blackbox until that process terminates (i.e. when you are done with your X session.) The rclock application is commented out as an example of things you can do to conserve memory.

~/.blackboxrc

session.screen0.slit.placement: CenterRight 
session.screen0.slit.direction: Vertical
session.screen0.slit.onTop:	False
session.screen0.slit.autoHide:	False
session.screen0.toolbar.onTop:	False
session.screen0.toolbar.autoHide:	False
session.screen0.toolbar.placement:	TopRight
session.screen0.toolbar.widthPercent:	66
session.screen0.workspaces:	2
session.screen0.focusLastWindow:	False
session.screen0.edgeSnapThreshold:	0
session.screen0.rowPlacementDirection:	LeftToRight
session.screen0.focusNewWindows:	False
session.screen0.windowPlacement:	RowSmartPlacement
session.screen0.focusModel:	SloppyFocus
session.screen0.workspaceNames: Workspace 1,Workspace 2
session.screen0.strftimeFormat: %I:%M %p
session.screen0.colPlacementDirection:	TopToBottom
session.screen0.fullMaximization:	False
session.cacheLife:	5
session.colorsPerChannel:	4
session.opaqueMove:	False
session.imageDither:	True
session.menuFile:	/root/.blackbox/menu
session.styleFile:	/usr/share/blackbox/styles/Minimal
session.autoRaiseDelay: 400
session.cacheMax:	200
session.doubleClickInterval:	250
The main elements here are the menu file (discussed next) and the styleFile. The styleFile sets the colors and contrast - the "Mimimal" style seemed to work well for the psion, but you can try other styles.

~/.blackbox/menu

#Blackbox menu file
[begin] (Blackbox 0.62.1pre0)
[exec] (xvt) {/usr/bin/xvt -sb -geometry 60x12-10-10 -sl 200}
[exec] (rxvt) {/usr/bin/rxvt -sb -geometry 60x14-10-10 -sr -sl 200}
[exec] (xedit) {xedit -geometry 500x200-5-5 }
[exec] (xcalc) {xcalc -geometry 200x200-15-15 }
[exec] (rclock) {rclock -geometry 60x60-1-1 }
[submenu] (Window Manager)
   [exec] (Edit Menus) {xedit -geometry 500x200-5-5 ~/.blackbox/menu}
   [config]   (Config Options)
   [reconfig] (Reconfigure)
   [restart] (Restart)
   [submenu] (Styles) {Which Style?}
	[styles menu] (Blackbox Styles) {/usr/share/blackbox/styles}
   [end]
[end]
[exit] (Exit)
[end]
[end]
#end of menu file
It is obvious how one would go about adding additional applications to the menu. The "style"'s file gives a list of all of the styles that come with the blackbox package (e.g., "Minimal").

Here is a screenshot of the Windowmaker Manager, an alternative manager. Emacs21 is also shown running. This manager has a number of advantages over Blackbox.

Here is a screenshot of the IceWM window manager, another lightweight manager.

13.5. Using the extra-screen icons

It is possible to use the toolbar of the 5MX screen in X windows using a utility call xpsitouch, an LCD toolbar handler. The README file tells the details on implementation. Xpsitouch basically ties clicks on the icons to specific functions that can be defined. These functions can be used to do things such as rotate the pointer click (mouse 1, 2, or 3), or launch specific applications or scripts.

13.6. Mouse Issues

The psion's touch screen has mouse button 1 pressed by default when you touch the screen. If you hold down the Menu key you can move a window by moving the mouse in the window. If mouse button 3 is the default and you hold down the Menu key, the "mouse" can be used to resize a window by moving the mouse anywhere in the window.

You can change the default mouse button manually using xmodmap:

xmodmap -e "pointer = 2 1 3"
will change the default button to 2, etc.

Most desktop systems like fluxbox, fvwm, WindowMaker, blackbox include a system for setting up custom keybindings for executing commands. fluxbox includes such a system natively, blackbox requires the bbkeys package. These systems allow one to set up keybindings to do things such as change the default pointer button (what button is executed when the screen is tapped), or adjust volume, or execute a play or record of sound.

The keylaunch package from the X windows section at debian.org can be used to tie custom key strokes to executing arbitrary commands such as those using xmodmap to change the mouse buttons. Start keylaunch & in your .xinitrc file. Set up a file .keylaunchrc that contains:

# Format:
# key=...KeyName: Command
#
# ... No modifier
# *.. Shift
# .*. Ctrl
# ..* Alt

key=..*Return: xvt
key=.*.1:xmodmap -e "pointer = 1 2 3"
key=.*.2:xmodmap -e "pointer = 2 3 1"
key=.*.3:xmodmap -e "pointer = 3 1 2"
So that

It might be possible to set up special key strokes to behave as the mouse buttons - the accessX extensions to X apparently allow you to do that. This is the MouseKeys feature. No luck as yet getting this to work. (If you type "Cntrl""Shift""NumLock" on your desktop, you can then use the number keypad to move the mouse around and execute mouse button clicks. The Psion does not have such a number keypad...)

Defunct Tools: xbut, XRmouse

One tool that binds the mouse buttons to key strokes is xbut. It allows you to map key stroke combinations to mouse buttons, using a .xbutrc like:

# Xbut generates mouse clicks from the keyboard
#
# To see the keycodes, run xev
#
66,Shift,1	# Shift+Left
49,Shift,2	# Shift+Down
65,Shift,3	# Shift+Right
You can download a binary for xbut HERE.

The mouse button functions can also be emulated with XRmouse. This nifty tool uses up considerable RAM at the moment, alas. The XRmouse application can be seen in the top left hand corner of the screenshot at the top of this page. XRmouse takes a bit of getting used to, but it works quite well after a time. The binary and source can be downloaded from http://projects.gnome.hu/xrmouse/index.en.html.

To use XRmouse you need the gtk libraries:

libgtk1.2-common_1.2.10-9_all.deb
libgtk1.2_1.2.10-9_arm.deb

13.7. Keyboard Issues

The .Xmodmap file that works for me is:

keycode 71 = Shift_L
keycode 63 = Shift_R
keycode 47 = Control_L
keycode 55 = Mode_switch
keycode 39 = Alt_L
clear Lock
add Shift = Shift_L
add Shift = Shift_R
add Control = Control_L
add Mod1 = Alt_L
add Mod5 = Mode_switch

13.8. Useful X applications

While all X applications are technically supposed to work on the psion running X, there are three limitations (1) screen size, (2) memory, and (3) disk space. You must choose your applications carefully, given these constraints.

13.9. Using a serial mouse!

It is possible to use a serial mouse on the 5MX. But first: it was once rumoured that using such a mouse would burn out the serial chip. However, the serial chip is meant to be the same as on the netBook, a Maxim 78266, which is identical to the Maxim MAX3243-RS chip. And this chip was explicitly designed to support a mouse. But be aware that if you want to use a external mouse, there is a slight danger to your serial chip. I have used a Logitech serial mouse without a problem for a few years now on my netBook, and the same mouse on my 5MX for a short while now without a problem. And no one has ever reported a burnt out serial chip (the rumour originated with the XTM people, the 186 emulator for EPOC).

You will first need a null-modem adapter for the serial port. The 5MX cable is designed to be null-modem by default, so that it can plug directly into the PC. So to use other external devices, such as mouse or GPS receiver, you need a null-modem serial adapter. The netBook HOWTO has more information about this issue. Your local electronics store should carry such null-modem adapters, although these are becoming harder to find as serial ports disappear from the computer landscape.

Then you will need an honest old serial mouse, which are also becoming harder to find. Check your local PC recycling store for a box of used serial mice, or try e-bay.com. A PS/2 mouse with an adapter will probably not work, unless the mouse is explicitly designed to support serial. I have had good luck with Logitech serial mice.

The 5MX Xipaq server does not support a serial mouse, alas. However, the Xfbdev from familiar linux at handhelds.org supports the 5MX framebuffer and a serial mouse. The 5MX touch screen will not be supported with this X server, however. The version to get is xserver-kdrive-fbdev version 6.6.1-11, and you'll also likely need the libxfont0 package. Unpack these with ar -x foo.ipk and copy the two binaries over to the equivalent place on 5MX. Place the Xfbdev binary in /usr/X11R6/bin and make a link from it to X there.

Then you'll need to make a link from /dev/ttyAM1 to /dev/mouse: ln -s /dev/ttyAM1 /dev/mouse; the Xfbdev server looks to /dev/mouse for the mouse by default. Disable any getty you may be running on /dev/ttyAM1. Then, you need to setup the serial port for 1200 baud. For this try, this script:

#!/bin/sh
stty -F /dev/ttyAM1 4:0:8e9:0:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
Curiously, you may have to run this twice - it might complain about not being able to carry out the instructions the first time. Then, if you plug in the mouse, and execute cat /dev/ttyAM1, you should see a stream of binary characters when the mouse is moved. Alternatively, try using minicom with 1200 baud set.

At this point, with the binary mouse characters verified, you can start X with xinit to see if the mouse works.

You can reset the serial port for 115200 baud with

#!/bin/sh
stty -F /dev/ttyAM1 1:0:800018b2:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:2f:0:0:0:0:0:0:0:0:0:0:0:0:0