Dan Nelson wrote:
> 
> In the last episode (Nov 07), Dag-Erling Smorgrav said:
> > Graham Wheeler <[EMAIL PROTECTED]> writes:
> > > I am trying to write a screen saver module that, when it kicks in,
> > > will switch to the first console, and then, if a key is pressed,
> > > will switch back to the one that was previously active. The idea is
> > > that the first console has something useful running on it,
> > > typically a tail -f of the logs.
> >
> You can make it look like you're switched to vty 0, by making your
> screen_saver() function simply copy the contents of vty 0 to screen
> memory on every update.  Just make sure both vtys are the same size
> first...

Okay, got it working. I've attached my code if anyone is interested.
Thanks for all the help Dan. 

I have another question now - it would be great if I could put a message
on the top or bottom line of /dev/ttyv0, in inverse video, and have the
output of the `tail -f' go to a scrolling region in the rest of the
screen. The idea here is, on /dev/ttyv0, to have a message "Press Alt-Fn
(n=1,2,..) for Login Consoles". The screen saver would replace this with
"Press any key to stop watching logs and return to login console", or
something like that.

It would be nice, but its not too important...

gram
-- 
Dr Graham Wheeler                        E-mail: [EMAIL PROTECTED]
Director, Research and Development       WWW:    http://www.cequrux.com
CEQURUX Technologies                     Phone:  +27(21)423-6065
Firewalls/VPN Specialists                Fax:    +27(21)424-3656
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/syslog.h>

#include <machine/md_var.h>
#include <machine/random.h>

#include <saver.h>

#include <dev/syscons/syscons.h>

#ifndef SC_STAT
#define SC_STAT         sc_get_scr_stat
#endif

#ifndef MAXCONS
#define MAXCONS         16
#endif

void CopyConsoleContents(video_adapter_t *adp, int from)
{
    if (from>=0 && from<MAXCONS)
    {
        int s = spltty();

        /* The next line may be the right way for FreeBSD 4.x */

        /*scr_stat *fc = SC_STAT(SC_DEV(sc_find_softc(adp, NULL), from));*/

        /* I'm using 3.4, which can't cope with the above; this is a 
           more kludgy equivalent that works for me; it assumes
           that the syscons major dev number is 12 */

        scr_stat *fc = sc_get_scr_stat(makedev(12, from));

        if (fc->scr_buf && adp->va_window &&
                fc->ysize == adp->va_info.vi_height &&
                fc->xsize == adp->va_info.vi_width)
        {
            int len = fc->ysize * fc->xsize, pos;
            for (pos = 0; pos < len; ++pos)
                writew(adp->va_window+pos*2, fc->scr_buf[pos]);
        }
        splx(s);
    }
}

static int
switch_saver(video_adapter_t *adp, int blank)
{
    if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
        return EAGAIN;
    if (blank)
        CopyConsoleContents(adp, 0);
    return 0;
}

static int
switch_init(video_adapter_t *adp)
{
    (void)adp;
    return 0;
}

static int
switch_term(video_adapter_t *adp)
{
    (void)adp;
    return 0;
}

static scrn_saver_t switch_module = {
    "switch_saver", switch_init, switch_term, switch_saver, NULL,
};

SAVER_MODULE(switch_saver, switch_module);

Reply via email to