1 /*****************************************************************************
2 * screensaver.c : disable screen savers when VLC is playing
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
7 * Authors: Sam Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
34 /*****************************************************************************
36 *****************************************************************************/
37 static int Activate ( vlc_object_t * );
38 static void Run ( intf_thread_t *p_intf );
40 /*****************************************************************************
42 *****************************************************************************/
44 set_description( _("X Screensaver disabler") );
45 set_capability( "interface", 0 );
46 set_callbacks( Activate, NULL );
49 /*****************************************************************************
50 * Activate: initialize and create stuff
51 *****************************************************************************/
52 static int Activate( vlc_object_t *p_this )
54 intf_thread_t *p_intf = (intf_thread_t*)p_this;
61 /*****************************************************************************
63 *****************************************************************************
64 * This part of the module is in a separate thread so that we do not have
65 * too much system() overhead.
66 *****************************************************************************/
67 static void Run( intf_thread_t *p_intf )
71 while( !p_intf->b_die )
75 /* Check screensaver every 30 seconds */
76 if( ++i_lastcall > 300 )
79 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
80 /* If there is a video output, disable xscreensaver */
83 vlc_object_release( p_vout );
85 /* http://www.jwz.org/xscreensaver/faq.html#dvd */
86 system( "xscreensaver-command -deactivate >&- 2>&- &" );
88 /* FIXME: add support for other screensavers */