Two 2 Cent Tips -- syslog & X Color DepthDate: 13 Jan 1997 10:33:29 +0100
From: Marco Melgazzi,
Dear sirs
Here's two 2c tips for your wonderful Linux Gazette. Note that all the lines ending with \ have to be joined on one line.
1. :::: Syslog fun (oh no, not again) :::::
Everybody seem to like to put a line like the following in their syslog:
*.* /dev/ttyx
this way every message is printed on an unused tty and the curious ( or worried ) user can switch to it and see what's going on. This approach has a big advantage ( it doesn't use any system resource ) and a couple of disadvantages ( notably you have to switch to text mode to read the messages and then you don't have scrollback ). So I have this little workaround: in /etc/syslog.conf put something like
*.* /var/adm/current_session_log
In rc.local or whatever file is called before starting syslog
/bin/cat /dev/null > /var/adm/current_session_log
In fvwm you can add something like this:
Style "tail" NoTitle, NoHandles, Sticky, WindowListSkip
Style "tail" StaysOnTop, CirculateSkip
*GoodStuff S-Log telnet-sm.xpm Exec "rxvt" \
rxvt -geometry 132x45-0+0 -sl 1200 -font fixed \
-e tail -n 1200 -f /var/adm/current_session_log &
So when you press the goodstuff button named 'S-log' you get a big rxvt with a nice scrollback buffer that displays exactly what's going on in the system. If your linux system stays up for weeks at a time you'll probably have to set up a CRON entry that trims this file every once in a while but this is left as an exercise for the reader ;-)
To pop down the rxvt a simple Ctrl-C is more than enough. By the way, this approach will surely save a lot of stress to the monitor electronics: in fact switching from text mode to hires a) takes time b) involves quite a lot of non-trivial adjustments in the monitor circuitry so it could likely acceelerate its ageing process.
2. ::::: How to use X with more than one color depth ::::::
I normally use X in 8bit ( since my board is not VRAM based 1152x864 at 70Hz slows down things considerably ) but, since when I hacked my XF86_S3 to let me use higher clocks in 16bit mode :), occasionally I need to switch to the 16bits depth (notably when using the oh-so-amazing 'The Gimp').
Since leaving two servers up and running all the time via xdm seemed a waste of memory, by tinkering with manual pages and articles from the net I came up with a viable alternative.
Let me first tell you one thing: in this way, when the second server is running, you get both :0 (in 8bit) that is managed by xdm and :1 that has been started on-demand. Since I don't usually use :1 while I'm online I didn't took the time to provide MIT-MAGIC-COOKIE authorization for it: this is a thing you -should- do if you plan to use this on the net.
Here there are a couple of my scripts:
::: ----------------------------------------------------------------
:::/usr/local/bin/1open16
::: ----------------------------------------------------------------
xinit ~/.x_rc_for_1_16 -- /usr/X11/bin/X16 :1 vt8 &
::: ----------------------------------------------------------------
:::/usr/X11/bin/X16
::: ----------------------------------------------------------------
#!/bin/sh
exec XF86_S3.new -bpp 16 ${@+"$@"}
::: ----------------------------------------------------------------
:::~/.x_rc_for_1_16
::: ----------------------------------------------------------------
#!/bin/sh
# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $
userresources=$HOME/.Xresources_for_1_16
usermodmap=$HOME/.Xmodmap
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap
export PATH= .... path ....
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge -display :1 $sysresources &
fi
if [ -f $sysmodmap ]; then
xmodmap -display :1 $sysmodmap &
fi
if [ -f $userresources ]; then
xrdb -merge -display :1 $userresources &
fi
if [ -f $usermodmap ]; then
xmodmap -display :1 $usermodmap &
fi
....
misc other variables
....
exec fvwm -f .fvwmrc_for_1_16
::: ----------------------------------------------------------------
::: in ~/.fvwmrc_for_1_16 I have this: I'm not sure this duplication
::: is necessary but in my configuration it is. YMMV
::: ----------------------------------------------------------------
Function "InitFunction"
Exec "I" xrdb -display :1 -merge ~/.Xresources &
Exec "I" xmodmap -display :1 ~/.Xmodmap &
Module "I" GoodStuff
Exec "I" emacs &
EndFunction
In this way when you execute the 1open16 script you will get a 16bit screen on :1 at the default resolution you put in your system XF86Config for 16bit depth.
Things get a little more hairy if you want to open the new screen with a different set of resolutions: unluckily ( I guess for security reasons ) XFree lets you use a new XF86Config -only- if you are root. So to play Quake on :1 you have to do the following...
::: ----------------------------------------------------------------
::: in ~/.fvwmrc ( this is nice for password requests, I use it all the
::: time, just put the word 'Password' in the rxvt that you need and use
::: the supplied style. I use it for going online, to access netscape &
::: other net stuff ( I'm paranoid so I created a user named -net- that
::: I use for all internet related stuff, I hate live-data trojans etc.)
::: you get the point.)
::: ----------------------------------------------------------------
Style "*Password" NoTitle, NoHandles, Sticky, WindowListSkip,StaysOnTop
::: in a menu entry
Exec "Quake (normal)" exec rxvt -fn \
"-b&h-lucidatypewriter-medium-r-*-*-*-180-75-75-*-*-*-*" \
-geometry 40x1+1-1 -T \"Quake Password" -e \
su root -c "/home/marco/bin/qk" &
::: ----------------------------------------------------------------
::: /home/marco/bin/qk. The redundant su is needed if you plan to launch
::: this file from the command line too.
::: ----------------------------------------------------------------
cd /home/marco/quake
su -c "xinit ./xf86quake -- /usr/X11/bin/X -bpp 8 :1 vt8 -xf86config \
/home/marco/lib/XF86Config.quake"
Of course /home/marco/lib/XF86Config.quake will contain only the resolution that I usually play quake at ( that is 400x300 or 512x384 ). In this way you can play quake without hassless even if you usually run at 1000-or-so x 800-or-so at whatever depth. Now if only Linus released the updated 1.06 xf86quake ;-) (in 1.01 you can't use a custom heap, you have the fixed 8mb one :( ).
Hope you'll like these tips!
Marco Melgazzi
|