LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-19-2016, 10:42 PM   #1
Yetoo
LQ Newbie
 
Registered: Dec 2015
Distribution: Fedora, Debian, Ubuntu, couldn't install gentoo
Posts: 20

Rep: Reputation: Disabled
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.
 
Old 05-21-2016, 09:30 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 16,752
Blog Entries: 27

Rep: Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082Reputation: 5082
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?
 
Old 05-22-2016, 11:50 AM   #3
Yetoo
LQ Newbie
 
Registered: Dec 2015
Distribution: Fedora, Debian, Ubuntu, couldn't install gentoo
Posts: 20

Original Poster
Rep: Reputation: Disabled
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.
 
Old 05-22-2016, 12:03 PM   #4
Yetoo
LQ Newbie
 
Registered: Dec 2015
Distribution: Fedora, Debian, Ubuntu, couldn't install gentoo
Posts: 20

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply

Tags
c-language, xscreensaver


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xscreensaver - Different screen-saver for each monitor? RichardPowers Linux - Software 2 09-03-2010 07:10 AM
How to run a custom made scheduler? chaitukanna Linux - Newbie 4 02-02-2009 09:08 AM
How do I run a scripts when screen saver activates? MikeyCarter Linux - Software 5 07-01-2008 12:56 PM
Feisty: Screensavers Run Slowly During Idle Time, and Fast During screen Saver Test. bburgy Ubuntu 4 06-27-2007 11:05 PM
How to turn off screen blanking screen saver in run level 3? Arodef Linux - Software 1 01-04-2005 01:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration