LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to Run a Custom Made Screen Saver with xscreensaver (https://www.linuxquestions.org/questions/linux-software-2/how-to-run-a-custom-made-screen-saver-with-xscreensaver-4175580222/)

Yetoo 05-19-2016 10:42 PM

How to Run a Custom Made Screen Saver with xscreensaver
 
I recently have made a test screensaver that has compiles successfully but does not run. All that sits at the terminal is a still courser. I have yet to find a website that explains how to individually start a screensaver. In case it concerns anyone, here is the code for the screensaver.
Code:


#include<stdlib.h>
#include<X11/Xlib.h>

#include "vroot.h"

main ()
{
  Display *dpy;
  Window root;
  GC g;


  /* open the display (connect to the X server) */
  dpy = XOpenDisplay (getenv ("DISPLAY"));


  /* get the root window */
  root = DefaultRootWindow (dpy);


  /* create a GC for drawing in the window */
  g = XCreateGC (dpy, root, 0, NULL);


  /* set foreground color */
  XSetForeground(dpy, g, WhitePixelOfScreen(DefaultScreenOfDisplay(dpy)) );


  /* draw something */
  while (1)
    {
      /* draw a square */
      XFillRectangle (dpy, root, g, random()%500, random()%500, 50, 40);


      /* once in a while, clear all */
      if( random()%500<1 )
        XClearWindow(dpy, root);


      /* flush changes and sleep */
      XFlush(dpy);
      usleep (10);
    }


  XCloseDisplay (dpy);
}

Just to clarify, this is not gnome-screensaver, this is xscreensaver.

frankbell 05-21-2016 09:30 PM

I have never done anything like this and can't answer your question directly, but xscreensaver has a number of man pages. I start by looking through them; some of them may give you a hint as to how to write a compatible screensaver.

Code:

$ apropos xscreensaver
XScreenSaver []      (3)  - X11 Screen Saver extension client library
cage []              (6)  - Escher's impossible cage, for xscreensaver
gears []            (6)  - draw interlocking gears, for xscreensaver
xscreensaver []      (1)  - command - control a running xscreensaver process
xscreensaver []      (1)  - demo - interactively control the background xscreensaver daemon
xscreensaver []      (1)  - extensible screen saver framework, plus locking
xscreensaver []      (1)  - getimage - put some randomly-selected image on the root window
xscreensaver []      (1)  - getimage-file - put a randomly-selected image on the root window
xscreensaver []      (1)  - getimage-video - put a video frame on the root window
xscreensaver []      (1)  - text - prints some text to stdout, for use by screen savers
xscreensaver []      (6)  - gl-helper - figure out which X visual to use for GL programs

You might also follow this link to the xscreensaver FAQ:

I'm just learning to program X, and I want to write an xscreensaver module. Where should I start?

Yetoo 05-22-2016 11:50 AM

I just looked through and I found that the .xscreensaver file in the home directory has all the modules that it is going to load. Thing is though, there is no path's involved, it just has the name. But I don't think there is a way. I tried running the other screensavers as a program and magically, the screensaver ran with all the graphics and such. However, when I ran simplesquares, the cursor stopped blinking and not even a flicker appears. Most liekly the example code does not work, but I do not know where other example code is.

Yetoo 05-22-2016 12:03 PM

I found the solution through a python tutorial: http://alvinalexander.com/python/pyt...eensaver-linux
All you need to do is to add the path to the .xscreensaver list of programs to run. Then to view it, just open up the demo and preview it.


All times are GMT -5. The time now is 06:34 AM.