[vlc-devel] [Patch] Xscreensaver plugin

Christophe Mutricy xtophe at laotseu.via.ecp.fr
Fri Mar 19 16:58:33 CET 2004


Hello,

I have made a plugin to VLC so we can use it with xscreensaver. You can
have all what VLC plays as a screensaver.

I don't know if it's useful for a lot of people but i have time to
waste, it's one of my old ideas and it's interresting understanding how
VLC works.

In fact, it's just an adaptation of the x11 plugin. We just have to draw
on the virtual root window xscreensaver provides us and don't have to
fed up with window manager or mouse, ... .

So there's only a new module descriptor (modules/video_output/xscreensaver.c)
		some fonction to handle the virtual root window (vroot.h)
		a specific CreateWindow function (xcommon.c)
		and #ifdef to not compile function we don't need.

I also write a little help text. I'm not a good (english)
writer. So feel free to comment syntax, spelling and content.
(doc/xscreensaver.txt)

There's also a little script. It helps to translate the -window-id
argument of xscreensaver to VLC argument and avoid to have a one-km long
command line in ~/.xscreensaver. (share/xscreensaver/vlc-xscreensaver)

Attached: 	xscreensaver.diff: result of "cvs diff -u"
		vroot.h, xscreensaver.c: to place in modules/video_output/x11/
		xscreensaver.txt: to place in doc/
		vlc-xscreensaver: to place in share/xscreensaver/

Bye


-- 
Xtophe
-------------- next part --------------
? doc/xscreensaver.txt
? modules/video_output/x11/vroot.h
? modules/video_output/x11/xscreensaver.c
? share/xscreensaver
Index: configure.ac
===================================================================
RCS file: /var/cvs/videolan/vlc/configure.ac,v
retrieving revision 1.198
diff -u -r1.198 configure.ac
--- configure.ac	18 Mar 2004 15:42:33 -0000	1.198
+++ configure.ac	19 Mar 2004 15:20:46 -0000
@@ -2449,6 +2449,31 @@
 fi
 
 dnl
+dnl  XScreensaver module
+dnl  (disabled by default)
+dnl
+AC_ARG_ENABLE(xscreensaver,
+  [  --enable-xscreensaver            XScreensaver support (default disabled)])
+if test "${enable_xscreensaver}" = "yes"
+then
+  CPPFLAGS="${CPPFLAGS_save} -I${x_includes}"
+  AC_CHECK_HEADERS(X11/Xlib.h, [
+    AX_ADD_PLUGINS([xscreensaver])
+    AX_ADD_LDFLAGS([xscreensaver],[-L${x_libraries} -lX11 -lXext])
+    AX_ADD_CPPFLAGS([xscreensaver],[-I${x_includes}])
+    AC_CHECK_HEADERS(X11/extensions/Xinerama.h, [
+      CFLAGS="${CFLAGS_save} -L${x_libraries} -lX11 -lXext"
+      AC_CHECK_LIB(Xinerama, XineramaQueryExtension, [
+        AC_DEFINE(HAVE_XINERAMA,1,[Define this if you have libXinerama installed])
+        AX_ADD_LDFLAGS([xscreensaver],[-lXinerama])
+      ])
+      CFLAGS="${CFLAGS_save}"
+    ])
+  ])
+  CPPFLAGS="${CPPFLAGS_save}"
+fi
+
+dnl
 dnl  SDL module
 dnl
 AC_ARG_ENABLE(sdl,
Index: doc/Makefile.am
===================================================================
RCS file: /var/cvs/videolan/vlc/doc/Makefile.am,v
retrieving revision 1.14
diff -u -r1.14 Makefile.am
--- doc/Makefile.am	5 Feb 2004 21:01:44 -0000	1.14
+++ doc/Makefile.am	19 Mar 2004 15:20:46 -0000
@@ -35,4 +35,5 @@
 	strings.txt \
 	translations.txt \
 	win32/Cross-Compile-Howto.txt \
+	xscreensaver.txt \
 	$(NULL)
Index: modules/video_output/x11/Modules.am
===================================================================
RCS file: /var/cvs/videolan/vlc/modules/video_output/x11/Modules.am,v
retrieving revision 1.3
diff -u -r1.3 Modules.am
--- modules/video_output/x11/Modules.am	27 Jun 2003 13:50:12 -0000	1.3
+++ modules/video_output/x11/Modules.am	19 Mar 2004 15:20:47 -0000
@@ -10,3 +10,9 @@
 	xcommon.h \
 	$(NULL)
 
+SOURCES_xscreensaver = \
+	xscreensaver.c \
+	xcommon.c \
+	xcommon.h \
+	vroot.h \
+	$(NULL)
Index: modules/video_output/x11/xcommon.c
===================================================================
RCS file: /var/cvs/videolan/vlc/modules/video_output/x11/xcommon.c,v
retrieving revision 1.43
diff -u -r1.43 xcommon.c
--- modules/video_output/x11/xcommon.c	14 Mar 2004 19:02:46 -0000	1.43
+++ modules/video_output/x11/xcommon.c	19 Mar 2004 15:20:47 -0000
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * xcommon.c: Functions common to the X11 and XVideo plugins
+ * xcommon.c: Functions common to the X11, XVideo and XScreensaver plugins
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
  * $Id: xcommon.c,v 1.43 2004/03/14 19:02:46 root Exp $
@@ -8,6 +8,7 @@
  *          Sam Hocevar <sam at zoy.org>
  *          David Kennedy <dkennedy at tinytoad.com>
  *          Gildas Bazin <gbazin at netcourrier.com>
+ *          Christophe Mutricy <xtophe at nxtelevision.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -73,6 +74,11 @@
 
 #include "xcommon.h"
 
+#ifdef MODULE_NAME_IS_xscreensaver
+#   include "vroot.h"
+#endif
+
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -82,11 +88,17 @@
 static int  InitVideo      ( vout_thread_t * );
 static void EndVideo       ( vout_thread_t * );
 static void DisplayVideo   ( vout_thread_t *, picture_t * );
+#ifndef MODULE_NAME_IS_xscreensaver
 static int  ManageVideo    ( vout_thread_t * );
-
+#endif
 static int  InitDisplay    ( vout_thread_t * );
 
+#ifdef MODULE_NAME_IS_xscreensaver
+static int  XscrCreateWindow   ( vout_thread_t * , x11_window_t * );
+#else
 static int  CreateWindow   ( vout_thread_t *, x11_window_t * );
+#endif
+
 static void DestroyWindow  ( vout_thread_t *, x11_window_t * );
 
 static int  NewPicture     ( vout_thread_t *, picture_t * );
@@ -98,7 +110,7 @@
 static IMAGE_TYPE *CreateShmImage ( vout_thread_t *,
                                     Display *, EXTRA_ARGS_SHM, int, int );
 #endif
-
+#ifndef MODULE_NAME_IS_xscreensaver
 static void ToggleFullScreen      ( vout_thread_t * );
 
 static void EnableXScreenSaver    ( vout_thread_t * );
@@ -108,23 +120,25 @@
 static void DestroyCursor  ( vout_thread_t * );
 static void ToggleCursor   ( vout_thread_t * );
 
+
+static void TestNetWMSupport( vout_thread_t * );
+static int ConvertKey( int );
+#endif
 #ifdef MODULE_NAME_IS_xvideo
 static int  XVideoGetPort    ( vout_thread_t *, vlc_fourcc_t, vlc_fourcc_t * );
 static void XVideoReleasePort( vout_thread_t *, int );
 #endif
 
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver )
 static void SetPalette     ( vout_thread_t *,
                              uint16_t *, uint16_t *, uint16_t * );
 #endif
 
-static void TestNetWMSupport( vout_thread_t * );
-static int ConvertKey( int );
-
+#ifndef MODULE_NAME_IS_xscreensaver
 /* Object variables callbacks */
 static int OnTopCallback( vlc_object_t *, char const *,
                           vlc_value_t, vlc_value_t, void * );
-
+#endif
 /*****************************************************************************
  * Activate: allocate X11 video thread output method
  *****************************************************************************
@@ -136,8 +150,9 @@
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     char *        psz_display;
+#ifndef MODULE_NAME_IS_xscreensaver
      vlc_value_t  val, text;
-
+#endif
 #ifdef MODULE_NAME_IS_xvideo
     char *       psz_chroma;
     vlc_fourcc_t i_chroma = 0;
@@ -146,7 +161,11 @@
 
     p_vout->pf_init = InitVideo;
     p_vout->pf_end = EndVideo;
+#ifndef MODULE_NAME_IS_xscreensaver
     p_vout->pf_manage = ManageVideo;
+#else
+    p_vout->pf_manage = NULL;
+#endif    
     p_vout->pf_render = NULL;
     p_vout->pf_display = DisplayVideo;
 
@@ -241,10 +260,12 @@
     p_vout->output.i_chroma = X112VLC_FOURCC(p_vout->output.i_chroma);
 #endif
 
+#ifndef MODULE_NAME_IS_xscreensaver
     /* Create blank cursor (for mouse cursor autohiding) */
     p_vout->p_sys->i_time_mouse_last_moved = mdate();
     p_vout->p_sys->b_mouse_pointer_visible = 1;
     CreateCursor( p_vout );
+#endif
 
     /* Set main window's size */
     p_vout->p_sys->original_window.i_width = p_vout->i_window_width;
@@ -252,10 +273,17 @@
 
     /* Spawn base window - this window will include the video output window,
      * but also command buttons, subtitles and other indicators */
+#ifndef MODULE_NAME_IS_xscreensaver
     if( CreateWindow( p_vout, &p_vout->p_sys->original_window ) )
+#else    
+    p_vout->p_sys->p_win = &p_vout->p_sys->fullscreen_window;
+    if( XscrCreateWindow( p_vout, p_vout->p_sys->p_win ) )
+#endif    
     {
         msg_Err( p_vout, "cannot create X11 window" );
+#ifndef MODULE_NAME_IS_xscreensaver
         DestroyCursor( p_vout );
+#endif        
         XCloseDisplay( p_vout->p_sys->p_display );
         free( p_vout->p_sys );
         return VLC_EGENERIC;
@@ -265,13 +293,16 @@
     if( InitDisplay( p_vout ) )
     {
         msg_Err( p_vout, "cannot initialize X11 display" );
+#ifndef MODULE_NAME_IS_xscreensaver
         DestroyCursor( p_vout );
+#endif        
         DestroyWindow( p_vout, &p_vout->p_sys->original_window );
         XCloseDisplay( p_vout->p_sys->p_display );
         free( p_vout->p_sys );
         return VLC_EGENERIC;
     }
 
+#ifndef MODULE_NAME_IS_xscreensaver
     /* Disable screen saver */
     DisableXScreenSaver( p_vout );
 
@@ -289,7 +320,7 @@
     /* Trigger a callback right now */
     var_Get( p_vout, "video-on-top", &val );
     var_Set( p_vout, "video-on-top", val );
-
+#endif
     return VLC_SUCCESS;
 }
 
@@ -302,6 +333,7 @@
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
+#ifndef MODULE_NAME_IS_xscreensaver
     /* If the fullscreen window is still open, close it */
     if( p_vout->b_fullscreen )
     {
@@ -313,8 +345,9 @@
     {
         ToggleCursor( p_vout );
     }
+#endif
 
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver )
     /* Destroy colormap */
     if( XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 )
     {
@@ -325,9 +358,12 @@
 #endif
 
     DestroyCursor( p_vout );
+#ifndef MODULE_NAME_IS_xscreensaver
     EnableXScreenSaver( p_vout );
     DestroyWindow( p_vout, &p_vout->p_sys->original_window );
-
+#else 
+    DestroyWindow( p_vout, p_vout->p_sys->p_win );
+#endif
     XCloseDisplay( p_vout->p_sys->p_display );
 
     /* Destroy structure */
@@ -491,6 +527,7 @@
     XSync( p_vout->p_sys->p_display, False );
 }
 
