*BSD News Article 28540


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!olivea!inews.intel.com!mwilley
From: mwilley@pcocd2.intel.com (Mark Willey - PCD)
Newsgroups: comp.os.386bsd.apps
Subject: Re: XFree Screen Saver
Date: 21 Mar 1994 17:55:56 GMT
Organization: Intel Corporation
Lines: 149
Sender: mwilley@pcocd2 (Mark Willey - PCD)
Distribution: world
Message-ID: <2mkn3c$aht@inews.intel.com>
References: <anderbea.1409.2D8CE2E9@columbia.dsu.edu>
NNTP-Posting-Host: fiw206.intel.com
Originator: mwilley@sedona


In article <anderbea.1409.2D8CE2E9@columbia.dsu.edu>, anderbea@columbia.dsu.edu (Anthony Anderberg) writes:
> 
>   Is there a way that I can change the length of time
> before the screen blanker starts?  Better yet,disable
> it all togather?

Well, you can use xset, or if you need to do it from a C program, here's a
quick example...

#include <stdio.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>

#define        TRUE    (1)
#define        FALSE   (0)

/*
#define DEBUG
*/

main(argc, argv)
    int   argc;
    char *argv[];

{
    char      *display, *geom, *fname, *cmd;
    int       mode_query, mode_set, set_delay, i;
    XEvent    event;
    Display   *theDisp;

    int       timeout, interval, prefer_blanking, allow_exposures;

    cmd = argv[0];
    display = geom = fname = NULL;
    mode_query = mode_set = FALSE;
    set_delay = 0;

    /*********************Options*********************/

    for (i = 1; i < argc; i++) {
        char *strind;

        if (!strncmp(argv[i],"-d",2)) {         /* display */
            i++;
            display = argv[i];
            continue;
        }

        strind = index(argv[i], ':');           /* old-style display */

        if (strind != NULL) {
            display = argv[i];
            continue;
        }

        if (!strncmp(argv[i],"-q",2)) {                /* query screen saver */
            if (mode_query)
              Syntax(cmd);
            mode_query = TRUE;
            continue;
        }

        if (!strncmp(argv[i],"-s",2)) {                /* set screen saver */
            if (mode_set)
                Syntax(cmd);
            mode_set = TRUE;
            set_delay = atoi(argv[++i]);
            continue;
        }

        Syntax(cmd);
    }

#ifdef DEBUG
    fprintf(stderr, "mode_query: %d, mode_set: %d, set_delay: %d, display: %s\n",
            mode_query, mode_set, set_delay, display);
#endif

    if ((!mode_set) && (!mode_query))
        Syntax(cmd);

    if (( theDisp = XOpenDisplay(display)) == NULL) {
        fprintf(stderr, "%s: Can't open display: %s\n", cmd, display);
        exit(1);
    }

    XGetScreenSaver(theDisp, &timeout, &interval, &prefer_blanking, &allow_exposures);

    if (mode_query) {
        fprintf(stderr, "timeout: %d, interval: %d, prefer_blanking: %d, allow_exposures: %d\n",
                timeout, interval, prefer_blanking, allow_exposures);
    }

    if (mode_set) {
        timeout = set_delay;
        XSetScreenSaver(theDisp, timeout, interval, prefer_blanking, allow_exposures);
    }

    XCloseDisplay(theDisp);

    exit(0);
}

Syntax(char *cmd)
{
    printf("Usage: %s (-query_screen_saver &| -set_screen_saver seconds) [-display display]\n",cmd);
    exit(1);
}

and here's makefiles for iaws and rs6k machines....
iaws...
CFLAGS = -O
OBJECTS = x_screen_saver.o
INCLUDES = 
LIBRARIES = -lX11 -lnsl -lc
CC = gcc $(CFLAGS) $(INCLUDES)

x_screen_saver: $(OBJECTS)
	$(CC) $(OBJECTS) -o $@ $(LIBRARIES)

.c.o:
	$(CC) -c $<

clean:
	rm -f x_screen_saver *.o

rs6k...
CFLAGS = -O
OBJECTS = x_screen_saver.o
INCLUDES = 
LIBRARIES = -lX11 -lc
CC = gcc $(CFLAGS) $(INCLUDES)

x_screen_saver: $(OBJECTS)
	$(CC) $(OBJECTS) -o $@ $(LIBRARIES)

.c.o:
	$(CC) -c $<

clean:
	rm -f x_screen_saver *.o

-- 
------------------------------------------------------------------------
Mark Willey                                                 916-356-5477
Intel Corporation, FM2-48                       mwilley@pcocd2.intel.com
1900 Prairie City Rd, Folsom, CA 95630	  I speak for myself, not Intel.
------------------------------------------------------------------------