+#ifndef MODULE_NAME_IS_xscreensaver
 /*****************************************************************************
  * ManageVideo: handle X11 events
  *****************************************************************************
@@ -864,6 +901,7 @@
 
     return 0;
 }
+#endif
 
 /*****************************************************************************
  * EndVideo: terminate X11 video thread output method
@@ -885,6 +923,7 @@
 
 /* following functions are local */
 
+#ifndef MODULE_NAME_IS_xscreensaver
 /*****************************************************************************
  * CreateWindow: open and set-up X11 main window
  *****************************************************************************/
@@ -1089,6 +1128,205 @@
 
     return VLC_SUCCESS;
 }
+#else
+
+/*****************************************************************************
+ * XscrCreateWindow: open and set-up X11 main window ( xscreensaver specific)
+ *****************************************************************************/
+ int XscrCreateWindow( vout_thread_t *p_vout, x11_window_t *p_win )
+{
+    XSizeHints              xsize_hints;
+    XSetWindowAttributes    xwindow_attributes;
+    XGCValues               xgcvalues;
+    XSetWindowAttributes attributes;
+#ifdef HAVE_XINERAMA
+    int i_d1, i_d2;
+#endif
+
+    /* Prepare window manager hints and properties */
+    xsize_hints.base_width          = p_win->i_width;
+    xsize_hints.base_height         = p_win->i_height;
+    xsize_hints.flags               = PSize;
+    p_win->wm_protocols =
+             XInternAtom( p_vout->p_sys->p_display, "WM_PROTOCOLS", True );
+    p_win->wm_delete_window =
+             XInternAtom( p_vout->p_sys->p_display, "WM_DELETE_WINDOW", True );
+
+    /* Prepare window attributes */
+    xwindow_attributes.backing_store = Always;       /* save the hidden part */
+    xwindow_attributes.background_pixel = BlackPixel(p_vout->p_sys->p_display,
+                                                     p_vout->p_sys->i_screen);
+    xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask;
+
+    /* Check whether someone provided us with a window ID */
+    p_win->owner_window = config_GetInt( p_vout, "xscreensaver-window" );
+    
+    if( !p_win->owner_window )
+    {
+        /* Create the window and set hints - the window must receive
+         * ConfigureNotify events, and until it is displayed, Expose and
+         * MapNotify events. */
+        p_vout->p_sys->p_win->i_width =
+            DisplayWidth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
+        p_vout->p_sys->p_win->i_height =
+            DisplayHeight( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );
+
+        p_win->base_window =
+            XCreateWindow( p_vout->p_sys->p_display,
+                           DefaultRootWindow( p_vout->p_sys->p_display ),
+                           0, 0,
+                           p_win->i_width, p_win->i_height,
+                           0,
+                           0, InputOutput, 0,
+                           CWBackingStore | CWBackPixel | CWEventMask,
+                           &xwindow_attributes );
+        /* brute force way to remove decorations */
+            attributes.override_redirect = True;
+            XChangeWindowAttributes( p_vout->p_sys->p_display,
+                                     p_vout->p_sys->p_win->base_window,
+                                     CWOverrideRedirect,
+                                     &attributes);
+
+            /* Make sure the change is effective */
+            XReparentWindow( p_vout->p_sys->p_display,
+                             p_vout->p_sys->p_win->base_window,
+                             DefaultRootWindow( p_vout->p_sys->p_display ),
+                             0, 0 );
+        p_vout->p_sys->p_win->i_x = 0;
+        p_vout->p_sys->p_win->i_y = 0;
+
+#ifdef HAVE_XINERAMA
+        if( XineramaQueryExtension( p_vout->p_sys->p_display, &i_d1, &i_d2 ) &&
+            XineramaIsActive( p_vout->p_sys->p_display ) )
+        {
+            XineramaScreenInfo *screens;   /* infos for xinerama */
+            int i_num_screens;
+
+            msg_Dbg( p_vout, "using XFree Xinerama extension");
+
+#define SCREEN p_vout->p_sys->p_win->i_screen
+
+            /* Get Informations about Xinerama (num of screens) */
+            screens = XineramaQueryScreens( p_vout->p_sys->p_display,
+                                            &i_num_screens );
+
+           if( !SCREEN )
+                SCREEN = config_GetInt( p_vout,
+                                        MODULE_STRING "-xineramascreen" );
+
+            /* just check that user has entered a good value */
+            if( SCREEN >= i_num_screens || SCREEN < 0 )
+            {
+                msg_Dbg( p_vout, "requested screen number invalid" );
+                SCREEN = 0;
+            }
+
+            /* Get the X/Y upper left corner coordinate of the above screen */
+            p_vout->p_sys->p_win->i_x = screens[SCREEN].x_org;
+            p_vout->p_sys->p_win->i_y = screens[SCREEN].y_org;
+
+            /* Set the Height/width to the screen resolution */
+            p_vout->p_sys->p_win->i_width = screens[SCREEN].width;
+            p_vout->p_sys->p_win->i_height = screens[SCREEN].height;
+
+            XFree(screens);
+
+#undef SCREEN
+        }
+#endif
+
+        XMoveResizeWindow( p_vout->p_sys->p_display,
+                           p_vout->p_sys->p_win->base_window,
+                           p_vout->p_sys->p_win->i_x,
+                           p_vout->p_sys->p_win->i_y,
+                           p_vout->p_sys->p_win->i_width,
+                           p_vout->p_sys->p_win->i_height );
+
+    }
+    else
+    {
+        /* Get the parent window's geometry information */
+        Window dummy1;
+        unsigned int dummy2, dummy3;
+        XGetGeometry( p_vout->p_sys->p_display, p_win->owner_window,
+                      &dummy1, &dummy2, &dummy3,
+                      &p_win->i_width,
+                      &p_win->i_height,
+                      &dummy2, &dummy3 );
+
+        /* From man XSelectInput: only one client at a time can select a
+         * ButtonPress event, so we need to open a new window anyway. */
+        p_win->base_window =
+            XCreateWindow( p_vout->p_sys->p_display,
+                           p_win->owner_window,
+                           0, 0,
+                           p_win->i_width, p_win->i_height,
+                           0,
+                           0, CopyFromParent, 0,
+                           CWBackingStore | CWBackPixel | CWEventMask,
+                           &xwindow_attributes );
+    }
+
+    /* Creation of a graphic context that doesn't generate a GraphicsExpose
+     * event when using functions like XCopyArea */
+    xgcvalues.graphics_exposures = False;
+    p_win->gc = XCreateGC( p_vout->p_sys->p_display,
+                           p_win->base_window,
+                           GCGraphicsExposures, &xgcvalues );
+
+    /* Send orders to server, and wait until window is displayed - 
+    *  As xscreensaver intercept event we can't know if window is displayed
+    *  Just Hope */
+    XMapWindow( p_vout->p_sys->p_display, p_win->base_window );
+
+    XSelectInput( p_vout->p_sys->p_display, p_win->base_window,
+                  StructureNotifyMask | KeyPressMask |
+                  ButtonPressMask | ButtonReleaseMask |
+                  PointerMotionMask );
+    if( XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 )
+    {
+        /* Allocate a new palette */
+        p_vout->p_sys->colormap =
+            XCreateColormap( p_vout->p_sys->p_display,
+                             DefaultRootWindow( p_vout->p_sys->p_display ),
+                             DefaultVisual( p_vout->p_sys->p_display,
+                                            p_vout->p_sys->i_screen ),
+                             AllocAll );
+
+        xwindow_attributes.colormap = p_vout->p_sys->colormap;
+        XChangeWindowAttributes( p_vout->p_sys->p_display, p_win->base_window,
+                                 CWColormap, &xwindow_attributes );
+    }
+/* Create video output sub-window. */
+    p_win->video_window =  XCreateSimpleWindow(
+                                      p_vout->p_sys->p_display,
+                                      p_win->base_window, 0, 0,
+                                      p_win->i_width, p_win->i_height,
+                                      0,
+                                      BlackPixel( p_vout->p_sys->p_display,
+                                                  p_vout->p_sys->i_screen ),
+                                      WhitePixel( p_vout->p_sys->p_display,
+                                                  p_vout->p_sys->i_screen ) );
+
+    XSetWindowBackground( p_vout->p_sys->p_display, p_win->video_window,
+                          BlackPixel( p_vout->p_sys->p_display,
+                                      p_vout->p_sys->i_screen ) );
+
+    XMapWindow( p_vout->p_sys->p_display, p_win->video_window );
+    XSelectInput( p_vout->p_sys->p_display, p_win->video_window,
+                  ExposureMask );
+
+    /* Do NOT use XFlush here ! */
+    XSync( p_vout->p_sys->p_display, False );
+
+    /* At this stage, the window is open, displayed, and ready to
+     * receive data */
+    p_vout->p_sys->p_win = p_win;
+
+    return VLC_SUCCESS;
+
+}
+#endif
 
 /*****************************************************************************
  * DestroyWindow: destroy the window
@@ -1270,6 +1508,7 @@
     free( p_pic->p_sys );
 }
 
+#ifndef MODULE_NAME_IS_xscreensaver
 /*****************************************************************************
  * ToggleFullScreen: Enable or disable full screen mode
  *****************************************************************************
@@ -1590,6 +1829,8 @@
         p_vout->p_sys->b_mouse_pointer_visible = 1;
     }
 }
+#endif    /* #ifndef MODULE_NAME_IS_xscreensaver */
+
 
 #ifdef MODULE_NAME_IS_xvideo
 /*****************************************************************************
@@ -1810,7 +2051,7 @@
  *****************************************************************************/
 static int InitDisplay( vout_thread_t *p_vout )
 {
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver)
     XPixmapFormatValues *       p_formats;                 /* pixmap formats */
     XVisualInfo *               p_xvisual;           /* visuals informations */
     XVisualInfo                 xvisual_template;         /* visual template */
@@ -1853,7 +2094,7 @@
 #endif
 #endif
 
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver)
     /* Initialize structure */
     p_vout->p_sys->i_screen = DefaultScreen( p_vout->p_sys->p_display );
 
@@ -2021,7 +2262,7 @@
 {
     byte_t *    p_data;                           /* image data storage zone */
     IMAGE_TYPE *p_image;
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver)
     int         i_quantum;                     /* XImage quantum (see below) */
     int         i_bytes_per_line;
 #endif
@@ -2039,7 +2280,7 @@
         return NULL;
     }
 
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver)
     /* Optimize the quantum of a scanline regarding its size - the quantum is
        a diviser of the number of bits between the start of two scanlines. */
     if( i_bytes_per_line & 0xf )
@@ -2074,7 +2315,7 @@
     return p_image;
 }
 
-#ifdef MODULE_NAME_IS_x11
+#if defined( MODULE_NAME_IS_x11 ) || defined( MODULE_NAME_IS_xscreensaver)
 /*****************************************************************************
  * SetPalette: sets an 8 bpp palette
  *****************************************************************************
@@ -2106,6 +2347,7 @@
 }
 #endif
 
+#ifndef MODULE_NAME_IS_xscreensaver
 /*****************************************************************************
  * TestNetWMSupport: tests for Extended Window Manager Hints support
  *****************************************************************************/
@@ -2256,3 +2498,4 @@
 
     return VLC_SUCCESS;
 }
+#endif
Index: share/Makefile.am
===================================================================
RCS file: /var/cvs/videolan/vlc/share/Makefile.am,v
retrieving revision 1.14
diff -u -r1.14 Makefile.am
--- share/Makefile.am	3 Mar 2004 17:18:38 -0000	1.14
+++ share/Makefile.am	19 Mar 2004 15:20:47 -0000
@@ -15,6 +15,7 @@
 nobase_dist_pkgdata_DATA = \
 	$(DIST_skins) \
 	$(DIST_http) \
+	$(DIST_xscreensaver) \
 	$(NULL)
 
 DIST_fonts = \
@@ -139,3 +137,7 @@
 	http/admin/.access \
 	http/style.css \
 	$(NULL)
+
+DIST_xscreensaver = \
+	xscreensaver/vlc-xscreensaver \
+	$(NULL)
-------------- next part --------------
How to use VLC media player as screensaver.

(c) 2004 Christophe Mutricy <xtophe at nxtelevision.com>

License : ?

This document aims to help you to use VLC as a screensaver on a box running Linux.

Which softwares do you need :

	- xscreensaver: an extensible screen saver framework. It's packaged in any good distro. 
			It's provided yet a lot of screensavers.
			For more info: man xscreensaver
				       http://www.jwz.org/xscreensaver/
	- vlc with the xscreensaver module. To see if the xscreensaver module is available, 
			type: vlc -l |grep xscreensaver.If not, try to find package with it 
			inside or compile from sources (www.videolan.org/vlc/download-sources.html).

What do you need to do :

XScreensaver configuration files are /etc/X11/app-defaults/XScreenSaver  (at least in Debian) for all 
users and ~/.xscreensaver.
We need to add vlc with the good option to one of those files.

With xscreensaver-demo, you can have a preview of the screensaver. Xscreensaver give -window-id <window id>
as argument to the screensaver program. So we need to translate -window-id to --xscreensaver-window.
That's why, you should use a little shell script. The one in share/xscreensaver/ (or /usr/share/vlc/xscreensaver) 
could give you some ideas.

We must pass to VLC those option: 	*  -V xscreensaver : obvious
					*  -I dummy : so no interface or GUI is loaded
					*  --loop : to loop at end of playlist.

We can pass other option like:		* --quiet
					* --no-sound
					* or any option usefull to counter the one in ~/.vlc/vlcrc

And we need to give one or several videos or a playlist. As MRL are not funny to write by hands,
you should load VLC with a GUI and save the playlist.

In my example, all the options  are inside the script and the playlist is given as an arguments.

Now we can edit ~/.xscreensaver or /etc/X11/app-defaults/XScreenSaver. Look for programs.
That's the list of all the screensaver. Then add our script. It should look like that :


programs:                                                                     \
                         "VLC"  vlc-xscreensaver  "~/video1.mpg ~/video2.avi"  \n\
                 "Qix (solid)"  qix -root -solid -delay 0 -segments 100     \n\
           "Qix (transparent)"  qix -root -count 4 -solid -transparent      \n\
                "Qix (linear)"  qix -root -count 5 -solid -transparent        \
                                  -linear -segments 250 -size 100           \n\
- mono:            "Qix (xor)"  qix -root -linear -count 5 -size 200          \
                                  -spread 30 -segments 75 -solid -xor       \n\
          "Attraction (balls)"  attraction -root -mode balls                \n\
          "Attraction (lines)"  attraction -root -mode lines -points 3        \
                                  -segments 200                             \n\
...

Note that the directory where is vlc-xscreensaver is in my $PATH. If not, you should put the complete address.

We can now lauch xscreensaver-demo and test.



$Id   $
-------------- next part --------------
#! /bin/sh
# vlc-xscreensaver - Example script to run VLC media player as screensaver
# Copyright (c) 2004 VideoLAN
# $Id:  $
# Author: Christophe Mutricy <xtophe at nxtelevision.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


# VLC="vlc -V xscreensaver -I dummy --loop"
VLC=" /home/xtophe/bidouille/vlc-0.7.1-test2/vlc -V xscreensaver -I dummy --loop
    --plugin-path /home/xtophe/bidouille/vlc-0.7.1-test2/modules" 

OPTION=" --quiet  --noaudio " 

# Test if we have a playlist and if xscreensaver give us a window id.
# Note that we replace this script by vlc with 'exec'. So vlc will receive
# the SIGTERM of xscreensaver.


if [ "$1" != '' ]
then 
	case "$2" in
		'')
			exec $VLC $OPTION $1
			;;
		'-window-id')
			exec $VLC $OPTION --xscreensaver-window $3 $1
			;;
		*)
			echo "$0 error: invalid argument  $2 "
			;;
	esac
else
	echo " $0 error: not enough argument"
fi

echo "Usage: $0 \"video1 video 2 ... \" [ -window-id <window id>]"
exit 1

	
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xscreensaver.c
Type: text/x-csrc
Size: 3402 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20040319/297ae7fc/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vroot.h
Type: text/x-chdr
Size: 5266 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20040319/297ae7fc/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20040319/297ae7fc/attachment.sig>


More information about the vlc-devel mailing list